Hi Seth,

Attached the util-vserver patch I was talking about, please let me know
what you think and I'll see what I can do to bring it in line.

Regards
Nigel
diff -u -r yum.git/cli.py yum.git.nkukard/cli.py
--- yum.git/cli.py	2007-09-07 17:45:20.000000000 +0000
+++ yum.git.nkukard/cli.py	2007-09-07 18:05:35.000000000 +0000
@@ -1218,13 +1218,14 @@
     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:
+                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 = '/'
@@ -1245,7 +1246,7 @@
                 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]')
diff -u -r yum.git/docs/yum.conf.5 yum.git.nkukard/docs/yum.conf.5
--- yum.git/docs/yum.conf.5	2007-09-07 17:45:20.000000000 +0000
+++ yum.git.nkukard/docs/yum.conf.5	2007-09-07 18:05:35.000000000 +0000
@@ -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 \fBpersistdir\fR
 Directory where yum should store information that should persist over multiple
@@ -44,6 +46,10 @@
 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 @@
 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
diff -u -r yum.git/yum/__init__.py yum.git.nkukard/yum/__init__.py
--- yum.git/yum/__init__.py	2007-09-07 17:45:20.000000000 +0000
+++ yum.git.nkukard/yum/__init__.py	2007-09-07 18:05:35.000000000 +0000
@@ -214,8 +214,7 @@
         repo_config_age = self.conf.config_file_age
         
         for reposdir in self.conf.reposdir:
-            if os.path.exists(self.conf.installroot+'/'+reposdir):
-                reposdir = self.conf.installroot + '/' + reposdir
+            reposdir  = self.conf.getRootedPath(reposdir)
 
             if os.path.isdir(reposdir):
                 for repofn in glob.glob('%s/*.repo' % reposdir):
@@ -668,11 +667,9 @@
         # if we're not root then we don't lock - just return nicely
         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.conf.lockfile
+
         mypid=str(os.getpid())    
         while not self._lock(lockfile, mypid, 0644):
             fd = open(lockfile, 'r')
@@ -704,9 +701,8 @@
         if self.conf.uid != 0:
             return
         
-        root = self.conf.installroot
-        lockfile = root + '/' + lockfile # lock in the chroot
-        
+        lockfile=self.conf.lockfile
+
         self._unlock(lockfile)
         
     def _lock(self, filename, contents='', mode=0777):
diff -u -r yum.git/yum/config.py yum.git.nkukard/yum/config.py
--- yum.git/yum/config.py	2007-09-07 17:45:20.000000000 +0000
+++ yum.git.nkukard/yum/config.py	2007-09-07 18:05:35.000000000 +0000
@@ -469,6 +469,26 @@
     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 = 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
+
+            if enforce_default:
+                if defaults_to_host:    res = path
+                else:                   res = tmp
+            else:
+                if os.path.exists(tmp): res = tmp
+                elif defaults_to_host:  res = path
+                else:                   res = tmp
+
+        return res
+
 class YumConf(StartupConf):
     '''
     Configuration option definitions for yum.conf\'s [main] section.
@@ -482,6 +502,7 @@
     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,7 +636,7 @@
     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)
     

Attachment: signature.asc
Description: OpenPGP digital signature

_______________________________________________
Yum-devel mailing list
[email protected]
https://lists.dulug.duke.edu/mailman/listinfo/yum-devel

Reply via email to