X-Git-Url: http://git.onelab.eu/?p=yum.git;a=blobdiff_plain;f=yum-3.2.27_el6-chroot.patch;fp=yum-3.2.27_el6-chroot.patch;h=453b3600d1c053b5c458804ad0c51fa8de662456;hp=0000000000000000000000000000000000000000;hb=00863dd7161950b7a8f505e37532a3798e1412d5;hpb=6dc5ff5e68236024ee4d9cad5a621e0612f3c4d1;ds=sidebyside diff --git a/yum-3.2.27_el6-chroot.patch b/yum-3.2.27_el6-chroot.patch new file mode 100644 index 0000000..453b360 --- /dev/null +++ b/yum-3.2.27_el6-chroot.patch @@ -0,0 +1,223 @@ +Patch for yum-3.2.27-14.el6_0.1 + +diff --git a/cli.py b/cli.py +index cebbae3..cdb0129 100644 +--- a/cli.py ++++ b/cli.py +@@ -1347,13 +1347,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 = '/' +@@ -1394,7 +1395,6 @@ class YumOptionParser(OptionParser): + action="store_true", + help=_("run entirely from system cache, don't update cache")) + group.add_option("-c", "--config", dest="conffile", +- default='/etc/yum/yum.conf', + help=_("config file location"), metavar='[config file]') + group.add_option("-R", "--randomwait", dest="sleeptime", type='int', + default=None, +diff --git a/yum/__init__.py b/yum/__init__.py +index 978815d..916c8d6 100644 +--- a/yum/__init__.py ++++ b/yum/__init__.py +@@ -399,8 +399,7 @@ class YumBase(depsolve.Depsolve): + # this check makes sure that our dirs exist properly. + # if they aren't in the installroot then don't prepend the installroot path + # if we don't do this then anaconda likes to not work. +- 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 sorted(glob.glob('%s/*.repo' % reposdir)): +@@ -1379,9 +1378,7 @@ class YumBase(depsolve.Depsolve): + 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): +diff --git a/yum/config.py b/yum/config.py +index 975172a..603aacc 100644 +--- a/yum/config.py ++++ b/yum/config.py +@@ -604,6 +604,26 @@ class StartupConf(BaseConfig): + syslog_facility = Option('LOG_DAEMON') + persistdir = Option('/var/lib/yum') + ++ 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. +@@ -617,6 +637,7 @@ class YumConf(StartupConf): + + 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() +@@ -832,7 +853,10 @@ def readStartupConfig(configfile, root): + # Stuff this here to avoid later re-parsing + startupconf._parser = parser + # setup the release ver here +- startupconf.releasever = _getsysver(startupconf.installroot, startupconf.distroverpkg) ++ try: ++ startupconf.releasever = _getsysver(startupconf.installroot, startupconf.distroverpkg) ++ except: ++ startupconf.releasever = "" + uuidfile = '%s/%s/uuid' % (startupconf.installroot, startupconf.persistdir) + startupconf.uuid = get_uuid(uuidfile) + +@@ -864,7 +888,7 @@ def readMainConfig(startupconf): + # Apply the installroot to directory options + def _apply_installroot(yumconf, option): + path = getattr(yumconf, option) +- ir_path = yumconf.installroot + path ++ ir_path = yumconf.getRootedPath(path) + ir_path = ir_path.replace('//', '/') # os.path.normpath won't fix this and + # it annoys me + ir_path = varReplace(ir_path, yumvars) +@@ -888,7 +912,7 @@ def readMainConfig(startupconf): + yumvars[fsvar] = val + + # These can use the above FS yumvars +- for option in ('cachedir', 'logfile', 'persistdir'): ++ for option in ('cachedir', 'logfile', 'persistdir', 'lockfile'): + _apply_installroot(yumconf, option) + + # Add in some extra attributes which aren't actually configuration values +diff --git a/yum/history.py b/yum/history.py +index 32eed2c..64b6695 100644 +--- a/yum/history.py ++++ b/yum/history.py +@@ -176,10 +176,7 @@ class YumHistory: + self._conn = None + + self.conf = yum.misc.GenericHolder() +- if not os.path.normpath(db_path).startswith(root): +- self.conf.db_path = os.path.normpath(root + '/' + db_path) +- else: +- self.conf.db_path = os.path.normpath('/' + db_path) ++ self.conf.db_path = db_path + self.conf.writable = False + self.conf.readable = True + +diff --git a/yum/rpmsack.py b/yum/rpmsack.py +index 878e8d4..1938f1a 100644 +--- a/yum/rpmsack.py ++++ b/yum/rpmsack.py +@@ -151,13 +151,8 @@ class RPMDBPackageSack(PackageSackBase): + self._get_pro_cache = {} + self._get_req_cache = {} + self._loaded_gpg_keys = False +- if cachedir is None: +- cachedir = persistdir + "/rpmdb-indexes" +- self.setCacheDir(cachedir) +- if not os.path.normpath(persistdir).startswith(self.root): +- self._persistdir = root + '/' + persistdir +- else: +- self._persistdir = persistdir ++ self._cachedir = persistdir + "/rpmdb-indexes" ++ self._persistdir = persistdir + self._have_cached_rpmdbv_data = None + self._cached_conflicts_data = None + # Store the result of what happens, if a transaction completes. +@@ -217,14 +212,6 @@ class RPMDBPackageSack(PackageSackBase): + self.transactionReset() # Should do nothing, but meh... + self._cached_rpmdb_mtime = None + +- def setCacheDir(self, cachedir): +- """ Sets the internal cachedir value for the rpmdb, to be the +- "rpmdb-indexes" directory in the persisent yum storage. """ +- if not os.path.normpath(cachedir).startswith(self.root): +- self._cachedir = self.root + '/' + cachedir +- else: +- self._cachedir = '/' + cachedir +- + def readOnlyTS(self): + if not self.ts: + self.ts = initReadOnlyTransaction(root=self.root) +@@ -861,7 +848,7 @@ class RPMDBPackageSack(PackageSackBase): + # http://lists.rpm.org/pipermail/rpm-maint/2007-November/001719.html + # ...if anything gets implemented, we should change. + rpmdbvfname = self._cachedir + "/version" +- rpmdbfname = self.root + "/var/lib/rpm/Packages" ++ rpmdbfname = self.root + rpm.expandMacro("%_dbpath/Packages") + + if os.path.exists(rpmdbvfname) and os.path.exists(rpmdbfname): + # See if rpmdb has "changed" ... +@@ -881,7 +868,7 @@ class RPMDBPackageSack(PackageSackBase): + if self._cached_rpmdb_mtime is None: + return # We haven't loaded any packages!!! + +- rpmdbfname = self.root + "/var/lib/rpm/Packages" ++ rpmdbfname = self.root + rpm.expandMacro("%_dbpath/Packages") + if not os.path.exists(rpmdbfname): + return # haha + +@@ -1104,7 +1091,7 @@ class RPMDBPackageSack(PackageSackBase): + self._name2pkg.setdefault(po.name, []).append(po) + self._tup2pkg[po.pkgtup] = po + if self.__cache_rpmdb__ and self._cached_rpmdb_mtime is None: +- rpmdbfname = self.root + "/var/lib/rpm/Packages" ++ rpmdbfname = self.root + rpm.expandMacro("%_dbpath/Packages") + self._cached_rpmdb_mtime = os.path.getmtime(rpmdbfname) + + return po +diff --git a/yum/rpmtrans.py b/yum/rpmtrans.py +index 0340153..a544b9c 100644 +--- a/yum/rpmtrans.py ++++ b/yum/rpmtrans.py +@@ -243,7 +243,10 @@ class RPMTransaction: + def _scriptout(self, data): + msgs = self._scriptOutput() + self.display.scriptout(data, msgs) +- self.base.history.log_scriptlet_output(data, msgs) ++ try: ++ self.base.history.log_scriptlet_output(data, msgs) ++ except: ++ self.display.errorlog('could not log scriptlet output') + + def __del__(self): + self._shutdownOutputLogging()