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.2.1-chroot.patch (7431B)


      1 --- yum-2.2.1/docs/yum.conf.5.chroot	2005-02-19 23:30:54.000000000 +0100
      2 +++ yum-2.2.1/docs/yum.conf.5	2005-04-08 19:53:02.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 \fBreposdir\fR
     15  Directory where yum should look for .repo files for its configuration
     16 @@ -33,6 +35,10 @@
     17  repository options below. These will be merged with the repositories defined
     18  in /etc/yum.conf to form the complete set of repositories 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 @@ -40,7 +46,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.2.1/yum/__init__.py.chroot	2005-03-15 08:34:03.000000000 +0100
     40 +++ yum-2.2.1/yum/__init__.py	2005-04-08 20:10:36.000000000 +0200
     41 @@ -298,19 +298,22 @@
     42                  self.log(3, 'Arch Excluding %s' % po)
     43                  self.pkgSack.delPackage(po)
     44          self.log(2, 'Finished')
     45 +
     46 +    def __getLockfileName(self):
     47 +        lockfile = self.conf.configdata['lockfile']
     48 +        return self.conf.getRootedPath(lockfile,
     49 +                                       enforce_default  = True,
     50 +                                       defaults_to_host = False)
     51          
     52 -        
     53 -        
     54 -    def doLock(self, lockfile):
     55 +    def doLock(self):
     56          """perform the yum locking, raise yum-based exceptions, not OSErrors"""
     57          
     58          # if we're not root then we don't lock - just return nicely
     59          if self.conf.getConfigOption('uid') != 0:
     60              return
     61  
     62 -        root = self.conf.installroot
     63 -        lockfile = root + '/' + lockfile # lock in the chroot
     64 -
     65 +        lockfile=self.__getLockfileName()
     66 +        
     67          mypid=str(os.getpid())    
     68          while not self._lock(lockfile, mypid, 0644):
     69              fd = open(lockfile, 'r')
     70 @@ -333,15 +336,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.getConfigOption('uid') != 0:
     80              return
     81  
     82 -        root = self.conf.installroot
     83 -        lockfile = root + '/' + lockfile # lock in the chroot
     84 +        lockfile=self.__getLockfileName()
     85  
     86          self._unlock(lockfile)
     87          
     88 --- yum-2.2.1/yum/config.py.chroot	2005-03-15 07:09:18.000000000 +0100
     89 +++ yum-2.2.1/yum/config.py	2005-04-08 19:53:02.000000000 +0200
     90 @@ -194,7 +194,8 @@
     91                        
     92          #defaults -either get them or set them
     93          optionstrings = [('cachedir', '/var/cache/yum'), 
     94 -                         ('logfile', '/var/log/yum.log'), 
     95 +                         ('logfile', '/var/log/yum.log'),
     96 +                         ('lockfile', '/var/run/yum.pid'),
     97                           ('reposdir', '/etc/yum.repos.d'),
     98                           ('rss-filename', 'yum-rss.xml'),
     99                           ('pkgpolicy', 'newest'),
    100 @@ -270,9 +271,7 @@
    101              
    102          # do the dirs - set the root if there is one (grumble)
    103          for option in ['cachedir', 'logfile']:
    104 -            path = self.configdata[option]
    105 -            root = self.configdata['installroot']
    106 -            rootedpath = root + path
    107 +            rootedpath = self.getRootedPath(self.configdata[option])
    108              self.configdata[option] = rootedpath
    109              setattr(self, option, rootedpath)
    110          
    111 @@ -314,8 +313,7 @@
    112          # read each of them in using confpp, then parse them same as any other repo
    113          # section - as above.
    114          reposdir = self.getConfigOption('reposdir')
    115 -        if os.path.exists(self.getConfigOption('installroot') + '/' + reposdir):
    116 -            reposdir = self.getConfigOption('installroot') + '/' + reposdir
    117 +        reposdir = self.getRootedPath(reposdir)
    118          
    119          reposglob = reposdir + '/*.repo'
    120          if os.path.exists(reposdir) and os.path.isdir(reposdir):
    121 @@ -334,6 +332,23 @@
    122                      print e
    123                      
    124  
    125 +    def getRootedPath(self, path, enforce_default=False, defaults_to_host=False):
    126 +	instroot = self.configdata['installroot']
    127 +        if   path.startswith('hostfs://'):   res = path[9:]
    128 +        elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:]
    129 +        else:
    130 +	    tmp = instroot + '/' +path
    131 +
    132 +            if enforce_default:
    133 +                if defaults_to_host:    res = path
    134 +                else:                   res = tmp
    135 +            else:
    136 +                if os.path.exists(tmp): res = tmp
    137 +                elif defaults_to_host:  res = path
    138 +                else:                   res = tmp
    139 +
    140 +	return res
    141 +
    142      def listConfigOptions(self):
    143          """return list of options available for global config"""
    144          return self.configdata.keys()
    145 --- yum-2.2.1/cli.py.chroot	2005-03-15 08:19:11.000000000 +0100
    146 +++ yum-2.2.1/cli.py	2005-04-08 19:53:02.000000000 +0200
    147 @@ -126,7 +126,7 @@
    148          sleeptime=0
    149          root = '/'
    150          installroot = None
    151 -        conffile = '/etc/yum.conf'
    152 +        conffile = None
    153          
    154          try: 
    155              for o,a in gopts:
    156 @@ -140,12 +140,14 @@
    157              
    158              # if the conf file is inside the  installroot - use that.
    159              # otherwise look for it in the normal root
    160 -            if installroot:
    161 -                if os.access(installroot + '/' + conffile, os.R_OK):
    162 +            if conffile==None:
    163 +                conffile = '/etc/yum.conf'
    164 +                if installroot and os.access(installroot + '/' + conffile, os.R_OK):
    165                      conffile = installroot + '/' + conffile
    166 -                    
    167 +
    168 +            if installroot:
    169                  root = installroot
    170 -                    
    171 +
    172              try:
    173                  self.conf = yumconf(configfile = conffile, root = root)
    174              except yum.Errors.ConfigError, e:
    175 --- yum-2.2.1/yummain.py.chroot	2005-01-07 14:45:50.000000000 +0100
    176 +++ yum-2.2.1/yummain.py	2005-04-08 19:53:02.000000000 +0200
    177 @@ -41,7 +41,7 @@
    178      def unlock():
    179          try:
    180              base.closeRpmDB()
    181 -            base.doUnlock('/var/run/yum.pid')
    182 +            base.doUnlock()
    183          except Errors.LockError, e:
    184              sys.exit(200)
    185  
    186 @@ -58,7 +58,7 @@
    187          sys.exit(1)
    188          
    189      try:
    190 -        base.doLock('/var/run/yum.pid')
    191 +        base.doLock()
    192      except Errors.LockError, e:
    193          base.errorlog(0,'%s' % e.msg)
    194          sys.exit(200)