root/trunk/contrib/yum-2.9.6-chroot.patch

Revision 2425, 7.8 kB (checked in by ensc, 2 years ago)

fixed location of the lockfile; formerly, the chroot path was prepended
twice

  • yum-2.9.6/cli.py

    old new  
    123123                action="store_true", default=False,  
    124124                help="run entirely from cache, don't update cache") 
    125125        self.optparser.add_option("-c", "", dest="conffile", action="store",  
    126                 default='/etc/yum.conf', help="config file location",  
     126                default=None, help="config file location",  
    127127                metavar=' [config file]') 
    128128        self.optparser.add_option("-R", "", dest="sleeptime", action="store",  
    129129                type='int', default=None, help="maximum command wait time", 
     
    175175 
    176176        # If the conf file is inside the  installroot - use that. 
    177177        # otherwise look for it in the normal root 
    178         if opts.installroot: 
    179             if os.access(opts.installroot+'/'+opts.conffile, os.R_OK): 
     178        if opts.conffile==None: 
     179            opts.conffile = '/etc/yum.conf' 
     180            if opts.installroot and os.access(opts.installroot+'/'+opts.conffile, os.R_OK): 
    180181                opts.conffile = opts.installroot+'/'+opts.conffile 
     182         
     183        if opts.installroot: 
    181184            root=opts.installroot 
    182185        else: 
    183186            root = '/' 
  • yum-2.9.6/docs/yum.conf.5

    old new  
    2323following options: 
    2424 
    2525.IP \fBcachedir\fR 
    26 Directory where yum should store its cache and db files. The default is 
    27 `/var/cache/yum'. 
     26Directory where yum should store its cache and db files. The default 
     27is `/var/cache/yum'. Unless the prefixes `hostfs://' or `chrootfs://' 
     28are used, some magic will be applied to determine the real path in 
     29combination with `--installroot'. 
    2830 
    2931.IP \fBkeepcache\fR 
    3032Either `1' or `0'. Determines whether or not yum keeps the cache 
     
    4042repositories defined in /etc/yum.conf to form the complete set of repositories 
    4143that yum will use. 
    4244 
     45Unless the prefixes `hostfs://' or `chrootfs://' are used, some magic 
     46will be applied to determine the real path in combination with 
     47`--installroot'. 
     48 
    4349.IP \fBdebuglevel\fR 
    4450Debug message output level. Practical range is 0\-10. Default is `2'. 
    4551 
     
    4753Error message output level. Practical range is 0\-10. Default is `2'. 
    4854 
    4955.IP \fBlogfile\fR 
    50 Full directory and file name for where yum should write its log file. 
     56Full directory and file name for where yum should write its log 
     57file. Unless the prefixes `hostfs://' or `chrootfs://' are used, 
     58some magic will be applied to determine the real path in combination 
     59with `--installroot'. 
    5160 
    5261.IP \fBgpgcheck\fR 
    5362Either `1' or `0'. This tells yum whether or not it should perform a GPG 
  • yum-2.9.6/yum/config.py

    old new  
    481481    pluginpath = ListOption(['/usr/lib/yum-plugins']) 
    482482    pluginconfpath = ListOption(['/etc/yum/pluginconf.d']) 
    483483 
     484    def getRootedPath(self, path, enforce_default=False, defaults_to_host=False): 
     485        instroot = getattr(self, 'installroot', None) 
     486        if instroot==None: 
     487            return path 
     488 
     489        if   path.startswith('hostfs://'):   res = path[9:] 
     490        elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:] 
     491        else: 
     492            tmp = instroot + '/' + path 
     493 
     494            if enforce_default: 
     495                if defaults_to_host:    res = path 
     496                else:                   res = tmp 
     497            else: 
     498                if os.path.exists(tmp): res = tmp 
     499                elif defaults_to_host:  res = path 
     500                else:                   res = tmp 
     501 
     502        return res 
     503 
    484504class YumConf(StartupConf): 
    485505    ''' 
    486506    Configuration option definitions for yum.conf\'s [main] section. 
     
    493513    cachedir = Option('/var/cache/yum') 
    494514    keepcache = BoolOption(True) 
    495515    logfile = Option('/var/log/yum.log') 
     516    lockfile = Option('/var/run/yum.pid') 
    496517    reposdir = ListOption(['/etc/yum/repos.d', '/etc/yum.repos.d']) 
    497518    syslog_ident = Option() 
    498519    syslog_facility = Option('LOG_DAEMON') 
     
    616637    yumconf.populate(startupconf._parser, 'main') 
    617638 
    618639    # Apply the installroot to directory options 
    619     for option in ('cachedir', 'logfile'): 
     640    for option in ('cachedir', 'logfile', 'lockfile'): 
    620641        path = getattr(yumconf, option) 
    621         setattr(yumconf, option, yumconf.installroot + path
     642        setattr(yumconf, option, yumconf.getRootedPath(path)
    622643     
    623644    # Add in some extra attributes which aren't actually configuration values  
    624645    yumconf.yumvar = vars 
  • yum-2.9.6/yum/__init__.py

    old new  
    171171        # (typically /etc/yum.repos.d and /etc/yum/repos.d) 
    172172        parser = config.IncludedDirConfigParser(vars=self.yumvar) 
    173173        for reposdir in self.conf.reposdir: 
    174             if os.path.exists(self.conf.installroot+'/'+reposdir): 
    175                 reposdir = self.conf.installroot + '/' + reposdir 
     174            reposdir  = self.conf.getRootedPath(reposdir) 
    176175 
    177176            if os.path.isdir(reposdir): 
    178177                #XXX: why can't we just pass the list of files? 
     
    502501             
    503502        self.verbose_logger.log(logginglevels.INFO_2, 'Finished') 
    504503         
    505     def doLock(self, lockfile): 
     504    def doLock(self): 
    506505        """perform the yum locking, raise yum-based exceptions, not OSErrors""" 
    507506         
    508507        # if we're not root then we don't lock - just return nicely 
    509508        if self.conf.uid != 0: 
    510509            return 
    511510             
    512         root = self.conf.installroot 
    513         lockfile = root + '/' + lockfile # lock in the chroot 
    514         lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra / 
     511        lockfile = self.conf.lockfile 
    515512         
    516513        mypid=str(os.getpid())     
    517514        while not self._lock(lockfile, mypid, 0644): 
     
    537540                    msg = 'Existing lock %s: another copy is running. Aborting.' % lockfile 
    538541                    raise Errors.LockError(0, msg) 
    539542     
    540     def doUnlock(self, lockfile): 
     543    def doUnlock(self): 
    541544        """do the unlock for yum""" 
    542545         
    543546        # if we're not root then we don't lock - just return nicely 
    544547        if self.conf.uid != 0: 
    545548            return 
    546549         
    547         root = self.conf.installroot 
    548         lockfile = root + '/' + lockfile # lock in the chroot 
     550        lockfile=self.conf.lockfile 
    549551         
    550552        self._unlock(lockfile) 
    551553         
  • yum-2.9.6/yummain.py

    old new  
    6262    def unlock(): 
    6363        try: 
    6464            base.closeRpmDB() 
    65             base.doUnlock(YUM_PID_FILE
     65            base.doUnlock(
    6666        except Errors.LockError, e: 
    6767            sys.exit(200) 
    6868 
     
    8888    except Errors.YumBaseError, e: 
    8989        exFatal(e) 
    9090    try: 
    91         base.doLock(YUM_PID_FILE
     91        base.doLock(
    9292    except Errors.LockError, e: 
    9393        logger.critical('%s', e.msg) 
    9494        sys.exit(200) 
Note: See TracBrowser for help on using the browser.