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.27_el6-chroot.patch (9598B)


      1 Patch for yum-3.2.27-14.el6_0.1
      2 
      3 diff --git a/cli.py b/cli.py
      4 index cebbae3..cdb0129 100644
      5 --- a/cli.py
      6 +++ b/cli.py
      7 @@ -1347,13 +1347,14 @@ class YumOptionParser(OptionParser):
      8      def getRoot(self,opts):
      9          # If the conf file is inside the  installroot - use that.
     10          # otherwise look for it in the normal root
     11 +        if opts.conffile==None:
     12 +            opts.conffile = '/etc/yum/yum.conf'
     13 +            if opts.installroot:
     14 +                if os.access(opts.installroot+opts.conffile, os.R_OK):
     15 +                    opts.conffile = opts.installroot+opts.conffile
     16 +                elif os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
     17 +                    opts.conffile = opts.installroot+'/etc/yum.conf'
     18          if opts.installroot:
     19 -            if os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
     20 -                opts.conffile = opts.installroot+'/'+opts.conffile
     21 -            elif opts.conffile == '/etc/yum/yum.conf':
     22 -                # check if /installroot/etc/yum.conf exists.
     23 -                if os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
     24 -                    opts.conffile = opts.installroot+'/etc/yum.conf'         
     25              root=opts.installroot
     26          else:
     27              root = '/'
     28 @@ -1394,7 +1395,6 @@ class YumOptionParser(OptionParser):
     29                  action="store_true",
     30                  help=_("run entirely from system cache, don't update cache"))
     31          group.add_option("-c", "--config", dest="conffile",
     32 -                default='/etc/yum/yum.conf',
     33                  help=_("config file location"), metavar='[config file]')
     34          group.add_option("-R", "--randomwait", dest="sleeptime", type='int',
     35                  default=None,
     36 diff --git a/yum/__init__.py b/yum/__init__.py
     37 index 978815d..916c8d6 100644
     38 --- a/yum/__init__.py
     39 +++ b/yum/__init__.py
     40 @@ -399,8 +399,7 @@ class YumBase(depsolve.Depsolve):
     41              # this check makes sure that our dirs exist properly.
     42              # if they aren't in the installroot then don't prepend the installroot path
     43              # if we don't do this then anaconda likes to not  work.
     44 -            if os.path.exists(self.conf.installroot+'/'+reposdir):
     45 -                reposdir = self.conf.installroot + '/' + reposdir
     46 +            reposdir = self.conf.getRootedPath(reposdir)
     47  
     48              if os.path.isdir(reposdir):
     49                  for repofn in sorted(glob.glob('%s/*.repo' % reposdir)):
     50 @@ -1379,9 +1378,7 @@ class YumBase(depsolve.Depsolve):
     51          if self.conf.uid != 0:
     52              return
     53              
     54 -        root = self.conf.installroot
     55 -        lockfile = root + '/' + lockfile # lock in the chroot
     56 -        lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra /
     57 +        lockfile = self.conf.lockfile
     58          
     59          mypid=str(os.getpid())    
     60          while not self._lock(lockfile, mypid, 0644):
     61 diff --git a/yum/config.py b/yum/config.py
     62 index 975172a..603aacc 100644
     63 --- a/yum/config.py
     64 +++ b/yum/config.py
     65 @@ -604,6 +604,26 @@ class StartupConf(BaseConfig):
     66      syslog_facility = Option('LOG_DAEMON')
     67      persistdir = Option('/var/lib/yum')
     68      
     69 +    def getRootedPath(self, path, enforce_default=False, defaults_to_host=False):
     70 +        instroot = getattr(self, 'installroot', None)
     71 +        if instroot==None:
     72 +            return path
     73 +
     74 +        if   path.startswith('hostfs://'):   res = path[9:]
     75 +        elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:]
     76 +        else:
     77 +            tmp = instroot + '/' + path
     78 +
     79 +            if enforce_default:
     80 +                if defaults_to_host:    res = path
     81 +                else:                   res = tmp
     82 +            else:
     83 +                if os.path.exists(tmp): res = tmp
     84 +                elif defaults_to_host:  res = path
     85 +                else:                   res = tmp
     86 +
     87 +        return res
     88 +
     89  class YumConf(StartupConf):
     90      '''
     91      Configuration option definitions for yum.conf\'s [main] section.
     92 @@ -617,6 +637,7 @@ class YumConf(StartupConf):
     93  
     94      keepcache = BoolOption(True)
     95      logfile = Option('/var/log/yum.log')
     96 +    lockfile = Option('/var/run/yum.pid')
     97      reposdir = ListOption(['/etc/yum/repos.d', '/etc/yum.repos.d'])
     98  
     99      commands = ListOption()
    100 @@ -832,7 +853,10 @@ def readStartupConfig(configfile, root):
    101      # Stuff this here to avoid later re-parsing
    102      startupconf._parser = parser
    103      # setup the release ver here
    104 -    startupconf.releasever = _getsysver(startupconf.installroot, startupconf.distroverpkg)
    105 +    try:
    106 +        startupconf.releasever = _getsysver(startupconf.installroot, startupconf.distroverpkg)
    107 +    except:
    108 +        startupconf.releasever = ""
    109      uuidfile = '%s/%s/uuid' % (startupconf.installroot, startupconf.persistdir)
    110      startupconf.uuid = get_uuid(uuidfile)
    111  
    112 @@ -864,7 +888,7 @@ def readMainConfig(startupconf):
    113      # Apply the installroot to directory options
    114      def _apply_installroot(yumconf, option):
    115          path = getattr(yumconf, option)
    116 -        ir_path = yumconf.installroot + path
    117 +        ir_path = yumconf.getRootedPath(path)
    118          ir_path = ir_path.replace('//', '/') # os.path.normpath won't fix this and
    119                                               # it annoys me
    120          ir_path = varReplace(ir_path, yumvars)
    121 @@ -888,7 +912,7 @@ def readMainConfig(startupconf):
    122          yumvars[fsvar] = val
    123  
    124      # These can use the above FS yumvars
    125 -    for option in ('cachedir', 'logfile', 'persistdir'):
    126 +    for option in ('cachedir', 'logfile', 'persistdir', 'lockfile'):
    127          _apply_installroot(yumconf, option)
    128  
    129      # Add in some extra attributes which aren't actually configuration values 
    130 diff --git a/yum/history.py b/yum/history.py
    131 index 32eed2c..64b6695 100644
    132 --- a/yum/history.py
    133 +++ b/yum/history.py
    134 @@ -176,10 +176,7 @@ class YumHistory:
    135          self._conn = None
    136          
    137          self.conf = yum.misc.GenericHolder()
    138 -        if not os.path.normpath(db_path).startswith(root):
    139 -            self.conf.db_path  = os.path.normpath(root + '/' + db_path)
    140 -        else:
    141 -            self.conf.db_path = os.path.normpath('/' + db_path)
    142 +        self.conf.db_path  = db_path
    143          self.conf.writable = False
    144          self.conf.readable = True
    145  
    146 diff --git a/yum/rpmsack.py b/yum/rpmsack.py
    147 index 878e8d4..1938f1a 100644
    148 --- a/yum/rpmsack.py
    149 +++ b/yum/rpmsack.py
    150 @@ -151,13 +151,8 @@ class RPMDBPackageSack(PackageSackBase):
    151          self._get_pro_cache = {}
    152          self._get_req_cache  = {}
    153          self._loaded_gpg_keys = False
    154 -        if cachedir is None:
    155 -            cachedir = persistdir + "/rpmdb-indexes"
    156 -        self.setCacheDir(cachedir)
    157 -        if not os.path.normpath(persistdir).startswith(self.root):
    158 -            self._persistdir = root +  '/' + persistdir
    159 -        else:
    160 -            self._persistdir = persistdir
    161 +        self._cachedir = persistdir + "/rpmdb-indexes"
    162 +        self._persistdir = persistdir
    163          self._have_cached_rpmdbv_data = None
    164          self._cached_conflicts_data = None
    165          # Store the result of what happens, if a transaction completes.
    166 @@ -217,14 +212,6 @@ class RPMDBPackageSack(PackageSackBase):
    167          self.transactionReset() # Should do nothing, but meh...
    168          self._cached_rpmdb_mtime = None
    169  
    170 -    def setCacheDir(self, cachedir):
    171 -        """ Sets the internal cachedir value for the rpmdb, to be the
    172 -            "rpmdb-indexes" directory in the persisent yum storage. """
    173 -        if not os.path.normpath(cachedir).startswith(self.root):
    174 -            self._cachedir = self.root + '/' + cachedir
    175 -        else:
    176 -            self._cachedir = '/' + cachedir
    177 -
    178      def readOnlyTS(self):
    179          if not self.ts:
    180              self.ts =  initReadOnlyTransaction(root=self.root)
    181 @@ -861,7 +848,7 @@ class RPMDBPackageSack(PackageSackBase):
    182          # http://lists.rpm.org/pipermail/rpm-maint/2007-November/001719.html
    183          # ...if anything gets implemented, we should change.
    184          rpmdbvfname = self._cachedir + "/version"
    185 -        rpmdbfname  = self.root + "/var/lib/rpm/Packages"
    186 +        rpmdbfname  = self.root + rpm.expandMacro("%_dbpath/Packages")
    187  
    188          if os.path.exists(rpmdbvfname) and os.path.exists(rpmdbfname):
    189              # See if rpmdb has "changed" ...
    190 @@ -881,7 +868,7 @@ class RPMDBPackageSack(PackageSackBase):
    191          if self._cached_rpmdb_mtime is None:
    192              return # We haven't loaded any packages!!!
    193  
    194 -        rpmdbfname  = self.root + "/var/lib/rpm/Packages"
    195 +        rpmdbfname  = self.root + rpm.expandMacro("%_dbpath/Packages")
    196          if not os.path.exists(rpmdbfname):
    197              return # haha
    198  
    199 @@ -1104,7 +1091,7 @@ class RPMDBPackageSack(PackageSackBase):
    200          self._name2pkg.setdefault(po.name, []).append(po)
    201          self._tup2pkg[po.pkgtup] = po
    202          if self.__cache_rpmdb__ and self._cached_rpmdb_mtime is None:
    203 -            rpmdbfname  = self.root + "/var/lib/rpm/Packages"
    204 +            rpmdbfname  = self.root + rpm.expandMacro("%_dbpath/Packages")
    205              self._cached_rpmdb_mtime = os.path.getmtime(rpmdbfname)
    206  
    207          return po
    208 diff --git a/yum/rpmtrans.py b/yum/rpmtrans.py
    209 index 0340153..a544b9c 100644
    210 --- a/yum/rpmtrans.py
    211 +++ b/yum/rpmtrans.py
    212 @@ -243,7 +243,10 @@ class RPMTransaction:
    213      def _scriptout(self, data):
    214          msgs = self._scriptOutput()
    215          self.display.scriptout(data, msgs)
    216 -        self.base.history.log_scriptlet_output(data, msgs)
    217 +        try:
    218 +            self.base.history.log_scriptlet_output(data, msgs)
    219 +        except:
    220 +            self.display.errorlog('could not log scriptlet output')
    221  
    222      def __del__(self):
    223          self._shutdownOutputLogging()