vshost-util-vserver

Build script and sources for util-vserver.
git clone https://ccx.te2000.cz/git/vshost-util-vserver
Log | Files | Refs

yum-2.9.6-chroot.patch (7966B)


      1 diff -Nurp yum-2.9.6.orig/cli.py yum-2.9.6/cli.py
      2 --- yum-2.9.6.orig/cli.py	2006-09-06 06:15:49.000000000 +0200
      3 +++ yum-2.9.6/cli.py	2006-09-25 09:08:06.000000000 +0200
      4 @@ -123,7 +123,7 @@ yum [options] < update | install | info 
      5                  action="store_true", default=False, 
      6                  help="run entirely from cache, don't update cache")
      7          self.optparser.add_option("-c", "", dest="conffile", action="store", 
      8 -                default='/etc/yum.conf', help="config file location", 
      9 +                default=None, help="config file location", 
     10                  metavar=' [config file]')
     11          self.optparser.add_option("-R", "", dest="sleeptime", action="store", 
     12                  type='int', default=None, help="maximum command wait time",
     13 @@ -175,9 +175,12 @@ yum [options] < update | install | info 
     14  
     15          # If the conf file is inside the  installroot - use that.
     16          # otherwise look for it in the normal root
     17 -        if opts.installroot:
     18 -            if os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
     19 +        if opts.conffile==None:
     20 +            opts.conffile = '/etc/yum.conf'
     21 +            if opts.installroot and os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
     22                  opts.conffile = opts.installroot+'/'+opts.conffile
     23 +        
     24 +        if opts.installroot:
     25              root=opts.installroot
     26          else:
     27              root = '/'
     28 diff -Nurp yum-2.9.6.orig/docs/yum.conf.5 yum-2.9.6/docs/yum.conf.5
     29 --- yum-2.9.6.orig/docs/yum.conf.5	2006-06-19 03:28:22.000000000 +0200
     30 +++ yum-2.9.6/docs/yum.conf.5	2006-09-25 09:02:50.000000000 +0200
     31 @@ -23,8 +23,10 @@ The [main] section must exist for yum to
     32  following options:
     33  
     34  .IP \fBcachedir\fR
     35 -Directory where yum should store its cache and db files. The default is
     36 -`/var/cache/yum'.
     37 +Directory where yum should store its cache and db files. The default
     38 +is `/var/cache/yum'. Unless the prefixes `hostfs://' or `chrootfs://'
     39 +are used, some magic will be applied to determine the real path in
     40 +combination with `--installroot'.
     41  
     42  .IP \fBkeepcache\fR
     43  Either `1' or `0'. Determines whether or not yum keeps the cache
     44 @@ -40,6 +42,10 @@ documented in \fB[repository] options\fR
     45  repositories defined in /etc/yum.conf to form the complete set of repositories
     46  that yum will use.
     47  
     48 +Unless the prefixes `hostfs://' or `chrootfs://' are used, some magic
     49 +will be applied to determine the real path in combination with
     50 +`--installroot'.
     51 +
     52  .IP \fBdebuglevel\fR
     53  Debug message output level. Practical range is 0\-10. Default is `2'.
     54  
     55 @@ -47,7 +53,10 @@ Debug message output level. Practical ra
     56  Error message output level. Practical range is 0\-10. Default is `2'.
     57  
     58  .IP \fBlogfile\fR
     59 -Full directory and file name for where yum should write its log file.
     60 +Full directory and file name for where yum should write its log
     61 +file. Unless the prefixes `hostfs://' or `chrootfs://' are used,
     62 +some magic will be applied to determine the real path in combination
     63 +with `--installroot'.
     64  
     65  .IP \fBgpgcheck\fR
     66  Either `1' or `0'. This tells yum whether or not it should perform a GPG
     67 diff -Nurp yum-2.9.6.orig/yum/config.py yum-2.9.6/yum/config.py
     68 --- yum-2.9.6.orig/yum/config.py	2006-06-19 03:28:22.000000000 +0200
     69 +++ yum-2.9.6/yum/config.py	2006-09-25 09:12:36.000000000 +0200
     70 @@ -481,6 +481,26 @@ class StartupConf(BaseConfig):
     71      pluginpath = ListOption(['/usr/lib/yum-plugins'])
     72      pluginconfpath = ListOption(['/etc/yum/pluginconf.d'])
     73  
     74 +    def getRootedPath(self, path, enforce_default=False, defaults_to_host=False):
     75 +        instroot = getattr(self, 'installroot', None)
     76 +        if instroot==None:
     77 +            return path
     78 +
     79 +        if   path.startswith('hostfs://'):   res = path[9:]
     80 +        elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:]
     81 +        else:
     82 +            tmp = instroot + '/' + path
     83 +
     84 +            if enforce_default:
     85 +                if defaults_to_host:    res = path
     86 +                else:                   res = tmp
     87 +            else:
     88 +                if os.path.exists(tmp): res = tmp
     89 +                elif defaults_to_host:  res = path
     90 +                else:                   res = tmp
     91 +
     92 +        return res
     93 +
     94  class YumConf(StartupConf):
     95      '''
     96      Configuration option definitions for yum.conf\'s [main] section.
     97 @@ -493,6 +513,7 @@ class YumConf(StartupConf):
     98      cachedir = Option('/var/cache/yum')
     99      keepcache = BoolOption(True)
    100      logfile = Option('/var/log/yum.log')
    101 +    lockfile = Option('/var/run/yum.pid')
    102      reposdir = ListOption(['/etc/yum/repos.d', '/etc/yum.repos.d'])
    103      syslog_ident = Option()
    104      syslog_facility = Option('LOG_DAEMON')
    105 @@ -616,9 +637,9 @@ def readMainConfig(startupconf):
    106      yumconf.populate(startupconf._parser, 'main')
    107  
    108      # Apply the installroot to directory options
    109 -    for option in ('cachedir', 'logfile'):
    110 +    for option in ('cachedir', 'logfile', 'lockfile'):
    111          path = getattr(yumconf, option)
    112 -        setattr(yumconf, option, yumconf.installroot + path)
    113 +        setattr(yumconf, option, yumconf.getRootedPath(path))
    114      
    115      # Add in some extra attributes which aren't actually configuration values 
    116      yumconf.yumvar = vars
    117 diff -Nurp yum-2.9.6.orig/yum/__init__.py yum-2.9.6/yum/__init__.py
    118 --- yum-2.9.6.orig/yum/__init__.py	2006-09-06 06:18:20.000000000 +0200
    119 +++ yum-2.9.6/yum/__init__.py	2006-09-25 09:02:50.000000000 +0200
    120 @@ -171,8 +171,7 @@ class YumBase(depsolve.Depsolve):
    121          # (typically /etc/yum.repos.d and /etc/yum/repos.d)
    122          parser = config.IncludedDirConfigParser(vars=self.yumvar)
    123          for reposdir in self.conf.reposdir:
    124 -            if os.path.exists(self.conf.installroot+'/'+reposdir):
    125 -                reposdir = self.conf.installroot + '/' + reposdir
    126 +            reposdir  = self.conf.getRootedPath(reposdir)
    127  
    128              if os.path.isdir(reposdir):
    129                  #XXX: why can't we just pass the list of files?
    130 @@ -502,16 +501,14 @@ class YumBase(depsolve.Depsolve):
    131              
    132          self.verbose_logger.log(logginglevels.INFO_2, 'Finished')
    133          
    134 -    def doLock(self, lockfile):
    135 +    def doLock(self):
    136          """perform the yum locking, raise yum-based exceptions, not OSErrors"""
    137          
    138          # if we're not root then we don't lock - just return nicely
    139          if self.conf.uid != 0:
    140              return
    141              
    142 -        root = self.conf.installroot
    143 -        lockfile = root + '/' + lockfile # lock in the chroot
    144 -        lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra /
    145 +        lockfile = self.conf.lockfile
    146          
    147          mypid=str(os.getpid())    
    148          while not self._lock(lockfile, mypid, 0644):
    149 @@ -537,15 +540,14 @@ class YumBase(depsolve.Depsolve):
    150                      msg = 'Existing lock %s: another copy is running. Aborting.' % lockfile
    151                      raise Errors.LockError(0, msg)
    152      
    153 -    def doUnlock(self, lockfile):
    154 +    def doUnlock(self):
    155          """do the unlock for yum"""
    156          
    157          # if we're not root then we don't lock - just return nicely
    158          if self.conf.uid != 0:
    159              return
    160          
    161 -        root = self.conf.installroot
    162 -        lockfile = root + '/' + lockfile # lock in the chroot
    163 +        lockfile=self.conf.lockfile
    164          
    165          self._unlock(lockfile)
    166          
    167 diff -Nurp yum-2.9.6.orig/yummain.py yum-2.9.6/yummain.py
    168 --- yum-2.9.6.orig/yummain.py	2006-08-19 22:04:33.000000000 +0200
    169 +++ yum-2.9.6/yummain.py	2006-09-25 09:02:50.000000000 +0200
    170 @@ -62,7 +62,7 @@ def main(args):
    171      def unlock():
    172          try:
    173              base.closeRpmDB()
    174 -            base.doUnlock(YUM_PID_FILE)
    175 +            base.doUnlock()
    176          except Errors.LockError, e:
    177              sys.exit(200)
    178  
    179 @@ -88,7 +88,7 @@ def main(args):
    180      except Errors.YumBaseError, e:
    181          exFatal(e)
    182      try:
    183 -        base.doLock(YUM_PID_FILE)
    184 +        base.doLock()
    185      except Errors.LockError, e:
    186          logger.critical('%s', e.msg)
    187          sys.exit(200)