yum-3.2.4-chroot.patch (8021B)
1 diff -Nurp yum-3.2.4.orig/cli.py yum-3.2.4/cli.py 2 --- yum-3.2.4.orig/cli.py 2007-08-15 17:48:03.000000000 +0200 3 +++ yum-3.2.4/cli.py 2008-09-29 02:32:24.000000000 +0200 4 @@ -1204,13 +1204,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' 15 if opts.installroot: 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' 22 root=opts.installroot 23 else: 24 root = '/' 25 @@ -1231,7 +1232,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.4.orig/docs/yum.conf.5 yum-3.2.4/docs/yum.conf.5 35 --- yum-3.2.4.orig/docs/yum.conf.5 2007-08-16 14:42:26.000000000 +0200 36 +++ yum-3.2.4/docs/yum.conf.5 2008-09-29 02:32:24.000000000 +0200 37 @@ -23,8 +23,10 @@ The [main] section must exist for yum to 38 following options: 39 40 .IP \fBcachedir\fR 41 -Directory where yum should store its cache and db files. The default is 42 -`/var/cache/yum'. 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'. 47 48 .IP \fBpersistdir\fR 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. 53 54 +Unless the prefixes `hostfs://' or `chrootfs://' are used, some magic 55 +will be applied to determine the real path in combination with 56 +`--installroot'. 57 + 58 .IP \fBdebuglevel\fR 59 Debug message output level. Practical range is 0\-10. Default is `2'. 60 61 @@ -51,7 +57,10 @@ Debug message output level. Practical ra 62 Error message output level. Practical range is 0\-10. Default is `2'. 63 64 .IP \fBlogfile\fR 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'. 70 71 .IP \fBgpgcheck\fR 72 Either `1' or `0'. This tells yum whether or not it should perform a GPG 73 diff -Nurp yum-3.2.4.orig/yum/config.py yum-3.2.4/yum/config.py 74 --- yum-3.2.4.orig/yum/config.py 2007-08-28 19:38:39.000000000 +0200 75 +++ yum-3.2.4/yum/config.py 2008-09-29 03:09:28.000000000 +0200 76 @@ -469,6 +469,26 @@ class StartupConf(BaseConfig): 77 pluginpath = ListOption(['/usr/share/yum-plugins', '/usr/lib/yum-plugins']) 78 pluginconfpath = ListOption(['/etc/yum/pluginconf.d']) 79 80 + def getRootedPath(self, path, enforce_default=False, defaults_to_host=False): 81 + instroot = getattr(self, 'installroot', None) 82 + if instroot==None: 83 + return path 84 + 85 + if path.startswith('hostfs://'): res = path[9:] 86 + elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:] 87 + else: 88 + tmp = instroot + '/' + path 89 + 90 + if enforce_default: 91 + if defaults_to_host: res = path 92 + else: res = tmp 93 + else: 94 + if os.path.exists(tmp): res = tmp 95 + elif defaults_to_host: res = path 96 + else: res = tmp 97 + 98 + return res 99 + 100 class YumConf(StartupConf): 101 ''' 102 Configuration option definitions for yum.conf\'s [main] section. 103 @@ -482,6 +502,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']) 109 syslog_ident = Option() 110 syslog_facility = Option('LOG_DAEMON') 111 @@ -615,9 +636,9 @@ def readMainConfig(startupconf): 112 yumconf.populate(startupconf._parser, 'main') 113 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)) 120 121 # Add in some extra attributes which aren't actually configuration values 122 yumconf.yumvar = yumvars 123 diff -Nurp yum-3.2.4.orig/yum/__init__.py yum-3.2.4/yum/__init__.py 124 --- yum-3.2.4.orig/yum/__init__.py 2007-08-28 20:45:13.000000000 +0200 125 +++ yum-3.2.4/yum/__init__.py 2008-09-29 03:08:34.000000000 +0200 126 @@ -214,8 +214,7 @@ class YumBase(depsolve.Depsolve): 127 repo_config_age = self.conf.config_file_age 128 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) 133 134 if os.path.isdir(reposdir): 135 for repofn in glob.glob('%s/*.repo' % reposdir): 136 @@ -664,11 +663,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: 139 return 140 - 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 / 144 - 145 + 146 + lockfile = self.conf.lockfile 147 + 148 mypid=str(os.getpid()) 149 while not self._lock(lockfile, mypid, 0644): 150 fd = open(lockfile, 'r') 151 @@ -700,9 +697,8 @@ class YumBase(depsolve.Depsolve): 152 if self.conf.uid != 0: 153 return 154 155 - root = self.conf.installroot 156 - lockfile = root + '/' + lockfile # lock in the chroot 157 - 158 + lockfile=self.conf.lockfile 159 + 160 self._unlock(lockfile) 161 162 def _lock(self, filename, contents='', mode=0777): 163 diff -Nurp yum-3.2.4.orig/yum/rpmtrans.py yum-3.2.4/yum/rpmtrans.py 164 --- yum-3.2.4.orig/yum/rpmtrans.py 2007-08-15 19:27:19.000000000 +0200 165 +++ yum-3.2.4/yum/rpmtrans.py 2008-09-29 03:09:54.000000000 +0200 166 @@ -149,7 +149,8 @@ class RPMTransaction: 167 168 if not hasattr(self, '_ts_done'): 169 # need config variable to put this in a better path/name 170 - te_fn = '%s/transaction-done.%s' % (self.base.conf.persistdir, self._ts_time) 171 + te_fn = '%s/transaction-done.%s' % ( 172 + self.base.conf.getRootedPath(self.base.conf.persistdir), self._ts_time) 173 self.ts_done_fn = te_fn 174 try: 175 self._ts_done = open(te_fn, 'w')