1 --- yum-3.2.4/yum/__init__.py.chroot
2 +++ yum-3.2.4/yum/__init__.py
3 @@ -214,8 +214,7 @@ class YumBase(depsolve.Depsolve):
4 repo_config_age = self.conf.config_file_age
6 for reposdir in self.conf.reposdir:
7 - if os.path.exists(self.conf.installroot+'/'+reposdir):
8 - reposdir = self.conf.installroot + '/' + reposdir
9 + reposdir = self.conf.getRootedPath(reposdir)
11 if os.path.isdir(reposdir):
12 for repofn in glob.glob('%s/*.repo' % reposdir):
13 @@ -664,11 +663,9 @@ class YumBase(depsolve.Depsolve):
14 # if we're not root then we don't lock - just return nicely
15 if self.conf.uid != 0:
18 - root = self.conf.installroot
19 - lockfile = root + '/' + lockfile # lock in the chroot
20 - lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra /
23 + lockfile = self.conf.lockfile
25 mypid=str(os.getpid())
26 while not self._lock(lockfile, mypid, 0644):
27 fd = open(lockfile, 'r')
28 @@ -700,9 +697,8 @@ class YumBase(depsolve.Depsolve):
29 if self.conf.uid != 0:
32 - root = self.conf.installroot
33 - lockfile = root + '/' + lockfile # lock in the chroot
35 + lockfile=self.conf.lockfile
37 self._unlock(lockfile)
39 def _lock(self, filename, contents='', mode=0777):
40 --- yum-3.2.4/yum/config.py.chroot
41 +++ yum-3.2.4/yum/config.py
42 @@ -469,6 +469,26 @@ class StartupConf(BaseConfig):
43 pluginpath = ListOption(['/usr/share/yum-plugins', '/usr/lib/yum-plugins'])
44 pluginconfpath = ListOption(['/etc/yum/pluginconf.d'])
46 + def getRootedPath(self, path, enforce_default=False, defaults_to_host=False):
47 + instroot = getattr(self, 'installroot', None)
51 + if path.startswith('hostfs://'): res = path[9:]
52 + elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:]
54 + tmp = instroot + '/' + path
57 + if defaults_to_host: res = path
60 + if os.path.exists(tmp): res = tmp
61 + elif defaults_to_host: res = path
66 class YumConf(StartupConf):
68 Configuration option definitions for yum.conf\'s [main] section.
69 @@ -482,6 +502,7 @@ class YumConf(StartupConf):
70 persistdir = Option('/var/lib/yum')
71 keepcache = BoolOption(True)
72 logfile = Option('/var/log/yum.log')
73 + lockfile = Option('/var/run/yum.pid')
74 reposdir = ListOption(['/etc/yum/repos.d', '/etc/yum.repos.d'])
75 syslog_ident = Option()
76 syslog_facility = Option('LOG_DAEMON')
77 @@ -615,9 +636,9 @@ def readMainConfig(startupconf):
78 yumconf.populate(startupconf._parser, 'main')
80 # Apply the installroot to directory options
81 - for option in ('cachedir', 'logfile', 'persistdir'):
82 + for option in ('cachedir', 'logfile', 'persistdir', 'lockfile'):
83 path = getattr(yumconf, option)
84 - setattr(yumconf, option, yumconf.installroot + path)
85 + setattr(yumconf, option, yumconf.getRootedPath(path))
87 # Add in some extra attributes which aren't actually configuration values
88 yumconf.yumvar = yumvars
89 --- yum-3.2.4/docs/yum.conf.5.chroot
90 +++ yum-3.2.4/docs/yum.conf.5
91 @@ -23,8 +23,10 @@ The [main] section must exist for yum to
95 -Directory where yum should store its cache and db files. The default is
97 +Directory where yum should store its cache and db files. The default
98 +is `/var/cache/yum'. Unless the prefixes `hostfs://' or `chrootfs://'
99 +are used, some magic will be applied to determine the real path in
100 +combination with `--installroot'.
103 Directory where yum should store information that should persist over multiple
104 @@ -44,6 +46,10 @@ documented in \fB[repository] options\fR
105 repositories defined in /etc/yum/yum.conf to form the complete set of
106 repositories that yum will use.
108 +Unless the prefixes `hostfs://' or `chrootfs://' are used, some magic
109 +will be applied to determine the real path in combination with
113 Debug message output level. Practical range is 0\-10. Default is `2'.
115 @@ -51,7 +57,10 @@ Debug message output level. Practical ra
116 Error message output level. Practical range is 0\-10. Default is `2'.
119 -Full directory and file name for where yum should write its log file.
120 +Full directory and file name for where yum should write its log
121 +file. Unless the prefixes `hostfs://' or `chrootfs://' are used,
122 +some magic will be applied to determine the real path in combination
123 +with `--installroot'.
126 Either `1' or `0'. This tells yum whether or not it should perform a GPG
127 --- yum-3.2.4/cli.py.chroot
129 @@ -1204,13 +1204,14 @@ class YumOptionParser(OptionParser):
130 def getRoot(self,opts):
131 # If the conf file is inside the installroot - use that.
132 # otherwise look for it in the normal root
133 + if opts.conffile==None:
134 + opts.conffile = '/etc/yum/yum.conf'
135 + if opts.installroot:
136 + if os.access(opts.installroot+opts.conffile, os.R_OK):
137 + opts.conffile = opts.installroot+opts.conffile
138 + elif os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
139 + opts.conffile = opts.installroot+'/etc/yum.conf'
141 - if os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
142 - opts.conffile = opts.installroot+'/'+opts.conffile
143 - elif opts.conffile == '/etc/yum/yum.conf':
144 - # check if /installroot/etc/yum.conf exists.
145 - if os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
146 - opts.conffile = opts.installroot+'/etc/yum.conf'
147 root=opts.installroot
150 @@ -1231,7 +1232,7 @@ class YumOptionParser(OptionParser):
151 help="be tolerant of errors")
152 self.add_option("-C", dest="cacheonly", action="store_true",
153 help="run entirely from cache, don't update cache")
154 - self.add_option("-c", dest="conffile", default='/etc/yum/yum.conf',
155 + self.add_option("-c", dest="conffile", default=None,
156 help="config file location", metavar=' [config file]')
157 self.add_option("-R", dest="sleeptime", type='int', default=None,
158 help="maximum command wait time", metavar=' [minutes]')