SOURCES: yum-chroot.patch - update from AC-branch

glen glen at pld-linux.org
Wed Dec 26 17:27:26 CET 2007


Author: glen                         Date: Wed Dec 26 16:27:26 2007 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- update from AC-branch

---- Files affected:
SOURCES:
   yum-chroot.patch (1.4 -> 1.5) 

---- Diffs:

================================================================
Index: SOURCES/yum-chroot.patch
diff -u SOURCES/yum-chroot.patch:1.4 SOURCES/yum-chroot.patch:1.5
--- SOURCES/yum-chroot.patch:1.4	Mon Dec 17 09:07:45 2007
+++ SOURCES/yum-chroot.patch	Wed Dec 26 17:27:20 2007
@@ -1,132 +1,57 @@
---- yum-2.3.4/docs/yum.conf.5.chroot
-+++ yum-2.3.4/docs/yum.conf.5
-@@ -23,8 +23,10 @@
- following options:
- 
- .IP \fBcachedir\fR
--Directory where yum should store its cache and db files. The default is
--`/var/cache/yum'.
-+Directory where yum should store its cache and db files. The default
-+is `/var/cache/yum'. Unless the prefixes `hostfs://' or `chrootfs://'
-+are used, some magic will be applied to determine the real path in
-+combination with `--installroot'.
- 
- .IP \fBreposdir\fR
- A list of directories where yum should look for .repo files which define
-@@ -34,6 +36,10 @@
- repositories defined in /etc/yum.conf to form the complete set of repositories
- that yum will use.
- 
-+Unless the prefixes `hostfs://' or `chrootfs://' are used, some magic
-+will be applied to determine the real path in combination with
-+`--installroot'.
-+
- .IP \fBdebuglevel\fR
- Debug message output level. Practical range is 0\-10. Default is `2'.
- 
-@@ -41,7 +47,10 @@
- Error message output level. Practical range is 0\-10. Default is `2'.
- 
- .IP \fBlogfile\fR
--Full directory and file name for where yum should write its log file.
-+Full directory and file name for where yum should write its log
-+file. Unless the prefixes `hostfs://' or `chrootfs://' are used,
-+some magic will be applied to determine the real path in combination
-+with `--installroot'.
- 
- .IP \fBgpgcheck\fR
- Either `1' or `0'. This tells yum whether or not it should perform a GPG
---- yum-2.3.4/yum/__init__.py.chroot
-+++ yum-2.3.4/yum/__init__.py
-@@ -102,9 +102,8 @@
-         # read each of them in using confpp, then parse them same as any other repo
-         # section - as above.
+--- yum-3.2.4/yum/__init__.py.chroot
++++ yum-3.2.4/yum/__init__.py
+@@ -214,8 +214,7 @@ class YumBase(depsolve.Depsolve):
+         repo_config_age = self.conf.config_file_age
+         
          for reposdir in self.conf.reposdir:
--            if os.path.exists(self.conf.installroot + '/' + reposdir):
+-            if os.path.exists(self.conf.installroot+'/'+reposdir):
 -                reposdir = self.conf.installroot + '/' + reposdir
--            
 +            reposdir  = self.conf.getRootedPath(reposdir)
-+
+ 
              if os.path.isdir(reposdir):
-                 repofn = glob.glob(reposdir+'/*.repo')
-                 repofn.sort()
-@@ -426,18 +425,20 @@
-         self.pkgSack.excludeArchs(archlist)
-         self.log(3, 'Finished')
-         
-+    def __getLockfileName(self):
-+        lockfile = self.conf.configdata['lockfile']
-+        return self.conf.getRootedPath(lockfile,
-+                                       enforce_default  = True,
-+                                       defaults_to_host = False)
-         
--        
--    def doLock(self, lockfile):
-+    def doLock(self):
-         """perform the yum locking, raise yum-based exceptions, not OSErrors"""
-         
+                 for repofn in glob.glob('%s/*.repo' % reposdir):
+@@ -664,11 +663,9 @@ class YumBase(depsolve.Depsolve):
          # if we're not root then we don't lock - just return nicely
-         if self.conf.getConfigOption('uid') != 0:
+         if self.conf.uid != 0:
              return
-             
+-            
 -        root = self.conf.installroot
 -        lockfile = root + '/' + lockfile # lock in the chroot
 -        lockfile = os.path.normpath(lockfile) # get rid of silly preceding extra /
-+        lockfile = self.__getLockfileName()
-         
+-        
++
++        lockfile = self.conf.lockfile
++
          mypid=str(os.getpid())    
          while not self._lock(lockfile, mypid, 0644):
-@@ -461,15 +462,14 @@
-                     msg = 'Existing lock %s: another copy is running. Aborting.' % lockfile
-                     raise Errors.LockError(0, msg)
-     
--    def doUnlock(self, lockfile):
-+    def doUnlock(self):
-         """do the unlock for yum"""
-         
-         # if we're not root then we don't lock - just return nicely
-         if self.conf.getConfigOption('uid') != 0:
+             fd = open(lockfile, 'r')
+@@ -700,9 +697,8 @@ class YumBase(depsolve.Depsolve):
+         if self.conf.uid != 0:
              return
          
 -        root = self.conf.installroot
 -        lockfile = root + '/' + lockfile # lock in the chroot
-+        lockfile=self.__getLockfileName()
-         
+-        
++        lockfile=self.conf.lockfile
++
          self._unlock(lockfile)
          
---- yum-2.3.4/yum/config.py.chroot
-+++ yum-2.3.4/yum/config.py
-@@ -205,7 +205,8 @@
-                       
-         #defaults -either get them or set them
-         optionstrings = [('cachedir', '/var/cache/yum'), 
--                         ('logfile', '/var/log/yum.log'), 
-+                         ('logfile', '/var/log/yum.log'),
-+                         ('lockfile', '/var/run/yum.pid'),
-                          ('reposdir', ['/etc/yum/repos.d', '/etc/yum.repos.d']),
-                          ('syslog_ident', None),
-                          ('syslog_facility', 'LOG_USER'),
-@@ -318,9 +319,7 @@
- 
-         # do the dirs - set the root if there is one (grumble)
-         for option in ['cachedir', 'logfile']:
--            path = self.configdata[option]
--            root = self.configdata['installroot']
--            rootedpath = root + path
-+            rootedpath = self.getRootedPath(self.configdata[option])
-             self.configdata[option] = rootedpath
-             setattr(self, option, rootedpath)
-         
-@@ -358,6 +357,23 @@
-                         "All plugin search paths must be absolute")
- 
+     def _lock(self, filename, contents='', mode=0777):
+--- yum-3.2.4/yum/config.py.chroot
++++ yum-3.2.4/yum/config.py
+@@ -469,6 +469,26 @@ class StartupConf(BaseConfig):
+     pluginpath = ListOption(['/usr/share/yum-plugins', '/usr/lib/yum-plugins'])
+     pluginconfpath = ListOption(['/etc/yum/pluginconf.d'])
  
 +    def getRootedPath(self, path, enforce_default=False, defaults_to_host=False):
-+	instroot = self.configdata['installroot']
++        instroot = getattr(self, 'installroot', None)
++        if instroot==None:
++            return path
++
 +        if   path.startswith('hostfs://'):   res = path[9:]
 +        elif path.startswith('chrootfs://'): res = instroot + '/' + path[11:]
 +        else:
-+	    tmp = instroot + '/' +path
++            tmp = instroot + '/' + path
 +
 +            if enforce_default:
 +                if defaults_to_host:    res = path
@@ -136,64 +61,98 @@
 +                elif defaults_to_host:  res = path
 +                else:                   res = tmp
 +
-+	return res
++        return res
 +
-     def listConfigOptions(self):
-         """return list of options available for global config"""
-         return self.configdata.keys()
-@@ -749,8 +765,7 @@
- 
-     reposdirs = []
-     for dir in conf.reposdir:
--        if os.path.exists(conf.installroot + '/' + dir):
--            reposdirs.append(conf.installroot + '/' + dir)
-+        reposdirs.append(conf.getRootedPath(dir))
- 
-     repofn = []
-     for reposdir in reposdirs:
---- yum-2.3.4/cli.py.chroot
-+++ yum-2.3.4/cli.py
-@@ -105,7 +105,7 @@
-                 action="store_true", default=False, 
-                 help="run entirely from cache, don't update cache")
-         self.optparser.add_option("-c", "", dest="conffile", action="store", 
--                default='/etc/yum.conf', help="config file location", 
-+                default=None, help="config file location", 
-                 metavar=' [config file]')
-         self.optparser.add_option("-R", "", dest="sleeptime", action="store", 
-                 type='int', default=None, help="maximum command wait time",
-@@ -158,9 +158,12 @@
-         try: 
-             # If the conf file is inside the  installroot - use that.
-             # otherwise look for it in the normal root
--            if opts.installroot:
--                if os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
-+            if opts.conffile==None:
-+                opts.conffile = '/etc/yum.conf'
-+                if opts.installroot and os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
-                     opts.conffile = opts.installroot+'/'+opts.conffile
+ class YumConf(StartupConf):
+     '''
+     Configuration option definitions for yum.conf\'s [main] section.
+@@ -482,6 +502,7 @@ class YumConf(StartupConf):
+     persistdir = Option('/var/lib/yum')
+     keepcache = BoolOption(True)
+     logfile = Option('/var/log/yum.log')
++    lockfile = Option('/var/run/yum.pid')
+     reposdir = ListOption(['/etc/yum/repos.d', '/etc/yum.repos.d'])
+     syslog_ident = Option()
+     syslog_facility = Option('LOG_DAEMON')
+@@ -615,9 +636,9 @@ def readMainConfig(startupconf):
+     yumconf.populate(startupconf._parser, 'main')
+ 
+     # Apply the installroot to directory options
+-    for option in ('cachedir', 'logfile', 'persistdir'):
++    for option in ('cachedir', 'logfile', 'persistdir', 'lockfile'):
+         path = getattr(yumconf, option)
+-        setattr(yumconf, option, yumconf.installroot + path)
++        setattr(yumconf, option, yumconf.getRootedPath(path))
+     
+     # Add in some extra attributes which aren't actually configuration values 
+     yumconf.yumvar = yumvars
+--- yum-3.2.4/docs/yum.conf.5.chroot
++++ yum-3.2.4/docs/yum.conf.5
+@@ -23,8 +23,10 @@ The [main] section must exist for yum to
+ following options:
+ 
+ .IP \fBcachedir\fR
+-Directory where yum should store its cache and db files. The default is
+-`/var/cache/yum'.
++Directory where yum should store its cache and db files. The default
++is `/var/cache/yum'. Unless the prefixes `hostfs://' or `chrootfs://'
++are used, some magic will be applied to determine the real path in
++combination with `--installroot'.
+ 
+ .IP \fBpersistdir\fR
+ Directory where yum should store information that should persist over multiple
+@@ -44,6 +46,10 @@ documented in \fB[repository] options\fR
+ repositories defined in /etc/yum/yum.conf to form the complete set of
+ repositories that yum will use.
+ 
++Unless the prefixes `hostfs://' or `chrootfs://' are used, some magic
++will be applied to determine the real path in combination with
++`--installroot'.
 +
+ .IP \fBdebuglevel\fR
+ Debug message output level. Practical range is 0\-10. Default is `2'.
+ 
+@@ -51,7 +57,10 @@ Debug message output level. Practical ra
+ Error message output level. Practical range is 0\-10. Default is `2'.
+ 
+ .IP \fBlogfile\fR
+-Full directory and file name for where yum should write its log file.
++Full directory and file name for where yum should write its log
++file. Unless the prefixes `hostfs://' or `chrootfs://' are used,
++some magic will be applied to determine the real path in combination
++with `--installroot'.
+ 
+ .IP \fBgpgcheck\fR
+ Either `1' or `0'. This tells yum whether or not it should perform a GPG
+--- yum-3.2.4/cli.py.chroot
++++ yum-3.2.4/cli.py
+@@ -1204,13 +1204,14 @@ class YumOptionParser(OptionParser):
+     def getRoot(self,opts):
+         # If the conf file is inside the  installroot - use that.
+         # otherwise look for it in the normal root
++        if opts.conffile==None:
++            opts.conffile = '/etc/yum/yum.conf'
 +            if opts.installroot:
-                 root=opts.installroot
-             else:
-                 root = '/'
---- yum-2.3.4/yummain.py.chroot
-+++ yum-2.3.4/yummain.py
-@@ -60,7 +60,7 @@
-     def unlock():
-         try:
-             base.closeRpmDB()
--            base.doUnlock(YUM_PID_FILE)
-+            base.doUnlock()
-         except Errors.LockError, e:
-             sys.exit(200)
- 
-@@ -78,7 +78,7 @@
-     except Errors.YumBaseError, e:
-         exFatal(e)
-     try:
--        base.doLock(YUM_PID_FILE)
-+        base.doLock()
-     except Errors.LockError, e:
-         base.errorlog(0,'%s' % e.msg)
-         sys.exit(200)
++                if os.access(opts.installroot+opts.conffile, os.R_OK):
++                    opts.conffile = opts.installroot+opts.conffile
++                elif os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
++                    opts.conffile = opts.installroot+'/etc/yum.conf'
+         if opts.installroot:
+-            if os.access(opts.installroot+'/'+opts.conffile, os.R_OK):
+-                opts.conffile = opts.installroot+'/'+opts.conffile
+-            elif opts.conffile == '/etc/yum/yum.conf':
+-                # check if /installroot/etc/yum.conf exists.
+-                if os.access(opts.installroot+'/etc/yum.conf', os.R_OK):
+-                    opts.conffile = opts.installroot+'/etc/yum.conf'         
+             root=opts.installroot
+         else:
+             root = '/'
+@@ -1231,7 +1232,7 @@ class YumOptionParser(OptionParser):
+                 help="be tolerant of errors")
+         self.add_option("-C", dest="cacheonly", action="store_true",
+                 help="run entirely from cache, don't update cache")
+-        self.add_option("-c", dest="conffile", default='/etc/yum/yum.conf',
++        self.add_option("-c", dest="conffile", default=None,
+                 help="config file location", metavar=' [config file]')
+         self.add_option("-R", dest="sleeptime", type='int', default=None,
+                 help="maximum command wait time", metavar=' [minutes]')
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/SOURCES/yum-chroot.patch?r1=1.4&r2=1.5&f=u



More information about the pld-cvs-commit mailing list