1 --- yum-2.6.0/docs/yum.conf.5.chroot 2006-03-07 04:40:08.000000000 +0100
2 +++ yum-2.6.0/docs/yum.conf.5 2006-03-26 13:21:35.000000000 +0200
7 -Directory where yum should store its cache and db files. The default is
9 +Directory where yum should store its cache and db files. The default
10 +is `/var/cache/yum'. Unless the prefixes `hostfs://' or `chrootfs://'
11 +are used, some magic will be applied to determine the real path in
12 +combination with `--installroot'.
15 Either `1' or `0'. Determines whether or not yum keeps the cache
17 repositories defined in /etc/yum.conf to form the complete set of repositories
20 +Unless the prefixes `hostfs://' or `chrootfs://' are used, some magic
21 +will be applied to determine the real path in combination with
25 Debug message output level. Practical range is 0\-10. Default is `2'.
28 Error message output level. Practical range is 0\-10. Default is `2'.
31 -Full directory and file name for where yum should write its log file.
32 +Full directory and file name for where yum should write its log
33 +file. Unless the prefixes `hostfs://' or `chrootfs://' are used,
34 +some magic will be applied to determine the real path in combination
35 +with `--installroot'.
38 Either `1' or `0'. This tells yum whether or not it should perform a GPG
39 --- yum-2.6.0/yum/__init__.py.chroot 2006-03-07 05:38:00.000000000 +0100
40 +++ yum-2.6.0/yum/__init__.py 2006-03-26 13:21:35.000000000 +0200
42 # (typically /etc/yum.repos.d and /etc/yum/repos.d)
43 parser = config.IncludedDirConfigParser(vars=self.yumvar)
44 for reposdir in self.conf.reposdir:
45 - if os.path.exists(self.conf.installroot+'/'+reposdir):
46 - reposdir = self.conf.installroot + '/' + reposdir
47 + reposdir = self.conf.getRootedPath(reposdir)
49 if os.path.isdir(reposdir):
50 #XXX: why can't we just pass the list of files?
53 self.log(2, 'Finished')
55 - def doLock(self, lockfile):
57 """perform the yum locking, raise yum-based exceptions, not OSErrors"""
59 # if we're not root then we don't lock - just return nicely
60 if self.conf.uid != 0:
63 - root = self.conf.installroot
64 - lockfile = root + '/' + lockfile # lock in the chroot
65 - lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra /
66 + lockfile = self.conf.lockfile
68 mypid=str(os.getpid())
69 while not self._lock(lockfile, mypid, 0644):
71 msg = 'Existing lock %s: another copy is running. Aborting.' % lockfile
72 raise Errors.LockError(0, msg)
74 - def doUnlock(self, lockfile):
76 """do the unlock for yum"""
78 # if we're not root then we don't lock - just return nicely
79 if self.conf.uid != 0:
82 - root = self.conf.installroot
83 - lockfile = root + '/' + lockfile # lock in the chroot
84 + lockfile=self.conf.lockfile
86 self._unlock(lockfile)
88 --- yum-2.6.0/yum/config.py.chroot 2006-03-07 04:40:08.000000000 +0100
89 +++ yum-2.6.0/yum/config.py 2006-03-26 13:22:41.000000000 +0200
92 raise Errors.ConfigError, 'No such option %s' % option
94 + def getRootedPath(self, path, enforce_default=False, defaults_to_host=False):
95 + instroot = getattr(self, 'installroot', None)
99 + if path.startswith('hostfs://'): res = path[9:]
100 + elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:]
102 + tmp = instroot + '/' +path
104 + if enforce_default:
105 + if defaults_to_host: res = path
108 + if os.path.exists(tmp): res = tmp
109 + elif defaults_to_host: res = path
115 class EarlyConf(BaseConfig):
117 Configuration option definitions for yum.conf's [main] section that are
119 cachedir = Option('/var/cache/yum')
120 keepcache = BoolOption(True)
121 logfile = Option('/var/log/yum.log')
122 + lockfile = Option('/var/run/yum.pid')
123 reposdir = ListOption(['/etc/yum/repos.d', '/etc/yum.repos.d'])
124 syslog_ident = Option()
125 syslog_facility = Option('LOG_DAEMON')
127 yumconf.populate(confparser, 'main')
129 # Apply the installroot to directory options
130 - for option in ('cachedir', 'logfile'):
131 + for option in ('cachedir', 'logfile', 'lockfile'):
132 path = getattr(yumconf, option)
133 - setattr(yumconf, option, yumconf.installroot + path)
134 + setattr(yumconf, option, yumconf.getRootedPath(path))
136 # Check that plugin paths are all absolute
137 for path in yumconf.pluginpath:
138 --- yum-2.6.0/cli.py.chroot 2006-02-22 22:16:13.000000000 +0100
139 +++ yum-2.6.0/cli.py 2006-03-26 13:21:35.000000000 +0200
141 action="store_true", default=False,
142 help="run entirely from cache, don't update cache")
143 self.optparser.add_option("-c", "", dest="conffile", action="store",
144 - default='/etc/yum.conf', help="config file location",
145 + default=None, help="config file location",
146 metavar=' [config file]')
147 self.optparser.add_option("-R", "", dest="sleeptime", action="store",
148 type='int', default=None, help="maximum command wait time",
151 # If the conf file is inside the installroot - use that.
152 # otherwise look for it in the normal root
153 - if opts.installroot:
154 - if os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
155 + if opts.conffile==None:
156 + opts.conffile = '/etc/yum.conf'
157 + if opts.installroot and os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
158 opts.conffile = opts.installroot+'/'+opts.conffile
160 + if opts.installroot:
161 root=opts.installroot
164 --- yum-2.6.0/yummain.py.chroot 2005-12-13 09:35:41.000000000 +0100
165 +++ yum-2.6.0/yummain.py 2006-03-26 13:21:35.000000000 +0200
170 - base.doUnlock(YUM_PID_FILE)
172 except Errors.LockError, e:
176 except Errors.YumBaseError, e:
179 - base.doLock(YUM_PID_FILE)
181 except Errors.LockError, e:
182 base.errorlog(0,'%s' % e.msg)