[yum-cvs] yum/rpmUtils updates.py,1.22,1.22.2.1

Seth Vidal skvidal at linux.duke.edu
Wed May 24 07:05:04 UTC 2006


Update of /home/groups/yum/cvs/yum/rpmUtils
In directory login1.linux.duke.edu:/tmp/cvs-serv25363/rpmUtils

Modified Files:
      Tag: yum-2_6_X
	updates.py 
Log Message:

if a user wants to install package foo and package foo is obsoleted by bar
install bar instead.


Index: updates.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/rpmUtils/updates.py,v
retrieving revision 1.22
retrieving revision 1.22.2.1
diff -u -r1.22 -r1.22.2.1
--- updates.py	20 Nov 2005 09:15:55 -0000	1.22
+++ updates.py	24 May 2006 07:05:02 -0000	1.22.2.1
@@ -127,6 +127,57 @@
             if len(self.updatesdict[tup]) > 1:
                 mylist = self.updatesdict[tup]
                 self.updatesdict[tup] = rpmUtils.miscutils.unique(mylist)
+    
+    
+    def checkForObsolete(self, pkglist, newest=1):
+        """accept a list of packages to check to see if anything obsoletes them
+           return an obsoleted_dict in the format of makeObsoletedDict"""
+           
+        obsdict = {} # obseleting package -> [obsoleted package]
+        pkgdict = self.makeNADict(pkglist, 1)
+        
+        # this needs to keep arch in mind
+        # if foo.i386 obsoletes bar
+        # it needs to obsoletes bar.i386 preferentially, not bar.x86_64
+        # if there is only one bar and only one foo then obsolete it, but try to
+        # match the arch.
+        
+        # look through all the obsoleting packages look for multiple archs per name
+        # if you find it look for the packages they obsolete
+        # 
+        for pkgtup in self.rawobsoletes.keys():
+            (name, arch, epoch, ver, rel) = pkgtup
+            for (obs_n, flag, (obs_e, obs_v, obs_r)) in self.rawobsoletes[(pkgtup)]:
+                if flag in [None, 0]: # unversioned obsolete
+                    if pkgdict.has_key((obs_n, None)):
+                        for (rpm_a, rpm_e, rpm_v, rpm_r) in pkgdict[(obs_n, None)]:
+                            if not obsdict.has_key(pkgtup):
+                                obsdict[pkgtup] = []
+                            obsdict[pkgtup].append((obs_n, rpm_a, rpm_e, rpm_v, rpm_r))
+
+                else: # versioned obsolete
+                    if pkgdict.has_key((obs_n, None)):
+                        for (rpm_a, rpm_e, rpm_v, rpm_r) in pkgdict[(obs_n, None)]:
+                            if rpmUtils.miscutils.rangeCheck((obs_n, flag, (obs_e, \
+                                                        obs_v, obs_r)), (obs_n,\
+                                                        rpm_a, rpm_e, rpm_v, rpm_r)):
+                                # make sure the obsoleting pkg is not already installed
+                                if not obsdict.has_key(pkgtup):
+                                    obsdict[pkgtup] = []
+                                obsdict[pkgtup].append((obs_n, rpm_a, rpm_e, rpm_v, rpm_r))
+        
+        obslist = obsdict.keys()
+        if newest:
+            obslist = self._reduceListNewestByNameArch(obslist)
+
+        returndict = {}
+        for new in obslist:
+            for old in obsdict[new]:
+                if not returndict.has_key(old):
+                    returndict[old] = []
+                returndict[old].append(new)
+        
+        return returndict
         
     def doObsoletes(self):
         """figures out what things available obsolete things installed, returns




More information about the Yum-cvs-commits mailing list