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.3.3-chroot.patch (7694B)


      1 --- yum-2.3.3/docs/yum.conf.5.chroot
      2 +++ yum-2.3.3/docs/yum.conf.5
      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 \fBreposdir\fR
     15  A list of directories where yum should look for .repo files which define
     16 @@ -34,6 +36,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 @@ -41,7 +47,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.3.3/yum/__init__.py.chroot
     40 +++ yum-2.3.3/yum/__init__.py
     41 @@ -101,9 +101,8 @@
     42          # read each of them in using confpp, then parse them same as any other repo
     43          # section - as above.
     44          for reposdir in self.conf.reposdir:
     45 -            if os.path.exists(self.conf.installroot + '/' + reposdir):
     46 -                reposdir = self.conf.installroot + '/' + reposdir
     47 -            
     48 +            reposdir  = self.conf.getRootedPath(reposdir)
     49 +
     50              if os.path.isdir(reposdir):
     51                  repofn = glob.glob(reposdir+'/*.repo')
     52                  repofn.sort()
     53 @@ -425,17 +424,20 @@
     54          self.pkgSack.excludeArchs(archlist)
     55          self.log(3, 'Finished')
     56          
     57 +    def __getLockfileName(self):
     58 +        lockfile = self.conf.configdata['lockfile']
     59 +        return self.conf.getRootedPath(lockfile,
     60 +                                       enforce_default  = True,
     61 +                                       defaults_to_host = False)
     62          
     63 -        
     64 -    def doLock(self, lockfile):
     65 +    def doLock(self):
     66          """perform the yum locking, raise yum-based exceptions, not OSErrors"""
     67          
     68          # if we're not root then we don't lock - just return nicely
     69          if self.conf.getConfigOption('uid') != 0:
     70              return
     71 -            
     72 -        root = self.conf.installroot
     73 -        lockfile = root + '/' + lockfile # lock in the chroot
     74 +
     75 +        lockfile=self.__getLockfileName()
     76          
     77          mypid=str(os.getpid())    
     78          while not self._lock(lockfile, mypid, 0644):
     79 @@ -459,15 +461,14 @@
     80                      msg = 'Existing lock %s: another copy is running. Aborting.' % lockfile
     81                      raise Errors.LockError(0, msg)
     82      
     83 -    def doUnlock(self, lockfile):
     84 +    def doUnlock(self):
     85          """do the unlock for yum"""
     86          
     87          # if we're not root then we don't lock - just return nicely
     88          if self.conf.getConfigOption('uid') != 0:
     89              return
     90          
     91 -        root = self.conf.installroot
     92 -        lockfile = root + '/' + lockfile # lock in the chroot
     93 +        lockfile=self.__getLockfileName()
     94          
     95          self._unlock(lockfile)
     96          
     97 --- yum-2.3.3/yum/config.py.chroot
     98 +++ yum-2.3.3/yum/config.py
     99 @@ -193,7 +193,8 @@
    100                        
    101          #defaults -either get them or set them
    102          optionstrings = [('cachedir', '/var/cache/yum'), 
    103 -                         ('logfile', '/var/log/yum.log'), 
    104 +                         ('logfile', '/var/log/yum.log'),
    105 +                         ('lockfile', '/var/run/yum.pid'),
    106                           ('reposdir', ['/etc/yum/repos.d', '/etc/yum.repos.d']),
    107                           ('syslog_ident', None),
    108                           ('syslog_facility', 'LOG_USER'),
    109 @@ -305,9 +306,7 @@
    110  
    111          # do the dirs - set the root if there is one (grumble)
    112          for option in ['cachedir', 'logfile']:
    113 -            path = self.configdata[option]
    114 -            root = self.configdata['installroot']
    115 -            rootedpath = root + path
    116 +            rootedpath = self.getRootedPath(self.configdata[option])
    117              self.configdata[option] = rootedpath
    118              setattr(self, option, rootedpath)
    119          
    120 @@ -340,6 +339,23 @@
    121                          "All plugin search paths must be absolute")
    122  
    123  
    124 +    def getRootedPath(self, path, enforce_default=False, defaults_to_host=False):
    125 +	instroot = self.configdata['installroot']
    126 +        if   path.startswith('hostfs://'):   res = path[9:]
    127 +        elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:]
    128 +        else:
    129 +	    tmp = instroot + '/' +path
    130 +
    131 +            if enforce_default:
    132 +                if defaults_to_host:    res = path
    133 +                else:                   res = tmp
    134 +            else:
    135 +                if os.path.exists(tmp): res = tmp
    136 +                elif defaults_to_host:  res = path
    137 +                else:                   res = tmp
    138 +
    139 +	return res
    140 +
    141      def listConfigOptions(self):
    142          """return list of options available for global config"""
    143          return self.configdata.keys()
    144 @@ -719,9 +735,7 @@
    145      # read each of them in using confpp, then parse them same as any other repo
    146      # section - as above.
    147  
    148 -    reposdir = conf.reposdir
    149 -    if os.path.exists(conf.installroot + '/' + reposdir):
    150 -        reposdir = conf.installroot + '/' + reposdir
    151 +    reposdir  = conf.getRootedPath(conf.reposdir)
    152      
    153      reposglob = reposdir + '/*.repo'
    154      if os.path.exists(reposdir) and os.path.isdir(reposdir):
    155 --- yum-2.3.3/cli.py.chroot
    156 +++ yum-2.3.3/cli.py
    157 @@ -108,7 +108,7 @@
    158                  action="store_true", default=False, 
    159                  help="run entirely from cache, don't update cache")
    160          self.optparser.add_option("-c", "", dest="conffile", action="store", 
    161 -                default='/etc/yum.conf', help="config file location", 
    162 +                default=None, help="config file location", 
    163                  metavar=' [config file]')
    164          self.optparser.add_option("-R", "", dest="sleeptime", action="store", 
    165                  type='int', default=None, help="maximum command wait time",
    166 @@ -161,9 +161,12 @@
    167          try: 
    168              # If the conf file is inside the  installroot - use that.
    169              # otherwise look for it in the normal root
    170 -            if opts.installroot:
    171 -                if os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
    172 +            if opts.conffile==None:
    173 +                opts.conffile = '/etc/yum.conf'
    174 +                if opts.installroot and os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
    175                      opts.conffile = opts.installroot+'/'+opts.conffile
    176 +
    177 +            if opts.installroot:
    178                  root=opts.installroot
    179              else:
    180                  root = '/'
    181 --- yum-2.3.3/yummain.py.chroot
    182 +++ yum-2.3.3/yummain.py
    183 @@ -60,7 +60,7 @@
    184      def unlock():
    185          try:
    186              base.closeRpmDB()
    187 -            base.doUnlock(YUM_PID_FILE)
    188 +            base.doUnlock()
    189          except Errors.LockError, e:
    190              sys.exit(200)
    191  
    192 @@ -78,7 +78,7 @@
    193      except Errors.YumBaseError, e:
    194          exFatal(e)
    195      try:
    196 -        base.doLock(YUM_PID_FILE)
    197 +        base.doLock()
    198      except Errors.LockError, e:
    199          base.errorlog(0,'%s' % e.msg)
    200          sys.exit(200)