yum-3.4.3_el70-chroot.patch (9609B)
1 Remove hardcoded '/var/lib/rpm' and use %_dbpath instead of 2 3 Index: yum-3.4.3/yum/rpmsack.py 4 =================================================================== 5 --- yum-3.4.3.orig/yum/rpmsack.py 6 +++ yum-3.4.3/yum/rpmsack.py 7 @@ -228,11 +228,8 @@ class RPMDBPackageSack(PackageSackBase): 8 self._loaded_gpg_keys = False 9 if cachedir is None: 10 cachedir = persistdir + "/rpmdb-indexes" 11 - self.setCacheDir(cachedir) 12 - if not os.path.normpath(persistdir).startswith(self.root): 13 - self._persistdir = root + '/' + persistdir 14 - else: 15 - self._persistdir = persistdir 16 + self._cachedir = cachedir 17 + self._persistdir = persistdir 18 if hasattr(rpm, 'expandMacro'): 19 dbpath = rpm.expandMacro('%_dbpath') 20 else: 21 @@ -396,18 +393,6 @@ class RPMDBPackageSack(PackageSackBase): 22 pkg.yumdb_info._read_cached_data['checksum_type'] = T 23 pkg.yumdb_info._read_cached_data['checksum_data'] = D 24 25 - def setCacheDir(self, cachedir): 26 - """ Sets the internal cachedir value for the rpmdb, to be the 27 - "rpmdb-indexes" directory in the persisent yum storage. """ 28 - if not os.path.normpath(cachedir).startswith(self.root): 29 - self._cachedir = self.root + '/' + cachedir 30 - else: 31 - self._cachedir = '/' + cachedir 32 - 33 - if hasattr(self, 'yumdb'): # Need to keep this up to date, after init. 34 - version_path = os.path.normpath(self._cachedir + '/version') 35 - self.yumdb.conf.version_path = version_path 36 - 37 def readOnlyTS(self): 38 if not self.ts: 39 self.ts = initReadOnlyTransaction(root=self.root) 40 Index: yum-3.4.3/cli.py 41 =================================================================== 42 --- yum-3.4.3.orig/cli.py 43 +++ yum-3.4.3/cli.py 44 @@ -2323,13 +2323,14 @@ class YumOptionParser(OptionParser): 45 self._checkAbsInstallRoot(opts) 46 # If the conf file is inside the installroot - use that. 47 # otherwise look for it in the normal root 48 + if opts.conffile==None: 49 + opts.conffile = '/etc/yum/yum.conf' 50 + if opts.installroot and opts.installroot.lstrip('/'): 51 + if os.access(opts.installroot+opts.conffile, os.R_OK): 52 + opts.conffile = opts.installroot+opts.conffile 53 + elif os.access(opts.installroot+'/etc/yum.conf', os.R_OK): 54 + opts.conffile = opts.installroot+'/etc/yum.conf' 55 if opts.installroot and opts.installroot.lstrip('/'): 56 - if os.access(opts.installroot+'/'+opts.conffile, os.R_OK): 57 - opts.conffile = opts.installroot+'/'+opts.conffile 58 - elif opts.conffile == '/etc/yum/yum.conf': 59 - # check if /installroot/etc/yum.conf exists. 60 - if os.access(opts.installroot+'/etc/yum.conf', os.R_OK): 61 - opts.conffile = opts.installroot+'/etc/yum.conf' 62 root=opts.installroot 63 else: 64 root = '/' 65 @@ -2370,7 +2371,6 @@ class YumOptionParser(OptionParser): 66 action="store_true", 67 help=_("run entirely from system cache, don't update cache")) 68 group.add_option("-c", "--config", dest="conffile", 69 - default='/etc/yum/yum.conf', 70 help=_("config file location"), metavar='[config file]') 71 group.add_option("-R", "--randomwait", dest="sleeptime", type='int', 72 default=None, 73 Index: yum-3.4.3/yum/__init__.py 74 =================================================================== 75 --- yum-3.4.3.orig/yum/__init__.py 76 +++ yum-3.4.3/yum/__init__.py 77 @@ -558,8 +558,7 @@ class YumBase(depsolve.Depsolve): 78 # this check makes sure that our dirs exist properly. 79 # if they aren't in the installroot then don't prepend the installroot path 80 # if we don't do this then anaconda likes to not work. 81 - if os.path.exists(self.conf.installroot+'/'+reposdir): 82 - reposdir = self.conf.installroot + '/' + reposdir 83 + reposdir = self.conf.getRootedPath(reposdir) 84 85 if os.path.isdir(reposdir): 86 for repofn in sorted(glob.glob('%s/*.repo' % reposdir)): 87 @@ -2146,12 +2145,16 @@ much more problems). 88 exid = "yum.includepkgs.3" 89 self.pkgSack.addPackageExcluder(repo.id, exid, 'exclude.marked') 90 91 - def doLock(self, lockfile = YUM_PID_FILE): 92 + def doLock(self, lockfile = None): 93 """Acquire the yum lock. 94 95 :param lockfile: the file to use for the lock 96 :raises: :class:`yum.Errors.LockError` 97 """ 98 + 99 + if lockfile is None: 100 + lockfile = self.conf.lockfile 101 + 102 if self.conf.uid != 0: 103 # If we are a user, assume we are using the root cache ... so don't 104 # bother locking. 105 @@ -2160,10 +2163,6 @@ much more problems). 106 root = self.conf.cachedir 107 # Don't want <cachedir>/var/run/yum.pid ... just: <cachedir>/yum.pid 108 lockfile = os.path.basename(lockfile) 109 - else: 110 - root = self.conf.installroot 111 - lockfile = root + '/' + lockfile # lock in the chroot 112 - lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra / 113 114 mypid=str(os.getpid()) 115 while not self._lock(lockfile, mypid, 0644): 116 Index: yum-3.4.3/yum/config.py 117 =================================================================== 118 --- yum-3.4.3.orig/yum/config.py 119 +++ yum-3.4.3/yum/config.py 120 @@ -727,6 +727,26 @@ class StartupConf(BaseConfig): 121 syslog_device = Option('/dev/log') 122 persistdir = Option('/var/lib/yum') 123 124 + def getRootedPath(self, path, enforce_default=False, defaults_to_host=False): 125 + instroot = getattr(self, 'installroot', None) 126 + if instroot==None or instroot == '/': 127 + return path 128 + 129 + if path.startswith('hostfs://'): res = path[9:] 130 + elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:] 131 + else: 132 + tmp = instroot + '/' + path 133 + 134 + if enforce_default: 135 + if defaults_to_host: res = path 136 + else: res = tmp 137 + else: 138 + if os.path.exists(tmp): res = tmp 139 + elif defaults_to_host: res = path 140 + else: res = tmp 141 + 142 + return res 143 + 144 class YumConf(StartupConf): 145 """Configuration option definitions for yum.conf's [main] section. 146 147 @@ -740,6 +760,7 @@ class YumConf(StartupConf): 148 149 keepcache = BoolOption(True) 150 logfile = Option('/var/log/yum.log') 151 + lockfile = Option('/var/run/yum.pid') 152 reposdir = ListOption(['/etc/yum/repos.d', '/etc/yum.repos.d']) 153 154 commands = ListOption() 155 @@ -1056,7 +1077,7 @@ def readStartupConfig(configfile, root, 156 startupconf.distroverpkg) 157 startupconf.releasever = releasever 158 159 - uuidfile = '%s/%s/uuid' % (startupconf.installroot, startupconf.persistdir) 160 + uuidfile = '%s/uuid' % (startupconf.persistdir,) 161 startupconf.uuid = get_uuid(uuidfile) 162 163 return startupconf 164 @@ -1086,7 +1107,7 @@ def readMainConfig(startupconf): 165 # Apply the installroot to directory options 166 def _apply_installroot(yumconf, option): 167 path = getattr(yumconf, option) 168 - ir_path = yumconf.installroot + path 169 + ir_path = yumconf.getRootedPath(path) 170 ir_path = ir_path.replace('//', '/') # os.path.normpath won't fix this and 171 # it annoys me 172 ir_path = varReplace(ir_path, yumvars) 173 @@ -1094,7 +1115,10 @@ def readMainConfig(startupconf): 174 175 # Read the FS yumvars 176 try: 177 - dir_fsvars = yumconf.installroot + "/etc/yum/vars/" 178 + if startupconf.config_file_path == '/etc/yum.conf': 179 + dir_fsvars = '/etc/yum/vars/' 180 + else: 181 + dir_fsvars = os.path.dirname(startupconf.config_file_path) + "/vars/" 182 fsvars = os.listdir(dir_fsvars) 183 except OSError: 184 fsvars = [] 185 @@ -1110,7 +1134,7 @@ def readMainConfig(startupconf): 186 yumvars[fsvar] = val 187 188 # These can use the above FS yumvars 189 - for option in ('cachedir', 'logfile', 'persistdir'): 190 + for option in ('cachedir', 'logfile', 'persistdir', 'lockfile'): 191 _apply_installroot(yumconf, option) 192 193 # Add in some extra attributes which aren't actually configuration values 194 Index: yum-3.4.3/yum/history.py 195 =================================================================== 196 --- yum-3.4.3.orig/yum/history.py 197 +++ yum-3.4.3/yum/history.py 198 @@ -659,10 +659,7 @@ class YumHistory: 199 self._conn = None 200 201 self.conf = yum.misc.GenericHolder() 202 - if not os.path.normpath(db_path).startswith(root): 203 - self.conf.db_path = os.path.normpath(root + '/' + db_path) 204 - else: 205 - self.conf.db_path = os.path.normpath('/' + db_path) 206 + self.conf.db_path = db_path 207 self.conf.writable = False 208 self.conf.readable = True 209 210 Index: yum-3.4.3/test/testbase.py 211 =================================================================== 212 --- yum-3.4.3.orig/test/testbase.py 213 +++ yum-3.4.3/test/testbase.py 214 @@ -68,6 +68,9 @@ class FakeConf(object): 215 self.depsolve_loop_limit = 10 216 self.override_install_langs = '' 217 218 + def getRootedPath(self, path, enforce_default=False, defaults_to_host=False): 219 + return path 220 + 221 class FakeSack: 222 """ Fake PackageSack to use with FakeRepository""" 223 def __init__(self):