Link a product buddy to the latest release package version (bnc #497696).
authorMichael Andres <ma@suse.de>
Mon, 27 Apr 2009 13:36:46 +0000 (15:36 +0200)
committerMichael Andres <ma@suse.de>
Mon, 27 Apr 2009 13:36:46 +0000 (15:36 +0200)
zypp/Product.cc

index 32f93a7..50b9d54 100644 (file)
@@ -77,18 +77,26 @@ namespace zypp
   {
     // Look for a  provider of 'product(name) = version' of same
     // architecture and within the same repo.
+    //
+    // bnc #497696: Update repos may have multiple release package versions
+    // providing the same product. As a workaround we link to the one with
+    // the highest version.
     Capability identCap( str::form( "product(%s) = %s", name().c_str(), edition().c_str() ) );
 
+    sat::Solvable found;
     sat::WhatProvides providers( identCap );
     for_( it, providers.begin(), providers.end() )
     {
       if ( it->repository() == repository()
            && it->arch() == arch() )
-        return *it;
+      {
+        if ( ! found || found.edition() < it->edition() )
+          found = *it;
+      }
     }
-
-    WAR << *this << ": no reference package found: " << identCap << endl;
-    return sat::Solvable::noSolvable;
+    if ( ! found )
+      WAR << *this << ": no reference package found: " << identCap << endl;
+    return found;
   }
 
   std::string Product::referenceFilename() const