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.6.0-chroot.patch (7184B)


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