Hi Thomas, Thomas Goirand wrote: > Hi, > > When I try to apply your patch that was made for 3.2.12 in the current > 3.2.21, it just fails: > [...]
> Would you be able to provide a patch against version 3.2.21? yup, patch in dpatch format attached. > Is there one that exists already somewhere? > The last one in the debian's version of util-vserver is against yum 3.2.4. I didn't check upstream trunk, but it was trivial to forward-port anyway. > Also, why this has not been applied > in the upstream version, if this is a so old issue? I can only guess here: The issue the patch addresses, is that the yum caller can specify 'cachedir', 'persistdir' and 'logfile', but not where the 'lockfile' should go. yum alway prepends installroot to all of these, which, in the case of an externalized yum database, is certainly incorrect for at least some. However, the patch solves this by introducing a new interface for all these config parameters: the ability to prepend 'hostfs://' and 'chrootfs://' to all these config parameters. Yum upstream might have problems accepting this new interface, or they do not agree with the use case of externalized package databases at all. Maybe you can confirm this analysis with yum upstream. > Also, my plan was to have the current 3.2.21-1 debian release reach > lenny proposed-updates in order to fix the current breakage. Would you > feel acceptable to wait for this to happen before we fix this issue? Yeah, sure, it's a wish list bug after all. > We could work on a version to be sent to Experimental if you wish. no hurry from my side, I'll keep my old package on my servers for the time being. Ciao, Philipp
#! /bin/sh /usr/share/dpatch/dpatch-run ## 0004_Vserver_interface.dpatch by Philipp Kaluza <[email protected]> ## ## All lines beginning with `## DP:' are a description of the patch. ## DP: This adds more fine control for setting up vservers @DPATCH@ diff -urNad yum-3.2.21~/cli.py yum-3.2.21/cli.py --- yum-3.2.21~/cli.py 2009-01-06 15:46:00.000000000 +0100 +++ yum-3.2.21/cli.py 2009-04-01 13:34:22.168245119 +0200 @@ -1176,13 +1176,14 @@ 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 = '/' @@ -1216,7 +1217,7 @@ 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 -urNad yum-3.2.21~/docs/yum.conf.5 yum-3.2.21/docs/yum.conf.5 --- yum-3.2.21~/docs/yum.conf.5 2008-12-08 16:37:25.000000000 +0100 +++ yum-3.2.21/docs/yum.conf.5 2009-04-01 13:34:22.168245119 +0200 @@ -23,8 +23,10 @@ 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 @@ 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 @@ 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 -urNad yum-3.2.21~/yum/__init__.py yum-3.2.21/yum/__init__.py --- yum-3.2.21~/yum/__init__.py 2009-01-07 21:33:14.000000000 +0100 +++ yum-3.2.21/yum/__init__.py 2009-04-01 13:34:22.168245119 +0200 @@ -289,8 +289,7 @@ 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): @@ -1045,11 +1044,9 @@ # 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') @@ -1084,8 +1081,7 @@ return if lockfile is not None: - root = self.conf.installroot - lockfile = root + '/' + lockfile # lock in the chroot + root = self.conf.lockfile elif self._lockfile is None: return # Don't delete other people's lock files on __del__ else: diff -urNad yum-3.2.21~/yum/config.py yum-3.2.21/yum/config.py --- yum-3.2.21~/yum/config.py 2009-04-01 13:34:22.012244915 +0200 +++ yum-3.2.21/yum/config.py 2009-04-01 13:34:22.168245119 +0200 @@ -588,6 +588,26 @@ syslog_ident = Option() syslog_facility = Option('LOG_DAEMON') + def getRootedPath(self, path, enforce_default=False, defaults_to_host=False): + 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 +621,7 @@ 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() @@ -776,9 +797,9 @@ 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) - setattr(yumconf, option, yumconf.installroot + path) + setattr(yumconf, option, yumconf.getRootedPath(path)) # Add in some extra attributes which aren't actually configuration values yumconf.yumvar = yumvars

