vshost-util-vserver

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

yum-3.2.0-chroot.patch (7648B)


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