Fix multiver. pkgs in "not updated" (bnc #629197).
authorJán Kupec <jkupec@suse.cz>
Sun, 31 Oct 2010 10:54:25 +0000 (11:54 +0100)
committerJán Kupec <jkupec@suse.cz>
Sun, 31 Oct 2010 10:54:25 +0000 (11:54 +0100)
src/Summary.cc

index 9dc46ab..684f334 100644 (file)
@@ -83,6 +83,18 @@ void Summary::readPool(const zypp::ResPool & pool)
   _todownload = ByteCount();
   _inst_size_change = ByteCount();
 
+  // find multi-version packages, which actually have mult. versions installed
+  const set<string> & multies = ZConfig::instance().multiversionSpec();
+  for_(name, multies.begin(), multies.end())
+  {
+    ui::Selectable::Ptr s = pool.proxy().lookup(ResKind::package, *name);
+    bool got_multi = s && (
+        s->installedSize() > 1 ||
+        (s->installedSize() == 1 && s->toInstall()) );
+    if (got_multi)
+      multi_installed.insert(*name);
+  }
+
   // collect resolvables to be installed/removed
 
   KindToResObjectSet to_be_installed;
@@ -170,6 +182,11 @@ void Summary::readPool(const zypp::ResPool & pool)
           // upgrade
           if (res->edition() > (*rmit)->edition())
           {
+            // don't put multiversion packages to 'toupgrade', they will
+            // always be reported as newly installed (and removed)
+            if (multi_installed.find(res->name()) != multi_installed.end())
+              continue;
+
             toupgrade[res->kind()].insert(rp);
             if (res->arch() != (*rmit)->arch())
               tochangearch[res->kind()].insert(rp);
@@ -189,6 +206,11 @@ void Summary::readPool(const zypp::ResPool & pool)
           // downgrade
           else
           {
+            // don't put multiversion packages to 'todowngrade', they will
+            // always be reported as newly installed (and removed)
+            if (multi_installed.find(res->name()) != multi_installed.end())
+              continue;
+
             todowngrade[res->kind()].insert(rp);
             if (res->arch() != (*rmit)->arch())
               tochangearch[res->kind()].insert(rp);
@@ -217,6 +239,9 @@ void Summary::readPool(const zypp::ResPool & pool)
 
   m.elapsed();
 
+  // collect the rest (not upgraded/downgraded) of to_be_removed as 'toremove'
+  // and decrease installed size change accordingly
+
   //bool toremove_by_solver = false;
   for (KindToResObjectSet::const_iterator it = to_be_removed.begin();
       it != to_be_removed.end(); ++it)
@@ -253,6 +278,7 @@ void Summary::readPool(const zypp::ResPool & pool)
 
       ResObject::constPtr candidate =
         (*it)->highestAvailableVersionObj().resolvable();
+
       if (!candidate)
         continue;
       if (compareByNVRA((*it)->installedObj().resolvable(), candidate) >= 0)
@@ -262,6 +288,11 @@ void Summary::readPool(const zypp::ResPool & pool)
           && (*it)->installedObj()->arch() != Arch_noarch
           && candidate->arch() != Arch_noarch)
         continue;
+      // mutliversion packages do not end up in toupgrade, so we need to remove
+      // them from candidates if the candidate actually installs (bnc #629197)
+      if (multi_installed.find(candidate->name()) != multi_installed.end()
+          && candidate->poolItem().status().isToBeInstalled())
+        continue;
 
       candidates[*kit].insert(ResPair(nullres, candidate));
     }
@@ -298,18 +329,6 @@ void Summary::readPool(const zypp::ResPool & pool)
       ++it;
   }
 
-  // find multi-version packages, which actually have mult. versions installed
-  const set<string> & multies = ZConfig::instance().multiversionSpec();
-  for_(name, multies.begin(), multies.end())
-  {
-    ui::Selectable::Ptr s = pool.proxy().lookup(ResKind::package, *name);
-    bool got_multi = s && (
-        s->installedSize() > 1 ||
-        (s->installedSize() == 1 && s->toInstall()) );
-    if (got_multi)
-      multi_installed.insert(*name);
-  }
-
   m.stop();
 }