1 --- yum-3.0.3/docs/yum.conf.5.chroot 2006-11-17 08:10:32.000000000 +0100
2 +++ yum-3.0.3/docs/yum.conf.5 2007-01-16 20:28:39.000000000 +0100
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-3.0.3/yum/config.py.chroot 2006-12-07 18:25:02.000000000 +0100
40 +++ yum-3.0.3/yum/config.py 2007-01-16 20:28:39.000000000 +0100
42 pluginpath = ListOption(['/usr/lib/yum-plugins'])
43 pluginconfpath = ListOption(['/etc/yum/pluginconf.d'])
45 + def getRootedPath(self, path, enforce_default=False, defaults_to_host=False):
46 + instroot = getattr(self, 'installroot', None)
50 + if path.startswith('hostfs://'): res = path[9:]
51 + elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:]
53 + tmp = instroot + '/' + path
56 + if defaults_to_host: res = path
59 + if os.path.exists(tmp): res = tmp
60 + elif defaults_to_host: res = path
65 class YumConf(StartupConf):
67 Configuration option definitions for yum.conf\'s [main] section.
69 cachedir = Option('/var/cache/yum')
70 keepcache = BoolOption(True)
71 logfile = Option('/var/log/yum.log')
72 + lockfile = Option('/var/run/yum.pid')
73 reposdir = ListOption(['/etc/yum/repos.d', '/etc/yum.repos.d'])
74 syslog_ident = Option()
75 syslog_facility = Option('LOG_DAEMON')
77 yumconf.populate(startupconf._parser, 'main')
79 # Apply the installroot to directory options
80 - for option in ('cachedir', 'logfile'):
81 + for option in ('cachedir', 'logfile', 'lockfile'):
82 path = getattr(yumconf, option)
83 - setattr(yumconf, option, yumconf.installroot + path)
84 + setattr(yumconf, option, yumconf.getRootedPath(path))
86 # Add in some extra attributes which aren't actually configuration values
87 yumconf.yumvar = yumvars
88 --- yum-3.0.3/yum/__init__.py.chroot 2007-01-07 21:09:27.000000000 +0100
89 +++ yum-3.0.3/yum/__init__.py 2007-01-16 20:32:04.000000000 +0100
91 # (typically /etc/yum.repos.d and /etc/yum/repos.d)
92 parser = ConfigParser()
93 for reposdir in self.conf.reposdir:
94 - if os.path.exists(self.conf.installroot+'/'+reposdir):
95 - reposdir = self.conf.installroot + '/' + reposdir
96 + reposdir = self.conf.getRootedPath(reposdir)
98 if os.path.isdir(reposdir):
99 for repofn in glob.glob('%s/*.repo' % reposdir):
100 @@ -523,17 +522,15 @@
102 self.verbose_logger.log(logginglevels.INFO_2, 'Finished')
104 - def doLock(self, lockfile = YUM_PID_FILE):
106 """perform the yum locking, raise yum-based exceptions, not OSErrors"""
108 # if we're not root then we don't lock - just return nicely
109 if self.conf.uid != 0:
112 - root = self.conf.installroot
113 - lockfile = root + '/' + lockfile # lock in the chroot
114 - lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra /
117 + lockfile = self.conf.lockfile
119 mypid=str(os.getpid())
120 while not self._lock(lockfile, mypid, 0644):
121 fd = open(lockfile, 'r')
122 @@ -558,16 +555,15 @@
123 msg = 'Existing lock %s: another copy is running. Aborting.' % lockfile
124 raise Errors.LockError(0, msg)
126 - def doUnlock(self, lockfile = YUM_PID_FILE):
127 + def doUnlock(self):
128 """do the unlock for yum"""
130 # if we're not root then we don't lock - just return nicely
131 if self.conf.uid != 0:
134 - root = self.conf.installroot
135 - lockfile = root + '/' + lockfile # lock in the chroot
137 + lockfile=self.conf.lockfile
139 self._unlock(lockfile)
141 def _lock(self, filename, contents='', mode=0777):
142 --- yum-3.0.3/cli.py.chroot 2006-12-08 00:27:08.000000000 +0100
143 +++ yum-3.0.3/cli.py 2007-01-16 20:28:39.000000000 +0100
145 action="store_true", default=False,
146 help="run entirely from cache, don't update cache")
147 self.optparser.add_option("-c", "", dest="conffile", action="store",
148 - default='/etc/yum.conf', help="config file location",
149 + default=None, help="config file location",
150 metavar=' [config file]')
151 self.optparser.add_option("-R", "", dest="sleeptime", action="store",
152 type='int', default=None, help="maximum command wait time",
155 # If the conf file is inside the installroot - use that.
156 # otherwise look for it in the normal root
157 - if opts.installroot:
158 - if os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
159 + if opts.conffile==None:
160 + opts.conffile = '/etc/yum.conf'
161 + if opts.installroot and os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
162 opts.conffile = opts.installroot+'/'+opts.conffile
164 + if opts.installroot:
165 root=opts.installroot