1 diff -Nurp yum-3.2.19.orig/cli.py yum-3.2.19/cli.py
2 --- yum-3.2.19.orig/cli.py 2008-08-19 21:31:11.000000000 +0200
3 +++ yum-3.2.19/cli.py 2008-09-29 02:50:02.000000000 +0200
4 @@ -1099,13 +1099,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==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 @@ -1139,7 +1140,7 @@ class YumOptionParser(OptionParser):
26 help=_("be tolerant of errors"))
27 self.add_option("-C", dest="cacheonly", action="store_true",
28 help=_("run entirely from cache, don't update cache"))
29 - self.add_option("-c", dest="conffile", default='/etc/yum/yum.conf',
30 + self.add_option("-c", dest="conffile", default=None,
31 help=_("config file location"), metavar=' [config file]')
32 self.add_option("-R", dest="sleeptime", type='int', default=None,
33 help=_("maximum command wait time"), metavar=' [minutes]')
34 diff -Nurp yum-3.2.19.orig/docs/yum.conf.5 yum-3.2.19/docs/yum.conf.5
35 --- yum-3.2.19.orig/docs/yum.conf.5 2008-08-06 19:39:50.000000000 +0200
36 +++ yum-3.2.19/docs/yum.conf.5 2008-09-29 02:50:02.000000000 +0200
37 @@ -23,8 +23,10 @@ The [main] section must exist for yum to
41 -Directory where yum should store its cache and db files. The default is
43 +Directory where yum should store its cache and db files. The default
44 +is `/var/cache/yum'. Unless the prefixes `hostfs://' or `chrootfs://'
45 +are used, some magic will be applied to determine the real path in
46 +combination with `--installroot'.
49 Directory where yum should store information that should persist over multiple
50 @@ -44,6 +46,10 @@ documented in \fB[repository] options\fR
51 repositories defined in /etc/yum/yum.conf to form the complete set of
52 repositories that yum will use.
54 +Unless the prefixes `hostfs://' or `chrootfs://' are used, some magic
55 +will be applied to determine the real path in combination with
59 Debug message output level. Practical range is 0\-10. Default is `2'.
61 @@ -51,7 +57,10 @@ Debug message output level. Practical ra
62 Error message output level. Practical range is 0\-10. Default is `2'.
65 -Full directory and file name for where yum should write its log file.
66 +Full directory and file name for where yum should write its log
67 +file. Unless the prefixes `hostfs://' or `chrootfs://' are used,
68 +some magic will be applied to determine the real path in combination
69 +with `--installroot'.
72 Either `1' or `0'. This tells yum whether or not it should perform a GPG
73 diff -Nurp yum-3.2.19.orig/yum/config.py yum-3.2.19/yum/config.py
74 --- yum-3.2.19.orig/yum/config.py 2008-08-19 21:31:11.000000000 +0200
75 +++ yum-3.2.19/yum/config.py 2008-09-29 03:14:07.000000000 +0200
76 @@ -588,6 +588,26 @@ class StartupConf(BaseConfig):
77 syslog_ident = Option()
78 syslog_facility = Option('LOG_DAEMON')
80 + def getRootedPath(self, path, enforce_default=False, defaults_to_host=False):
81 + instroot = getattr(self, 'installroot', None)
85 + if path.startswith('hostfs://'): res = path[9:]
86 + elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:]
88 + tmp = instroot + '/' + path
91 + if defaults_to_host: res = path
94 + if os.path.exists(tmp): res = tmp
95 + elif defaults_to_host: res = path
100 class YumConf(StartupConf):
102 Configuration option definitions for yum.conf\'s [main] section.
103 @@ -601,6 +621,7 @@ class YumConf(StartupConf):
104 persistdir = Option('/var/lib/yum')
105 keepcache = BoolOption(True)
106 logfile = Option('/var/log/yum.log')
107 + lockfile = Option('/var/run/yum.pid')
108 reposdir = ListOption(['/etc/yum/repos.d', '/etc/yum.repos.d'])
110 commands = ListOption()
111 @@ -757,9 +778,9 @@ def readMainConfig(startupconf):
112 yumconf.populate(startupconf._parser, 'main')
114 # Apply the installroot to directory options
115 - for option in ('cachedir', 'logfile', 'persistdir'):
116 + for option in ('cachedir', 'logfile', 'lockfile'):
117 path = getattr(yumconf, option)
118 - setattr(yumconf, option, yumconf.installroot + path)
119 + setattr(yumconf, option, yumconf.getRootedPath(path))
121 # Add in some extra attributes which aren't actually configuration values
122 yumconf.yumvar = yumvars
123 diff -Nurp yum-3.2.19.orig/yum/__init__.py yum-3.2.19/yum/__init__.py
124 --- yum-3.2.19.orig/yum/__init__.py 2008-08-26 21:37:17.000000000 +0200
125 +++ yum-3.2.19/yum/__init__.py 2008-09-29 02:50:02.000000000 +0200
126 @@ -288,8 +288,7 @@ class YumBase(depsolve.Depsolve):
127 self.getReposFromConfigFile(self.conf.config_file_path, repo_config_age)
129 for reposdir in self.conf.reposdir:
130 - if os.path.exists(self.conf.installroot+'/'+reposdir):
131 - reposdir = self.conf.installroot + '/' + reposdir
132 + reposdir = self.conf.getRootedPath(reposdir)
134 if os.path.isdir(reposdir):
135 for repofn in glob.glob('%s/*.repo' % reposdir):
136 @@ -933,11 +932,9 @@ class YumBase(depsolve.Depsolve):
137 # if we're not root then we don't lock - just return nicely
138 if self.conf.uid != 0:
141 - root = self.conf.installroot
142 - lockfile = root + '/' + lockfile # lock in the chroot
143 - lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra /
146 + lockfile = self.conf.lockfile
148 mypid=str(os.getpid())
149 while not self._lock(lockfile, mypid, 0644):
150 fd = open(lockfile, 'r')
151 diff -Nurp yum-3.2.19.orig/yum/rpmtrans.py yum-3.2.19/yum/rpmtrans.py
152 --- yum-3.2.19.orig/yum/rpmtrans.py 2008-08-26 21:40:17.000000000 +0200
153 +++ yum-3.2.19/yum/rpmtrans.py 2008-09-29 03:14:14.000000000 +0200
154 @@ -227,7 +227,8 @@ class RPMTransaction:
156 if not hasattr(self, '_ts_done'):
157 # need config variable to put this in a better path/name
158 - te_fn = '%s/transaction-done.%s' % (self.base.conf.persistdir, self._ts_time)
159 + te_fn = '%s/transaction-done.%s' % (
160 + self.base.conf.getRootedPath(self.base.conf.persistdir), self._ts_time)
161 self.ts_done_fn = te_fn
163 self._ts_done = open(te_fn, 'w')