[Yum] a few patches..

Dan Burcaw dburcaw at terrasoftsolutions.com
Sat Jun 14 06:23:11 UTC 2003



Mostly minor fixes, or ppc items.. but.. I also added --installroot 
support. So, you can now do:


yum --installroot=/mychroot groupinstall "Workstation"


Hot damn,
Dan
-------------- next part --------------
Seth,

This patch adds yaboot support (via grubby) and handles ppc (mac)
kernel names (vmlinux vs vmlinuz). I also added common kernel
package names on Yellow Dog for ppc.  The later part does not
need to be applied if you don't want to, but like the Red Hat
defaults, it may be a suitable thing to contain.


diff -uN yum-1.98.orig/checkbootloader.py yum-1.98/checkbootloader.py
--- yum-1.98.orig/checkbootloader.py	2003-05-31 21:33:33.000000000 -0600
+++ yum-1.98/checkbootloader.py	2003-06-13 23:05:36.000000000 -0600
@@ -21,6 +21,7 @@
 
 grubConfigFile = "/boot/grub/grub.conf"
 liloConfigFile = "/etc/lilo.conf"
+yabootConfigFile = "/etc/yaboot.conf"
 
 
 # XXX: this is cut and pasted directly from booty/bootloaderInfo.py
@@ -131,6 +132,8 @@
         haveGrubConf = 0
     if not os.access(instRoot + liloConfigFile, os.R_OK):
         haveLiloConf = 0
+    if not os.access(instRoot + yabootConfigFile, os.R_OK):
+        haveYabootConf = 0
 
     if haveGrubConf:
         f = open(grubConfigFile, "r")
@@ -158,6 +161,14 @@
         if block[6:10] == "LILO":
             return "LILO"
 
+    if haveYabootConf:
+        f = open(yabootConfigFile, "r")
+        lines = f.readlines()
+        for line in lines:
+            if line[0:5] == "boot=":
+                bootDev = line[5:-1]
+                return "YABOOT"
+
 
 if __name__ == "__main__":
     bootloader = whichBootLoader()
diff -uN yum-1.98.orig/grubcfg.py yum-1.98/grubcfg.py
--- yum-1.98.orig/grubcfg.py	2003-05-31 21:33:33.000000000 -0600
+++ yum-1.98/grubcfg.py	2003-06-11 12:20:09.000000000 -0600
@@ -36,8 +36,13 @@
     return ret
 
 def setDefault(newImage):
+    if iutil.getArch() == "ppc":
+       kernName = "vmlinux"
+    else:
+       kernName = "vmlinuz"
+
     try:
-        ret = iutil.execWithRedirect("/sbin/grubby", ["grubby", "--set-default", "/boot/vmlinuz-%s" % newImage])
+        ret = iutil.execWithRedirect("/sbin/grubby", ["grubby", "--set-default", "/boot/%s-%s" %(kernName, newImage)])
     except RuntimeError, command:
         raise GrubbyRuntimeError("unable to run grubby. Not running as root?")
 
diff -uN yum-1.98.orig/pkgaction.py yum-1.98/pkgaction.py
--- yum-1.98.orig/pkgaction.py	2003-05-31 21:33:33.000000000 -0600
+++ yum-1.98/pkgaction.py	2003-06-11 12:21:43.000000000 -0600
@@ -461,7 +461,8 @@
     for (name,arch) in tsnevral.NAkeys():
         s = tsnevral.state(name,arch)
         if s in ['i','u','ud','iu']:
-            if name in ['kernel','kernel-smp','kernel-enterprise','kernel-bigmem','kernel-BOOT']:
+            if name in ['kernel','kernel-smp','kernel-enterprise','kernel-bigmem','kernel-BOOT',
+			'kernel-ans', 'kernel-briq', 'kernel-pseries', 'kernel-iseries', 'kernel-teron']:
                 hdr=tsnevral.getHeader(name,arch)
                 if "kernel-smp" in hdr[rpm.RPMTAG_PROVIDES]:
                     extraInfo = "kernel-smp"
@@ -471,6 +472,16 @@
                     extraInfo = "kernel-bigmem"
                 elif "kernel-BOOT" in hdr[rpm.RPMTAG_PROVIDES]:
                     extraInfo = "kernel-BOOT"    
+                elif "kernel-ans" in hdr[rpm.RPMTAG_PROVIDES]:
+                    extraInfo = "kernel-ans"
+                elif "kernel-briq" in hdr[rpm.RPMTAG_PROVIDES]:
+                    extraInfo = "kernel-briq"
+                elif "kernel-pseries" in hdr[rpm.RPMTAG_PROVIDES]:
+                    extraInfo = "kernel-pseries"
+                elif "kernel-iseries" in hdr[rpm.RPMTAG_PROVIDES]:
+                    extraInfo = "kernel-iseries"
+                elif "kernel-teron" in hdr[rpm.RPMTAG_PROVIDES]:
+                    extraInfo = "kernel-teron"
                 else:
                     extraInfo = "kernel"
 
@@ -487,6 +498,16 @@
                     infoString = "bigmem"  
                 elif extraInfo == "kernel-smp":
                     infoString = "smp"
+                elif extraInfo == "kernel-ans":
+                    infoString = "ans"
+                elif extraInfo == "kernel-briq":
+                    infoString = "briq"
+                elif extraInfo == "kernel-pseries":
+                    infoString = "pseries"
+                elif extraInfo == "kernel-iseries":
+                    infoString = "iseries"
+                elif extraInfo == "kernel-teron":
+                    infoString = "teron"
                 else:
                     infoString = ""
                 verRel = "%s-%s%s" % (hdr[rpm.RPMTAG_VERSION], hdr[rpm.RPMTAG_RELEASE],infoString)
@@ -520,6 +541,9 @@
             #to put the kernels in the right order
             log(2, _('Grub found - making this kernel the default'))
             up2datetheft.install_grub(kernel_list)
+        elif bootloader == "YABOOT":
+            log(2, 'Yaboot found - adding kernel to yaboot and making it the default')
+            up2datetheft.install_grub(kernel_list)
         else:
             errorlog(1, _('No bootloader found, Cannot configure kernel, continuing.'))
             filelog(1, 'No bootloader found, Cannot configure kernel.')
-------------- next part --------------
Seth,

This patch only tries to open conf.logfile if the
file exists.  Otherwise, Logger() gives a really
bizarre IOError that makes no sense.  Perhaps
that exception should be fixed as well.

Also, I have rpm -vv being turned on if the
conf.debuglevel >= 2.  You may not want to accept
this piece, but I found it handy when debugging
installroot support.


diff -uNr yum-1.98.orig/yummain.py yum-1.98/yummain.py
--- yum-1.98.orig/yummain.py	2003-05-31 21:33:33.000000000 -0600
+++ yum-1.98/yummain.py	2003-06-13 23:36:10.000000000 -0600
@@ -71,7 +76,7 @@
         # we'd like to have a log object now
         log=Logger(threshold=conf.debuglevel, file_object=sys.stdout)
         # syslog-style log
-        if conf.uid == 0:
+        if conf.uid == 0 and os.access(conf.logfile, os.R_OK):
             logfile=open(conf.logfile,"a")
             filelog=Logger(threshold=10, file_object=logfile,preprefix=clientStuff.printtime())
         else:
@@ -145,7 +153,11 @@
     pkgaction.conf = conf
     callback.conf = conf
     rpmUtils.conf = conf
-    
+
+    # same as rpm -vv
+    if conf.debuglevel >= 2:    
+        rpm.setVerbosity(7)
+
     # get our ts together that we'll use all over the place
     ts = rpmUtils.Rpm_Ts_Work()
     ts.sigChecking('none')
-------------- next part --------------
--- yum-1.98.orig/AUTHORS	2003-05-31 21:33:33.000000000 -0600
+++ yum-1.98/AUTHORS	2003-06-13 21:53:52.000000000 -0600
@@ -16,11 +16,11 @@
     Robert G. Brown <rgb at phy.duke.edu>
     Hollis Blanchard
     Grigory Bakunov <black at asplinux.ru>
-    
+    Dan Burcaw <dburcaw at terrasoftsolutions.com>
     
 Original Yup people:
-    Bryan Stillwell <bstill at terraplex.com>. 
+    Bryan Stillwell
     Stephen Edie
-    Dan Burcaw <dburcaw at yellowdoglinux.com>
-    Troy Bengegerdes <troy at blacklablinux.com> 
+    Dan Burcaw
+    Troy Bengegerdes
 
-------------- next part --------------
Seth,

This patch adds ppc as a most-significant-bit architecture 
(big endian). Also, I removed getArch() as it is already in
iutil. No need to have two of the same functions.

--- yum-1.98.orig/translate.py	2003-05-31 21:33:33.000000000 -0600
+++ yum-1.98/translate.py	2003-06-13 23:51:16.000000000 -0600
@@ -4,6 +4,7 @@
 # $Id: translate.py,v 1.2.2.1 2003/05/21 21:33:41 skvidal Exp $
 
 import os, string
+from iutil import getArch
 
 prefix = '/usr'
 localedir = prefix + '/share/locale'
@@ -241,20 +242,10 @@
                 lang.append(nl)
     return lang
 
-def getArch ():
-    arch = os.uname ()[4]
-    if (len (arch) == 4 and arch[0] == 'i' and arch[2:4] == "86"):
-        arch = "i386"
-
-    if arch == "sparc64":
-        arch = "sparc"
-
-    return arch
-
 ###################################################################
 # Now the real module code
 
-if getArch() == 'sparc':
+if getArch() == 'sparc' or getArch() == 'ppc':
     _gettext_byteorder = 'msb'
 else:
     _gettext_byteorder = 'lsb'
-------------- next part --------------
Seth,

This patch adds chroot support via --installroot.  It also
adds the yum.conf option installroot.

diff -uNr yum-1.98.orig/clientStuff.py yum-1.98/clientStuff.py
--- yum-1.98.orig/clientStuff.py	2003-05-31 21:33:33.000000000 -0600
+++ yum-1.98/clientStuff.py	2003-06-13 19:43:24.000000000 -0600
@@ -836,7 +836,7 @@
 
 def create_final_ts(tsInfo):
     # download the pkgs to the local paths and add them to final transaction set
-    tsfin = rpm.TransactionSet('/')
+    tsfin = rpm.TransactionSet(conf.instroot)
     for (name, arch) in tsInfo.NAkeys():
         pkghdr = tsInfo.getHeader(name, arch)
         rpmloc = tsInfo.localRpmPath(name, arch)
diff -uNr yum-1.98.orig/config.py yum-1.98/config.py
--- yum-1.98.orig/config.py	2003-05-31 21:33:33.000000000 -0600
+++ yum-1.98/config.py	2003-06-13 23:19:39.000000000 -0600
@@ -79,7 +80,8 @@
         releasever = None
         self.bandwidth = None
         self.throttle = None
-        
+        self.installroot = '/'
+      
         if self._getoption('main','cachedir') != None:
             self.cachedir = self._getoption('main','cachedir')
         if self._getoption('main','debuglevel') != None:
@@ -106,6 +108,8 @@
             self.bandwidth = self._getoption('main','bandwidth')
         if self._getoption('main', 'throttle') != None:
             self.throttle = self._getoption('main','throttle')
+        if self._getoption('main', 'installroot') != None:
+            self.throttle = self._getoption('main','installroot')
 
         # figure out what the releasever really is from the distroverpkg
         self.yumvar['releasever'] = self._getsysver(self.distroverpkg)
diff -uNr yum-1.98.orig/depchecktree.py yum-1.98/depchecktree.py
--- yum-1.98.orig/depchecktree.py	2003-05-31 21:33:33.000000000 -0600
+++ yum-1.98/depchecktree.py	2003-06-11 14:17:04.000000000 -0600
@@ -92,7 +92,7 @@
 
 
 def depchecktree(rpmlist):
-    ts = rpm.TransactionSet('/')
+    ts = rpm.TransactionSet(conf.instroot)
     error=0
     msgs=[]
     for rpmfn in rpmlist:
diff -uNr yum-1.98.orig/nevral.py yum-1.98/nevral.py
--- yum-1.98.orig/nevral.py	2003-05-31 21:33:33.000000000 -0600
+++ yum-1.98/nevral.py	2003-06-13 23:16:02.000000000 -0600
@@ -229,8 +229,8 @@
     def populateTs(self, addavailable = 1):
         installonlypkgs = ['kernel', 'kernel-bigmem', 'kernel-enterprise',
                            'kernel-smp', 'kernel-debug']
-                           
-        _ts = rpmUtils.Rpm_Ts_Work('/')
+                     
+        _ts = rpmUtils.Rpm_Ts_Work(conf.instroot)
         for (name, arch) in self.NAkeys(): 
             if self.state(name, arch) in ('u','ud','iu'):
                 log(4,'Updating: %s, %s' % (name, arch))
diff -uNr yum-1.98.orig/rpmUtils.py yum-1.98/rpmUtils.py
--- yum-1.98.orig/rpmUtils.py	2003-05-31 21:33:33.000000000 -0600
+++ yum-1.98/rpmUtils.py	2003-06-13 22:17:08.000000000 -0600
@@ -103,7 +103,7 @@
 
 def openrpmdb():
     try:
-        db = rpm.TransactionSet('/')
+        db = rpm.TransactionSet(conf.instroot)
     except rpm.error, e:
         errorlog(0, _("Could not open RPM database for reading. Perhaps it is already in use?"))
     return db
@@ -217,6 +217,10 @@
     operate with a list of the Base objects above, so I can refer to any one object there
     not sure the best way to do this yet, more thinking involved"""
     def __init__(self, dbPath='/'):
+        if conf.instroot:
+            if conf.instroot != '/':
+                dbPath = conf.instroot
+
         self.ts = rpm.TransactionSet(dbPath)
         
         self.methods = ['addInstall', 'addErase', 'run', 'check', 'order', 'hdrFromFdno',
diff -uNr yum-1.98.orig/yummain.py yum-1.98/yummain.py
--- yum-1.98.orig/yummain.py	2003-05-31 21:33:33.000000000 -0600
+++ yum-1.98/yummain.py	2003-06-13 23:36:10.000000000 -0600
@@ -35,7 +35,7 @@
 
 
 def parseCmdArgs(args):
-    
+   
     # setup our errorlog object 
     errorlog=Logger(threshold=2, file_object=sys.stderr)
 
@@ -45,12 +45,17 @@
         yumconffile="/etc/yum.conf"
         
     try:
-        gopts, cmds = getopt.getopt(args, 'Cc:hR:e:d:y', ['help'])
+        gopts, cmds = getopt.getopt(args, 'Cc:hR:e:d:y:', ['help', 'chroot='])
     except getopt.error, e:
         errorlog(0, _('Options Error: %s') % e)
         usage()
-   
+  
     try: 
+	for o,a in gopts:
+           if o == '--chroot':
+               if os.access(a + "/etc/yum.conf", os.R_OK):
+                   yumconffile=a + '/etc/yum.conf'
+
         for o,a in gopts:
             if o == '-R':
                 sleeptime=random.randrange(int(a)*60)
@@ -71,7 +76,7 @@
         # we'd like to have a log object now
         log=Logger(threshold=conf.debuglevel, file_object=sys.stdout)
         # syslog-style log
-        if conf.uid == 0:
+        if conf.uid == 0 and os.access(conf.logfile, os.R_OK):
             logfile=open(conf.logfile,"a")
             filelog=Logger(threshold=10, file_object=logfile,preprefix=clientStuff.printtime())
         else:
@@ -90,6 +95,9 @@
                 usage()
             if o =='-C':
                 conf.cache=1
+	    if o == '--chroot':
+		conf.instroot=a
+
     except ValueError, e:
         errorlog(0, _('Options Error: %s') % e)
         usage()
@@ -145,7 +153,11 @@
     pkgaction.conf = conf
     callback.conf = conf
     rpmUtils.conf = conf
-    
+
+    # same as rpm -vv
+    if conf.debuglevel >= 2:    
+        rpm.setVerbosity(7)
+
     # get our ts together that we'll use all over the place
     ts = rpmUtils.Rpm_Ts_Work()
     ts.sigChecking('none')
@@ -327,6 +339,7 @@
           -y answer yes to all questions
           -R [time in minutes] - set the max amount of time to randonly run in.
           -C run from cache only - do not update the cache
+	  --installroot [path] - set the install root (default '/')
           -h, --help this screen
     """)
     sys.exit(1)


More information about the Yum mailing list