1 diff -ur yum-3.2.28.orig/cli.py yum-3.2.28/cli.py
2 --- yum-3.2.28.orig/cli.py 2010-07-07 14:46:08.000000000 -0400
3 +++ yum-3.2.28/cli.py 2010-10-18 14:05:51.919642477 -0400
4 @@ -1409,13 +1409,15 @@
5 def getRoot(self,opts):
6 # If the conf file is inside the installroot - use that.
7 # otherwise look for it in the normal root
8 + if opts.conffile is None:
9 + opts.conffile = '/etc/yum/yum.conf'
10 + if opts.installroot:
11 + if os.access(opts.installroot+opts.conffile, os.R_OK):
12 + opts.conffile = opts.installroot+opts.conffile
13 + elif os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
14 + opts.conffile = opts.installroot+'/etc/yum.conf'
17 - if os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
18 - opts.conffile = opts.installroot+'/'+opts.conffile
19 - elif opts.conffile == '/etc/yum/yum.conf':
20 - # check if /installroot/etc/yum.conf exists.
21 - if os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
22 - opts.conffile = opts.installroot+'/etc/yum.conf'
28 help=_("run entirely from system cache, don't update cache"))
29 group.add_option("-c", "--config", dest="conffile",
30 - default='/etc/yum/yum.conf',
32 help=_("config file location"), metavar='[config file]')
33 group.add_option("-R", "--randomwait", dest="sleeptime", type='int',
35 diff -ur yum-3.2.28.orig/yum/config.py yum-3.2.28/yum/config.py
36 --- yum-3.2.28.orig/yum/config.py 2010-10-18 13:59:40.165820228 -0400
37 +++ yum-3.2.28/yum/config.py 2010-10-18 14:05:51.919642477 -0400
39 syslog_facility = Option('LOG_USER')
40 syslog_device = Option('/dev/log')
41 persistdir = Option('/var/lib/yum')
44 + def getRootedPath(self, path, enforce_default=False, defaults_to_host=False):
45 + instroot = self.installroot
46 + if instroot is None:
49 + if path.startswith('hostfs://'): res = path[9:]
50 + elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:]
52 + tmp = instroot + '/' + path
55 + if defaults_to_host: res = path
58 + if os.path.exists(tmp): res = tmp
59 + elif defaults_to_host: res = path
64 class YumConf(StartupConf):
66 Configuration option definitions for yum.conf\'s [main] section.
69 keepcache = BoolOption(True)
70 logfile = Option('/var/log/yum.log')
71 + lockfile = Option('/var/run/yum.pid')
72 reposdir = ListOption(['/etc/yum/repos.d', '/etc/yum.repos.d'])
74 commands = ListOption()
76 # Apply the installroot to directory options
77 def _apply_installroot(yumconf, option):
78 path = getattr(yumconf, option)
79 - ir_path = yumconf.installroot + path
80 + ir_path = yumconf.getRootedPath(path)
81 ir_path = ir_path.replace('//', '/') # os.path.normpath won't fix this and
83 ir_path = varReplace(ir_path, yumvars)
87 # These can use the above FS yumvars
88 - for option in ('cachedir', 'logfile', 'persistdir'):
89 + for option in ('cachedir', 'logfile', 'lockfile', 'persistdir'):
90 _apply_installroot(yumconf, option)
92 # Add in some extra attributes which aren't actually configuration values
93 diff -ur yum-3.2.28.orig/yum/__init__.py yum-3.2.28/yum/__init__.py
94 --- yum-3.2.28.orig/yum/__init__.py 2010-10-18 13:59:40.173818661 -0400
95 +++ yum-3.2.28/yum/__init__.py 2010-10-18 14:05:51.920642052 -0400
97 # this check makes sure that our dirs exist properly.
98 # if they aren't in the installroot then don't prepend the installroot path
99 # if we don't do this then anaconda likes to not work.
100 - if os.path.exists(self.conf.installroot+'/'+reposdir):
101 - reposdir = self.conf.installroot + '/' + reposdir
102 + reposdir = self.conf.getRootedPath(reposdir)
104 if os.path.isdir(reposdir):
105 for repofn in sorted(glob.glob('%s/*.repo' % reposdir)):
106 @@ -1585,10 +1584,8 @@
107 if self.conf.uid != 0:
110 - root = self.conf.installroot
111 - lockfile = root + '/' + lockfile # lock in the chroot
112 - lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra /
114 + lockfile = self.conf.lockfile
116 mypid=str(os.getpid())
117 while not self._lock(lockfile, mypid, 0644):