1 --- yum-3.2.0/yum/config.py.chroot
2 +++ yum-3.2.0/yum/config.py
4 pluginpath = ListOption(['/usr/share/yum-plugins', '/usr/lib/yum-plugins'])
5 pluginconfpath = ListOption(['/etc/yum/pluginconf.d'])
7 + def getRootedPath(self, path, enforce_default=False, defaults_to_host=False):
8 + instroot = getattr(self, 'installroot', None)
12 + if path.startswith('hostfs://'): res = path[9:]
13 + elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:]
15 + tmp = instroot + '/' + path
18 + if defaults_to_host: res = path
21 + if os.path.exists(tmp): res = tmp
22 + elif defaults_to_host: res = path
27 class YumConf(StartupConf):
29 Configuration option definitions for yum.conf\'s [main] section.
31 cachedir = Option('/var/cache/yum')
32 keepcache = BoolOption(True)
33 logfile = Option('/var/log/yum.log')
34 + lockfile = Option('/var/run/yum.pid')
35 reposdir = ListOption(['/etc/yum/repos.d', '/etc/yum.repos.d'])
36 syslog_ident = Option()
37 syslog_facility = Option('LOG_DAEMON')
39 yumconf.populate(startupconf._parser, 'main')
41 # Apply the installroot to directory options
42 - for option in ('cachedir', 'logfile'):
43 + for option in ('cachedir', 'logfile', 'lockfile'):
44 path = getattr(yumconf, option)
45 - setattr(yumconf, option, yumconf.installroot + path)
46 + setattr(yumconf, option, yumconf.getRootedPath(path))
48 # Add in some extra attributes which aren't actually configuration values
49 yumconf.yumvar = yumvars
50 --- yum-3.2.0/yum/__init__.py.chroot
51 +++ yum-3.2.0/yum/__init__.py
53 # (typically /etc/yum/repos.d)
54 parser = ConfigParser()
55 for reposdir in self.conf.reposdir:
56 - if os.path.exists(self.conf.installroot+'/'+reposdir):
57 - reposdir = self.conf.installroot + '/' + reposdir
58 + reposdir = self.conf.getRootedPath(reposdir)
60 if os.path.isdir(reposdir):
61 for repofn in glob.glob('%s/*.repo' % reposdir):
64 self.verbose_logger.log(logginglevels.INFO_2, 'Finished')
66 - def doLock(self, lockfile = YUM_PID_FILE):
68 """perform the yum locking, raise yum-based exceptions, not OSErrors"""
70 # if we're not root then we don't lock - just return nicely
71 if self.conf.uid != 0:
74 - root = self.conf.installroot
75 - lockfile = root + '/' + lockfile # lock in the chroot
76 - lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra /
79 + lockfile = self.conf.lockfile
81 mypid=str(os.getpid())
82 while not self._lock(lockfile, mypid, 0644):
83 fd = open(lockfile, 'r')
85 msg = 'Existing lock %s: another copy is running as pid %s. Aborting.' % (lockfile, oldpid)
86 raise Errors.LockError(0, msg)
88 - def doUnlock(self, lockfile = YUM_PID_FILE):
90 """do the unlock for yum"""
92 # if we're not root then we don't lock - just return nicely
93 if self.conf.uid != 0:
96 - root = self.conf.installroot
97 - lockfile = root + '/' + lockfile # lock in the chroot
99 + lockfile=self.conf.lockfile
101 self._unlock(lockfile)
103 def _lock(self, filename, contents='', mode=0777):
104 --- yum-3.2.0/docs/yum.conf.5.chroot
105 +++ yum-3.2.0/docs/yum.conf.5
110 -Directory where yum should store its cache and db files. The default is
112 +Directory where yum should store its cache and db files. The default
113 +is `/var/cache/yum'. Unless the prefixes `hostfs://' or `chrootfs://'
114 +are used, some magic will be applied to determine the real path in
115 +combination with `--installroot'.
118 Either `1' or `0'. Determines whether or not yum keeps the cache
120 repositories defined in /etc/yum/yum.conf to form the complete set of
121 repositories that yum will use.
123 +Unless the prefixes `hostfs://' or `chrootfs://' are used, some magic
124 +will be applied to determine the real path in combination with
128 Debug message output level. Practical range is 0\-10. Default is `2'.
131 Error message output level. Practical range is 0\-10. Default is `2'.
134 -Full directory and file name for where yum should write its log file.
135 +Full directory and file name for where yum should write its log
136 +file. Unless the prefixes `hostfs://' or `chrootfs://' are used,
137 +some magic will be applied to determine the real path in combination
138 +with `--installroot'.
141 Either `1' or `0'. This tells yum whether or not it should perform a GPG
142 --- yum-3.2.0/cli.py.chroot
144 @@ -1166,13 +1166,16 @@
145 def getRoot(self,opts):
146 # If the conf file is inside the installroot - use that.
147 # otherwise look for it in the normal root
148 - if opts.installroot:
149 - if os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
150 + if opts.conffile==None:
151 + opts.conffile = '/etc/yum.conf'
152 + if opts.installroot and os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
153 opts.conffile = opts.installroot+'/'+opts.conffile
154 elif opts.conffile == '/etc/yum/yum.conf':
155 # check if /installroot/etc/yum.conf exists.
156 if os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
157 opts.conffile = opts.installroot+'/etc/yum.conf'
159 + if opts.installroot:
160 root=opts.installroot
163 @@ -1195,7 +1198,7 @@
164 action="store_true", default=False,
165 help="run entirely from cache, don't update cache")
166 self.add_option("-c", "", dest="conffile", action="store",
167 - default='/etc/yum/yum.conf', help="config file location",
168 + default=None, help="config file location",
169 metavar=' [config file]')
170 self.add_option("-R", "", dest="sleeptime", action="store",
171 type='int', default=None, help="maximum command wait time",