1 diff -Nurp yum-3.2.22.orig/cli.py yum-3.2.22/cli.py
2 --- yum-3.2.22.orig/cli.py 2009-11-05 23:13:23.000000000 +0100
3 +++ yum-3.2.22/cli.py 2009-11-05 23:21:50.000000000 +0100
4 @@ -1259,13 +1259,14 @@ class YumOptionParser(OptionParser):
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'
16 - if os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
17 - opts.conffile = opts.installroot+'/'+opts.conffile
18 - elif opts.conffile == '/etc/yum/yum.conf':
19 - # check if /installroot/etc/yum.conf exists.
20 - if os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
21 - opts.conffile = opts.installroot+'/etc/yum.conf'
25 @@ -1304,7 +1305,7 @@ class YumOptionParser(OptionParser):
26 help=_("be tolerant of errors"))
27 group.add_option("-C", dest="cacheonly", action="store_true",
28 help=_("run entirely from cache, don't update cache"))
29 - group.add_option("-c", dest="conffile", default='/etc/yum/yum.conf',
30 + group.add_option("-c", dest="conffile", default=None,
31 help=_("config file location"), metavar=' [config file]')
32 group.add_option("-R", dest="sleeptime", type='int', default=None,
33 help=_("maximum command wait time"), metavar=' [minutes]')
34 diff -Nurp yum-3.2.22.orig/yum/config.py yum-3.2.22/yum/config.py
35 --- yum-3.2.22.orig/yum/config.py 2009-11-05 23:13:23.000000000 +0100
36 +++ yum-3.2.22/yum/config.py 2009-11-06 00:21:39.000000000 +0100
37 @@ -588,6 +588,26 @@ class StartupConf(BaseConfig):
38 syslog_ident = Option()
39 syslog_facility = Option('LOG_DAEMON')
41 + def getRootedPath(self, path, enforce_default=False, defaults_to_host=False):
42 + instroot = self.installroot
43 + if instroot is None:
46 + if path.startswith('hostfs://'): res = path[9:]
47 + elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:]
49 + tmp = instroot + '/' + path
52 + if defaults_to_host: res = path
55 + if os.path.exists(tmp): res = tmp
56 + elif defaults_to_host: res = path
61 class YumConf(StartupConf):
63 Configuration option definitions for yum.conf\'s [main] section.
64 @@ -601,6 +621,7 @@ class YumConf(StartupConf):
65 persistdir = Option('/var/lib/yum')
66 keepcache = BoolOption(True)
67 logfile = Option('/var/log/yum.log')
68 + lockfile = Option('/var/run/yum.pid')
69 reposdir = ListOption(['/etc/yum/repos.d', '/etc/yum.repos.d'])
72 @@ -808,9 +829,9 @@ def readMainConfig(startupconf):
73 yumconf.populate(startupconf._parser, 'main')
75 # Apply the installroot to directory options
76 - for option in ('cachedir', 'logfile', 'persistdir'):
77 + for option in ('cachedir', 'logfile', 'lockfile', 'persistdir'):
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 setattr(yumconf, option, ir_path)
84 diff -Nurp yum-3.2.22.orig/yum/__init__.py yum-3.2.22/yum/__init__.py
85 --- yum-3.2.22.orig/yum/__init__.py 2009-11-05 23:13:23.000000000 +0100
86 +++ yum-3.2.22/yum/__init__.py 2009-11-06 00:23:19.000000000 +0100
87 @@ -341,8 +341,7 @@ class YumBase(depsolve.Depsolve):
88 # this check makes sure that our dirs exist properly.
89 # if they aren't in the installroot then don't prepent the installroot path
90 # if we don't do this then anaconda likes to not work.
91 - if os.path.exists(self.conf.installroot+'/'+reposdir):
92 - reposdir = self.conf.installroot + '/' + reposdir
93 + reposdir = self.conf.getRootedPath(reposdir)
95 if os.path.isdir(reposdir):
96 for repofn in sorted(glob.glob('%s/*.repo' % reposdir)):
97 @@ -1128,8 +1127,7 @@ class YumBase(depsolve.Depsolve):
100 root = self.conf.installroot
101 - lockfile = root + '/' + lockfile # lock in the chroot
102 - lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra /
103 + lockfile = self.conf.lockfile
105 mypid=str(os.getpid())
106 while not self._lock(lockfile, mypid, 0644):