[Patch] Re: [Yum-devel] YumInstalledPackage

Jack Neely jjneely at pams.ncsu.edu
Tue Jan 31 04:07:54 UTC 2006


Paul,

Attached is the code I was playing with.  I'm working with code for
kernel module handling which compares specific Requires of kernel module
packages.  (Do they require the same kernel?)  The method that you and I
mucked with a bit doesn't quite cut it.  The meta data that gets
populated into YumAvailablePackage looks like:

    (name, type, (epoch, version, release))

where type is 'EQ', "LT', etc.  Getting that info out of RPM gives me

    (name, code, "e:v-r")

I don't want to parse that.  I don't want to duplicate the code that
does it in createrepo.  In this case its not too hard to parse, but
*sigh*.

Jack
-- 
Jack Neely <jjneely at ncsu.edu>
Campus Linux Services Project Lead
PAMS Computer Operations at NC State University
GPG Fingerprint: 1917 5AC1 E828 9337 7AA4  EA6B 213B 765F 3B6A 5B89
-------------- next part --------------
? yum/kernel-module.ipatch
Index: yum/config.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/config.py,v
retrieving revision 1.91
diff -u -r1.91 config.py
--- yum/config.py	26 Jan 2006 04:08:23 -0000	1.91
+++ yum/config.py	31 Jan 2006 03:57:44 -0000
@@ -486,7 +486,7 @@
     proxy_password = Option()
     pluginpath = ListOption(['/usr/lib/yum-plugins'])
     installonlypkgs = ListOption(['kernel', 'kernel-bigmem',
-            'kernel-enterprise','kernel-smp', 'kernel-modules', 'kernel-debug',
+            'kernel-enterprise','kernel-smp', 'kernel-module', 'kernel-debug',
             'kernel-unsupported', 'kernel-source', 'kernel-devel'])
     kernelpkgnames = ListOption(['kernel','kernel-smp', 'kernel-enterprise',
             'kernel-bigmem', 'kernel-BOOT'])
Index: yum/packages.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/yum/packages.py,v
retrieving revision 1.43
diff -u -r1.43 packages.py
--- yum/packages.py	5 Jan 2006 01:30:35 -0000	1.43
+++ yum/packages.py	31 Jan 2006 03:57:44 -0000
@@ -311,10 +311,15 @@
             
 
 
-class YumInstalledPackage(YumAvailablePackage):
+class YumInstalledPackage(repomd.packageObject.PackageObject, 
+                          repomd.packageObject.RpmBase):
     """super class for dealing with packages in the rpmdb"""
+    
     def __init__(self, hdr):
         """hand in an rpm header, we'll assume it's installed and query from there"""
+        repomd.packageObject.PackageObject.__init__(self)
+        repomd.packageObject.RpmBase.__init__(self)
+        
         self.hdr = hdr
         self.name = self.tagByName('name')
         self.arch = self.tagByName('arch')
@@ -329,6 +334,19 @@
         self.description = self.tagByName('description')
         self.pkgid = self.tagByName(rpm.RPMTAG_SHA1HEADER)
         self.state = None
+        self.populatePRCO()
+        
+    def populatePRCO(self):
+        prco = ["provide", "require", "conflict", "obsolete"]
+        for dep in prco:
+            n = self.tagByName(dep+"name")
+            f = self.tagByName(dep+"flags")
+            v = self.tagByName(dep+"version")
+
+            if n != None:
+                r = zip(n, f, v)
+
+            self.prco[dep+"s"] = r
         
     def __str__(self):
         if self.epoch == '0':


More information about the Yum-devel mailing list