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,7 +636,7 @@ 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)
86 --- yum-3.2.4/docs/yum.conf.5.chroot
87 +++ yum-3.2.4/docs/yum.conf.5
88 @@ -23,8 +23,10 @@ The [main] section must exist for yum to
92 -Directory where yum should store its cache and db files. The default is
94 +Directory where yum should store its cache and db files. The default
95 +is `/var/cache/yum'. Unless the prefixes `hostfs://' or `chrootfs://'
96 +are used, some magic will be applied to determine the real path in
97 +combination with `--installroot'.
100 Directory where yum should store information that should persist over multiple
101 @@ -44,6 +46,10 @@ documented in \fB[repository] options\fR
102 repositories defined in /etc/yum/yum.conf to form the complete set of
103 repositories that yum will use.
105 +Unless the prefixes `hostfs://' or `chrootfs://' are used, some magic
106 +will be applied to determine the real path in combination with
110 Debug message output level. Practical range is 0\-10. Default is `2'.
112 @@ -51,7 +57,10 @@ Debug message output level. Practical ra
113 Error message output level. Practical range is 0\-10. Default is `2'.
116 -Full directory and file name for where yum should write its log file.
117 +Full directory and file name for where yum should write its log
118 +file. Unless the prefixes `hostfs://' or `chrootfs://' are used,
119 +some magic will be applied to determine the real path in combination
120 +with `--installroot'.
123 Either `1' or `0'. This tells yum whether or not it should perform a GPG
124 --- yum-3.2.4/cli.py.chroot
126 @@ -1204,13 +1204,14 @@ class YumOptionParser(OptionParser):
127 def getRoot(self,opts):
128 # If the conf file is inside the installroot - use that.
129 # otherwise look for it in the normal root
130 + if opts.conffile==None:
131 + opts.conffile = '/etc/yum/yum.conf'
132 + if opts.installroot:
133 + if os.access(opts.installroot+opts.conffile, os.R_OK):
134 + opts.conffile = opts.installroot+opts.conffile
135 + elif os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
136 + opts.conffile = opts.installroot+'/etc/yum.conf'
138 - if os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
139 - opts.conffile = opts.installroot+'/'+opts.conffile
140 - elif opts.conffile == '/etc/yum/yum.conf':
141 - # check if /installroot/etc/yum.conf exists.
142 - if os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
143 - opts.conffile = opts.installroot+'/etc/yum.conf'
144 root=opts.installroot
147 @@ -1231,7 +1232,7 @@ class YumOptionParser(OptionParser):
148 help="be tolerant of errors")
149 self.add_option("-C", dest="cacheonly", action="store_true",
150 help="run entirely from cache, don't update cache")
151 - self.add_option("-c", dest="conffile", default='/etc/yum/yum.conf',
152 + self.add_option("-c", dest="conffile", default=None,
153 help="config file location", metavar=' [config file]')
154 self.add_option("-R", dest="sleeptime", type='int', default=None,
155 help="maximum command wait time", metavar=' [minutes]')