[yum-cvs] yum cli.py,1.241.2.14,1.241.2.15

Seth Vidal skvidal at linux.duke.edu
Tue Mar 13 03:22:19 UTC 2007


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

Modified Files:
      Tag: yum-3_0_X
	cli.py 
Log Message:

fix-bizarro perl/perl-devel case and a bunch of other similar ones.
fixes rh bug: 231549
thanks to Robin Norwood for the easy replicator.


Index: cli.py
===================================================================
RCS file: /home/groups/yum/cvs/yum/cli.py,v
retrieving revision 1.241.2.14
retrieving revision 1.241.2.15
diff -u -r1.241.2.14 -r1.241.2.15
--- cli.py	7 Mar 2007 20:17:32 -0000	1.241.2.14
+++ cli.py	13 Mar 2007 03:22:17 -0000	1.241.2.15
@@ -556,18 +556,33 @@
                 arg = unmatched[0] #only one in there
                 self.verbose_logger.debug('Checking for virtual provide or file-provide for %s', 
                     arg)
+                # let's make sure we don't have this dep installed already
                 try:
-                    mypkg = self.returnPackageByDep(arg)
+                    my_inst_pkgs = self.returnInstalledPackagesByDep(arg)
+                except yum.Errors.YumBaseError, e:
+                    my_inst_pkgs = []
+
+                if my_inst_pkgs:
+                    self.verbose_logger.log(yum.logginglevels.DEBUG_3,
+                        'Requested dep: %s is provided by installed package', str(arg))
+                    
+                    break # we don't need to look, we have it
+                try:
+                    mypkgs = self.returnPackagesByDep(arg)
                 except yum.Errors.YumBaseError, e:
                     self.logger.critical(_('No Match for argument: %s') % arg)
                 else:
-                    arg = '%s:%s-%s-%s.%s' % (mypkg.epoch, mypkg.name,
-                                              mypkg.version, mypkg.release,
-                                              mypkg.arch)
-                    emtch, mtch, unmtch = self.pkgSack.matchPackageNames([arg])
-                    exactmatch.extend(emtch)
-                    matched.extend(mtch)
-            
+                    for mypkg in mypkgs:
+                        if self._installable(mypkg, True):
+                            self.verbose_logger.log(yum.logginglevels.DEBUG_3,
+                                    'Solving package %s is installable, not going through the rest', mypkg)
+                            exactmatch.append(mypkg)
+                            break
+                        else:
+                            self.verbose_logger.log(yum.logginglevels.DEBUG_3,
+                                    'Solving package %s is not installable, skipping', mypkg)
+                            
+                        
             installable = yum.misc.unique(exactmatch + matched)
             exactarchlist = self.conf.exactarchlist
             
@@ -1122,8 +1137,58 @@
     def shellUsage(self):
         ''' Print out the shell usage '''
         print self.optparser.print_usage()
-            
-            
+    
+    def _installable(self, pkg, ematch=False):
+
+        """check if the package is reasonably installable, true/false"""
+        
+        exactarchlist = self.conf.exactarchlist        
+        # we look through each returned possibility and rule out the
+        # ones that we obviously can't use
+        
+        if self.rpmdb.installed(po=pkg):
+            self.verbose_logger.log(yum.logginglevels.DEBUG_3,
+                'Package %s is already installed, skipping', pkg)
+            return False
+        
+        # everything installed that matches the name
+        installedByKey = self.rpmdb.searchNevra(name=pkg.name)
+        comparable = []
+        for instpo in installedByKey:
+            if rpmUtils.arch.isMultiLibArch(instpo.arch) == rpmUtils.arch.isMultiLibArch(pkg.arch):
+                comparable.append(instpo)
+            else:
+                self.verbose_logger.log(yum.logginglevels.DEBUG_3,
+                    'Discarding non-comparable pkg %s.%s', instpo.name, instpo.arch)
+                continue
+                
+        # go through each package 
+        if len(comparable) > 0:
+            for instpo in comparable:
+                if pkg.EVR > instpo.EVR: # we're newer - this is an update, pass to them
+                    if instpo.name in exactarchlist:
+                        if pkg.arch == instpo.arch:
+                            return True
+                    else:
+                        return True
+                        
+                elif pkg.EVR == instpo.EVR: # same, ignore
+                    return False
+                    
+                elif pkg.EVR < instpo.EVR: # lesser, check if the pkgtup is an exactmatch
+                                   # if so then add it to be installed
+                                   # if it can be multiply installed
+                                   # this is where we could handle setting 
+                                   # it to be an 'oldpackage' revert.
+                                   
+                    if ematch and self.allowedMultipleInstalls(pkg):
+                        return True
+                        
+        else: # we've not got any installed that match n or n+a
+            self.verbose_logger.log(yum.logginglevels.DEBUG_1, 'No other %s installed, adding to list for potential install', pkg.name)
+            return True
+        
+        return False
 
 class YumOptionParser(OptionParser):
     '''Subclass that makes some minor tweaks to make OptionParser do things the




More information about the Yum-cvs-commits mailing list