--- /dev/null
+diff -Nurp yum-3.2.19.orig/cli.py yum-3.2.19/cli.py
+--- yum-3.2.19.orig/cli.py 2008-08-19 21:31:11.000000000 +0200
++++ yum-3.2.19/cli.py 2008-09-29 02:50:02.000000000 +0200
+@@ -1099,13 +1099,14 @@ class YumOptionParser(OptionParser):
+ def getRoot(self,opts):
+ # If the conf file is inside the installroot - use that.
+ # otherwise look for it in the normal root
++ if opts.conffile==None:
++ opts.conffile = '/etc/yum/yum.conf'
++ if opts.installroot:
++ if os.access(opts.installroot+opts.conffile, os.R_OK):
++ opts.conffile = opts.installroot+opts.conffile
++ elif os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
++ opts.conffile = opts.installroot+'/etc/yum.conf'
+ if opts.installroot:
+- if os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
+- opts.conffile = opts.installroot+'/'+opts.conffile
+- elif opts.conffile == '/etc/yum/yum.conf':
+- # check if /installroot/etc/yum.conf exists.
+- if os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
+- opts.conffile = opts.installroot+'/etc/yum.conf'
+ root=opts.installroot
+ else:
+ root = '/'
+@@ -1139,7 +1140,7 @@ class YumOptionParser(OptionParser):
+ help=_("be tolerant of errors"))
+ self.add_option("-C", dest="cacheonly", action="store_true",
+ help=_("run entirely from cache, don't update cache"))
+- self.add_option("-c", dest="conffile", default='/etc/yum/yum.conf',
++ self.add_option("-c", dest="conffile", default=None,
+ help=_("config file location"), metavar=' [config file]')
+ self.add_option("-R", dest="sleeptime", type='int', default=None,
+ help=_("maximum command wait time"), metavar=' [minutes]')
+diff -Nurp yum-3.2.19.orig/docs/yum.conf.5 yum-3.2.19/docs/yum.conf.5
+--- yum-3.2.19.orig/docs/yum.conf.5 2008-08-06 19:39:50.000000000 +0200
++++ yum-3.2.19/docs/yum.conf.5 2008-09-29 02:50:02.000000000 +0200
+@@ -23,8 +23,10 @@ The [main] section must exist for yum to
+ following options:
+
+ .IP \fBcachedir\fR
+-Directory where yum should store its cache and db files. The default is
+-`/var/cache/yum'.
++Directory where yum should store its cache and db files. The default
++is `/var/cache/yum'. Unless the prefixes `hostfs://' or `chrootfs://'
++are used, some magic will be applied to determine the real path in
++combination with `--installroot'.
+
+ .IP \fBpersistdir\fR
+ Directory where yum should store information that should persist over multiple
+@@ -44,6 +46,10 @@ documented in \fB[repository] options\fR
+ repositories defined in /etc/yum/yum.conf to form the complete set of
+ repositories that yum will use.
+
++Unless the prefixes `hostfs://' or `chrootfs://' are used, some magic
++will be applied to determine the real path in combination with
++`--installroot'.
++
+ .IP \fBdebuglevel\fR
+ Debug message output level. Practical range is 0\-10. Default is `2'.
+
+@@ -51,7 +57,10 @@ Debug message output level. Practical ra
+ Error message output level. Practical range is 0\-10. Default is `2'.
+
+ .IP \fBlogfile\fR
+-Full directory and file name for where yum should write its log file.
++Full directory and file name for where yum should write its log
++file. Unless the prefixes `hostfs://' or `chrootfs://' are used,
++some magic will be applied to determine the real path in combination
++with `--installroot'.
+
+ .IP \fBgpgcheck\fR
+ Either `1' or `0'. This tells yum whether or not it should perform a GPG
+diff -Nurp yum-3.2.19.orig/yum/config.py yum-3.2.19/yum/config.py
+--- yum-3.2.19.orig/yum/config.py 2008-08-19 21:31:11.000000000 +0200
++++ yum-3.2.19/yum/config.py 2008-09-29 02:50:49.000000000 +0200
+@@ -588,6 +588,27 @@ class StartupConf(BaseConfig):
+ syslog_ident = Option()
+ syslog_facility = Option('LOG_DAEMON')
+
++ def getRootedPath(self, option, enforce_default=False, defaults_to_host=False):
++ path = getattr(self, option)
++ instroot = getattr(self, 'installroot', None)
++ if instroot==None:
++ return path
++
++ if path.startswith('hostfs://'): res = path[9:]
++ elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:]
++ else:
++ tmp = instroot + '/' + path
++
++ if enforce_default:
++ if defaults_to_host: res = path
++ else: res = tmp
++ else:
++ if os.path.exists(tmp): res = tmp
++ elif defaults_to_host: res = path
++ else: res = tmp
++
++ return res
++
+ class YumConf(StartupConf):
+ '''
+ Configuration option definitions for yum.conf\'s [main] section.
+@@ -601,6 +622,7 @@ class YumConf(StartupConf):
+ persistdir = Option('/var/lib/yum')
+ keepcache = BoolOption(True)
+ logfile = Option('/var/log/yum.log')
++ lockfile = Option('/var/run/yum.pid')
+ reposdir = ListOption(['/etc/yum/repos.d', '/etc/yum.repos.d'])
+
+ commands = ListOption()
+@@ -757,9 +779,8 @@ def readMainConfig(startupconf):
+ yumconf.populate(startupconf._parser, 'main')
+
+ # Apply the installroot to directory options
+- for option in ('cachedir', 'logfile', 'persistdir'):
+- path = getattr(yumconf, option)
+- setattr(yumconf, option, yumconf.installroot + path)
++ for option in ('cachedir', 'logfile', 'lockfile'):
++ setattr(yumconf, option, yumconf.getRootedPath(option))
+
+ # Add in some extra attributes which aren't actually configuration values
+ yumconf.yumvar = yumvars
+diff -Nurp yum-3.2.19.orig/yum/__init__.py yum-3.2.19/yum/__init__.py
+--- yum-3.2.19.orig/yum/__init__.py 2008-08-26 21:37:17.000000000 +0200
++++ yum-3.2.19/yum/__init__.py 2008-09-29 02:50:02.000000000 +0200
+@@ -288,8 +288,7 @@ class YumBase(depsolve.Depsolve):
+ self.getReposFromConfigFile(self.conf.config_file_path, repo_config_age)
+
+ for reposdir in self.conf.reposdir:
+- if os.path.exists(self.conf.installroot+'/'+reposdir):
+- reposdir = self.conf.installroot + '/' + reposdir
++ reposdir = self.conf.getRootedPath(reposdir)
+
+ if os.path.isdir(reposdir):
+ for repofn in glob.glob('%s/*.repo' % reposdir):
+@@ -933,11 +932,9 @@ class YumBase(depsolve.Depsolve):
+ # if we're not root then we don't lock - just return nicely
+ if self.conf.uid != 0:
+ return
+-
+- root = self.conf.installroot
+- lockfile = root + '/' + lockfile # lock in the chroot
+- lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra /
+-
++
++ lockfile = self.conf.lockfile
++
+ mypid=str(os.getpid())
+ while not self._lock(lockfile, mypid, 0644):
+ fd = open(lockfile, 'r')
+diff -Nurp yum-3.2.19.orig/yum/rpmtrans.py yum-3.2.19/yum/rpmtrans.py
+--- yum-3.2.19.orig/yum/rpmtrans.py 2008-08-26 21:40:17.000000000 +0200
++++ yum-3.2.19/yum/rpmtrans.py 2008-09-29 02:50:21.000000000 +0200
+@@ -227,7 +227,7 @@ class RPMTransaction:
+
+ if not hasattr(self, '_ts_done'):
+ # need config variable to put this in a better path/name
+- te_fn = '%s/transaction-done.%s' % (self.base.conf.persistdir, self._ts_time)
++ te_fn = '%s/transaction-done.%s' % (self.base.conf.getRootedPath('persistdir'), self._ts_time)
+ self.ts_done_fn = te_fn
+ try:
+ self._ts_done = open(te_fn, 'w')
---- yum-3.2.4/yum/__init__.py.chroot
-+++ yum-3.2.4/yum/__init__.py
-@@ -214,8 +214,7 @@ class YumBase(depsolve.Depsolve):
- repo_config_age = self.conf.config_file_age
-
- for reposdir in self.conf.reposdir:
-- if os.path.exists(self.conf.installroot+'/'+reposdir):
-- reposdir = self.conf.installroot + '/' + reposdir
-+ reposdir = self.conf.getRootedPath(reposdir)
+diff -Nurp yum-3.2.4.orig/cli.py yum-3.2.4/cli.py
+--- yum-3.2.4.orig/cli.py 2007-08-15 17:48:03.000000000 +0200
++++ yum-3.2.4/cli.py 2008-09-29 02:32:24.000000000 +0200
+@@ -1204,13 +1204,14 @@ class YumOptionParser(OptionParser):
+ def getRoot(self,opts):
+ # If the conf file is inside the installroot - use that.
+ # otherwise look for it in the normal root
++ if opts.conffile==None:
++ opts.conffile = '/etc/yum/yum.conf'
++ if opts.installroot:
++ if os.access(opts.installroot+opts.conffile, os.R_OK):
++ opts.conffile = opts.installroot+opts.conffile
++ elif os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
++ opts.conffile = opts.installroot+'/etc/yum.conf'
+ if opts.installroot:
+- if os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
+- opts.conffile = opts.installroot+'/'+opts.conffile
+- elif opts.conffile == '/etc/yum/yum.conf':
+- # check if /installroot/etc/yum.conf exists.
+- if os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
+- opts.conffile = opts.installroot+'/etc/yum.conf'
+ root=opts.installroot
+ else:
+ root = '/'
+@@ -1231,7 +1232,7 @@ class YumOptionParser(OptionParser):
+ help="be tolerant of errors")
+ self.add_option("-C", dest="cacheonly", action="store_true",
+ help="run entirely from cache, don't update cache")
+- self.add_option("-c", dest="conffile", default='/etc/yum/yum.conf',
++ self.add_option("-c", dest="conffile", default=None,
+ help="config file location", metavar=' [config file]')
+ self.add_option("-R", dest="sleeptime", type='int', default=None,
+ help="maximum command wait time", metavar=' [minutes]')
+diff -Nurp yum-3.2.4.orig/docs/yum.conf.5 yum-3.2.4/docs/yum.conf.5
+--- yum-3.2.4.orig/docs/yum.conf.5 2007-08-16 14:42:26.000000000 +0200
++++ yum-3.2.4/docs/yum.conf.5 2008-09-29 02:32:24.000000000 +0200
+@@ -23,8 +23,10 @@ The [main] section must exist for yum to
+ following options:
- if os.path.isdir(reposdir):
- for repofn in glob.glob('%s/*.repo' % reposdir):
-@@ -664,11 +663,9 @@ class YumBase(depsolve.Depsolve):
- # if we're not root then we don't lock - just return nicely
- if self.conf.uid != 0:
- return
--
-- root = self.conf.installroot
-- lockfile = root + '/' + lockfile # lock in the chroot
-- lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra /
--
-+
-+ lockfile = self.conf.lockfile
-+
- mypid=str(os.getpid())
- while not self._lock(lockfile, mypid, 0644):
- fd = open(lockfile, 'r')
-@@ -700,9 +697,8 @@ class YumBase(depsolve.Depsolve):
- if self.conf.uid != 0:
- return
-
-- root = self.conf.installroot
-- lockfile = root + '/' + lockfile # lock in the chroot
--
-+ lockfile=self.conf.lockfile
+ .IP \fBcachedir\fR
+-Directory where yum should store its cache and db files. The default is
+-`/var/cache/yum'.
++Directory where yum should store its cache and db files. The default
++is `/var/cache/yum'. Unless the prefixes `hostfs://' or `chrootfs://'
++are used, some magic will be applied to determine the real path in
++combination with `--installroot'.
+
+ .IP \fBpersistdir\fR
+ Directory where yum should store information that should persist over multiple
+@@ -44,6 +46,10 @@ documented in \fB[repository] options\fR
+ repositories defined in /etc/yum/yum.conf to form the complete set of
+ repositories that yum will use.
+
++Unless the prefixes `hostfs://' or `chrootfs://' are used, some magic
++will be applied to determine the real path in combination with
++`--installroot'.
+
- self._unlock(lockfile)
-
- def _lock(self, filename, contents='', mode=0777):
---- yum-3.2.4/yum/config.py.chroot
-+++ yum-3.2.4/yum/config.py
-@@ -469,6 +469,26 @@ class StartupConf(BaseConfig):
+ .IP \fBdebuglevel\fR
+ Debug message output level. Practical range is 0\-10. Default is `2'.
+
+@@ -51,7 +57,10 @@ Debug message output level. Practical ra
+ Error message output level. Practical range is 0\-10. Default is `2'.
+
+ .IP \fBlogfile\fR
+-Full directory and file name for where yum should write its log file.
++Full directory and file name for where yum should write its log
++file. Unless the prefixes `hostfs://' or `chrootfs://' are used,
++some magic will be applied to determine the real path in combination
++with `--installroot'.
+
+ .IP \fBgpgcheck\fR
+ Either `1' or `0'. This tells yum whether or not it should perform a GPG
+diff -Nurp yum-3.2.4.orig/yum/config.py yum-3.2.4/yum/config.py
+--- yum-3.2.4.orig/yum/config.py 2007-08-28 19:38:39.000000000 +0200
++++ yum-3.2.4/yum/config.py 2008-09-29 02:49:04.000000000 +0200
+@@ -469,6 +469,27 @@ class StartupConf(BaseConfig):
pluginpath = ListOption(['/usr/share/yum-plugins', '/usr/lib/yum-plugins'])
pluginconfpath = ListOption(['/etc/yum/pluginconf.d'])
-+ def getRootedPath(self, path, enforce_default=False, defaults_to_host=False):
++ def getRootedPath(self, option, enforce_default=False, defaults_to_host=False):
++ path = getattr(self, option)
+ instroot = getattr(self, 'installroot', None)
+ if instroot==None:
+ return path
class YumConf(StartupConf):
'''
Configuration option definitions for yum.conf\'s [main] section.
-@@ -482,6 +502,7 @@ class YumConf(StartupConf):
+@@ -482,6 +503,7 @@ class YumConf(StartupConf):
persistdir = Option('/var/lib/yum')
keepcache = BoolOption(True)
logfile = Option('/var/log/yum.log')
reposdir = ListOption(['/etc/yum/repos.d', '/etc/yum.repos.d'])
syslog_ident = Option()
syslog_facility = Option('LOG_DAEMON')
-@@ -615,9 +636,9 @@ def readMainConfig(startupconf):
+@@ -615,9 +637,8 @@ def readMainConfig(startupconf):
yumconf.populate(startupconf._parser, 'main')
# Apply the installroot to directory options
- for option in ('cachedir', 'logfile', 'persistdir'):
-+ for option in ('cachedir', 'logfile', 'persistdir', 'lockfile'):
- path = getattr(yumconf, option)
+- path = getattr(yumconf, option)
- setattr(yumconf, option, yumconf.installroot + path)
-+ setattr(yumconf, option, yumconf.getRootedPath(path))
++ for option in ('cachedir', 'logfile', 'lockfile'):
++ setattr(yumconf, option, yumconf.getRootedPath(option))
# Add in some extra attributes which aren't actually configuration values
yumconf.yumvar = yumvars
---- yum-3.2.4/docs/yum.conf.5.chroot
-+++ yum-3.2.4/docs/yum.conf.5
-@@ -23,8 +23,10 @@ The [main] section must exist for yum to
- following options:
-
- .IP \fBcachedir\fR
--Directory where yum should store its cache and db files. The default is
--`/var/cache/yum'.
-+Directory where yum should store its cache and db files. The default
-+is `/var/cache/yum'. Unless the prefixes `hostfs://' or `chrootfs://'
-+are used, some magic will be applied to determine the real path in
-+combination with `--installroot'.
-
- .IP \fBpersistdir\fR
- Directory where yum should store information that should persist over multiple
-@@ -44,6 +46,10 @@ documented in \fB[repository] options\fR
- repositories defined in /etc/yum/yum.conf to form the complete set of
- repositories that yum will use.
+diff -Nurp yum-3.2.4.orig/yum/__init__.py yum-3.2.4/yum/__init__.py
+--- yum-3.2.4.orig/yum/__init__.py 2007-08-28 20:45:13.000000000 +0200
++++ yum-3.2.4/yum/__init__.py 2008-09-29 02:32:24.000000000 +0200
+@@ -214,8 +214,7 @@ class YumBase(depsolve.Depsolve):
+ repo_config_age = self.conf.config_file_age
+
+ for reposdir in self.conf.reposdir:
+- if os.path.exists(self.conf.installroot+'/'+reposdir):
+- reposdir = self.conf.installroot + '/' + reposdir
++ reposdir = self.conf.getRootedPath(reposdir)
-+Unless the prefixes `hostfs://' or `chrootfs://' are used, some magic
-+will be applied to determine the real path in combination with
-+`--installroot'.
+ if os.path.isdir(reposdir):
+ for repofn in glob.glob('%s/*.repo' % reposdir):
+@@ -664,11 +663,9 @@ class YumBase(depsolve.Depsolve):
+ # if we're not root then we don't lock - just return nicely
+ if self.conf.uid != 0:
+ return
+-
+- root = self.conf.installroot
+- lockfile = root + '/' + lockfile # lock in the chroot
+- lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra /
+-
+
- .IP \fBdebuglevel\fR
- Debug message output level. Practical range is 0\-10. Default is `2'.
-
-@@ -51,7 +57,10 @@ Debug message output level. Practical ra
- Error message output level. Practical range is 0\-10. Default is `2'.
-
- .IP \fBlogfile\fR
--Full directory and file name for where yum should write its log file.
-+Full directory and file name for where yum should write its log
-+file. Unless the prefixes `hostfs://' or `chrootfs://' are used,
-+some magic will be applied to determine the real path in combination
-+with `--installroot'.
-
- .IP \fBgpgcheck\fR
- Either `1' or `0'. This tells yum whether or not it should perform a GPG
---- yum-3.2.4/cli.py.chroot
-+++ yum-3.2.4/cli.py
-@@ -1204,13 +1204,14 @@ class YumOptionParser(OptionParser):
- def getRoot(self,opts):
- # If the conf file is inside the installroot - use that.
- # otherwise look for it in the normal root
-+ if opts.conffile==None:
-+ opts.conffile = '/etc/yum/yum.conf'
-+ if opts.installroot:
-+ if os.access(opts.installroot+opts.conffile, os.R_OK):
-+ opts.conffile = opts.installroot+opts.conffile
-+ elif os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
-+ opts.conffile = opts.installroot+'/etc/yum.conf'
- if opts.installroot:
-- if os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
-- opts.conffile = opts.installroot+'/'+opts.conffile
-- elif opts.conffile == '/etc/yum/yum.conf':
-- # check if /installroot/etc/yum.conf exists.
-- if os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
-- opts.conffile = opts.installroot+'/etc/yum.conf'
- root=opts.installroot
- else:
- root = '/'
-@@ -1231,7 +1232,7 @@ class YumOptionParser(OptionParser):
- help="be tolerant of errors")
- self.add_option("-C", dest="cacheonly", action="store_true",
- help="run entirely from cache, don't update cache")
-- self.add_option("-c", dest="conffile", default='/etc/yum/yum.conf',
-+ self.add_option("-c", dest="conffile", default=None,
- help="config file location", metavar=' [config file]')
- self.add_option("-R", dest="sleeptime", type='int', default=None,
- help="maximum command wait time", metavar=' [minutes]')
++ lockfile = self.conf.lockfile
++
+ mypid=str(os.getpid())
+ while not self._lock(lockfile, mypid, 0644):
+ fd = open(lockfile, 'r')
+@@ -700,9 +697,8 @@ class YumBase(depsolve.Depsolve):
+ if self.conf.uid != 0:
+ return
+
+- root = self.conf.installroot
+- lockfile = root + '/' + lockfile # lock in the chroot
+-
++ lockfile=self.conf.lockfile
++
+ self._unlock(lockfile)
+
+ def _lock(self, filename, contents='', mode=0777):
+diff -Nurp yum-3.2.4.orig/yum/rpmtrans.py yum-3.2.4/yum/rpmtrans.py
+--- yum-3.2.4.orig/yum/rpmtrans.py 2007-08-15 19:27:19.000000000 +0200
++++ yum-3.2.4/yum/rpmtrans.py 2008-09-29 02:48:23.000000000 +0200
+@@ -149,7 +149,7 @@ class RPMTransaction:
+
+ if not hasattr(self, '_ts_done'):
+ # need config variable to put this in a better path/name
+- te_fn = '%s/transaction-done.%s' % (self.base.conf.persistdir, self._ts_time)
++ te_fn = '%s/transaction-done.%s' % (self.base.conf.getRootedPath('persistdir'), self._ts_time)
+ self.ts_done_fn = te_fn
+ try:
+ self._ts_done = open(te_fn, 'w')