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):
56 + def __getLockfileName(self):
57 + lockfile = self.conf.lockfile
58 + return self.conf.getRootedPath(lockfile,
59 + enforce_default = True,
60 + defaults_to_host = False)
63 """perform the yum locking, raise yum-based exceptions, not OSErrors"""
65 # if we're not root then we don't lock - just return nicely
66 if self.conf.uid != 0:
69 - root = self.conf.installroot
70 - lockfile = root + '/' + lockfile # lock in the chroot
71 - lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra /
72 + lockfile = self.__getLockfileName()
74 mypid=str(os.getpid())
75 while not self._lock(lockfile, mypid, 0644):
77 msg = 'Existing lock %s: another copy is running. Aborting.' % lockfile
78 raise Errors.LockError(0, msg)
80 - def doUnlock(self, lockfile):
82 """do the unlock for yum"""
84 # if we're not root then we don't lock - just return nicely
85 if self.conf.uid != 0:
88 - root = self.conf.installroot
89 - lockfile = root + '/' + lockfile # lock in the chroot
90 + lockfile=self.__getLockfileName()
92 self._unlock(lockfile)
94 --- yum-2.6.0/yum/config.py.chroot 2006-03-07 04:40:08.000000000 +0100
95 +++ yum-2.6.0/yum/config.py 2006-03-26 13:22:41.000000000 +0200
98 raise Errors.ConfigError, 'No such option %s' % option
100 + def getRootedPath(self, path, enforce_default=False, defaults_to_host=False):
101 + instroot = getattr(self, 'installroot', None)
105 + if path.startswith('hostfs://'): res = path[9:]
106 + elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:]
108 + tmp = instroot + '/' +path
110 + if enforce_default:
111 + if defaults_to_host: res = path
114 + if os.path.exists(tmp): res = tmp
115 + elif defaults_to_host: res = path
121 class EarlyConf(BaseConfig):
123 Configuration option definitions for yum.conf's [main] section that are
125 cachedir = Option('/var/cache/yum')
126 keepcache = BoolOption(True)
127 logfile = Option('/var/log/yum.log')
128 + lockfile = Option('/var/run/yum.pid')
129 reposdir = ListOption(['/etc/yum/repos.d', '/etc/yum.repos.d'])
130 syslog_ident = Option()
131 syslog_facility = Option('LOG_DAEMON')
133 yumconf.populate(confparser, 'main')
135 # Apply the installroot to directory options
136 - for option in ('cachedir', 'logfile'):
137 + for option in ('cachedir', 'logfile', 'lockfile'):
138 path = getattr(yumconf, option)
139 - setattr(yumconf, option, yumconf.installroot + path)
140 + setattr(yumconf, option, yumconf.getRootedPath(path))
142 # Check that plugin paths are all absolute
143 for path in yumconf.pluginpath:
144 --- yum-2.6.0/cli.py.chroot 2006-02-22 22:16:13.000000000 +0100
145 +++ yum-2.6.0/cli.py 2006-03-26 13:21:35.000000000 +0200
147 action="store_true", default=False,
148 help="run entirely from cache, don't update cache")
149 self.optparser.add_option("-c", "", dest="conffile", action="store",
150 - default='/etc/yum.conf', help="config file location",
151 + default=None, help="config file location",
152 metavar=' [config file]')
153 self.optparser.add_option("-R", "", dest="sleeptime", action="store",
154 type='int', default=None, help="maximum command wait time",
157 # If the conf file is inside the installroot - use that.
158 # otherwise look for it in the normal root
159 - if opts.installroot:
160 - if os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
161 + if opts.conffile==None:
162 + opts.conffile = '/etc/yum.conf'
163 + if opts.installroot and os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
164 opts.conffile = opts.installroot+'/'+opts.conffile
166 + if opts.installroot:
167 root=opts.installroot
170 --- yum-2.6.0/yummain.py.chroot 2005-12-13 09:35:41.000000000 +0100
171 +++ yum-2.6.0/yummain.py 2006-03-26 13:21:35.000000000 +0200
176 - base.doUnlock(YUM_PID_FILE)
178 except Errors.LockError, e:
182 except Errors.YumBaseError, e:
185 - base.doLock(YUM_PID_FILE)
187 except Errors.LockError, e:
188 base.errorlog(0,'%s' % e.msg)