Fix 'zypper info's report of package support status (bnc#651614)
authorMichael Andres <ma@suse.de>
Tue, 13 Sep 2011 11:02:50 +0000 (13:02 +0200)
committerMichael Andres <ma@suse.de>
Tue, 13 Sep 2011 11:02:50 +0000 (13:02 +0200)
src/info.cc
zypper.spec.cmake

index e1c8d31..a95f5e7 100644 (file)
@@ -9,7 +9,7 @@
 
 #include <boost/format.hpp>
 
-#include <zypp/base/LogTools.h>
+// #include <zypp/base/LogTools.h>
 #include <zypp/base/Algorithm.h>
 #include <zypp/ZYpp.h>
 #include <zypp/Package.h>
@@ -171,11 +171,18 @@ Copy and modify /usr/share/vim/current/gvimrc to ~/.gvimrc if needed.
  */
 void printPkgInfo(Zypper & zypper, const ui::Selectable & s)
 {
-  PoolItem installed = s.installedObj();
-  PoolItem theone = s.updateCandidateObj();
-  if (!theone)
-    theone = installed;
-  Package::constPtr pkg = asKind<Package>(theone.resolvable());
+  PoolItem installed( s.installedObj() );
+  PoolItem updateCand( s.updateCandidateObj() );
+  // An updateCandidate is always better than any installed object.
+  // If the best version is already installed try to look it up in
+  // the repo it came from, otherwise use the installed one.
+  PoolItem theone( updateCand );
+  if ( !theone )
+  {
+    theone = s.identicalAvailableObj( installed );
+    if ( !theone )
+      theone = installed;
+  }
 
   cout << (zypper.globalOpts().is_rug_compatible ? _("Catalog: ") : _("Repository: "))
        << (zypper.config().show_alias ?
@@ -187,22 +194,26 @@ void printPkgInfo(Zypper & zypper, const ui::Selectable & s)
   // if running on SUSE Linux Enterprise, report unsupported packages
   Product::constPtr platform = God->target()->baseProduct();
   if (platform && platform->name().find("SUSE_SLE") != string::npos)
+  {
+    Package::constPtr pkg = asKind<Package>(theone.resolvable());
     cout << _("Support Level: ") << asUserString(pkg->vendorSupport()) << endl;
+  }
 
   cout << _("Installed: ") << (installed ? _("Yes") : _("No")) << endl;
 
-  //! \todo fix this - arch?
   cout << _("Status: ");
-  if (installed &&
-      installed.resolvable()->edition() >= theone.resolvable()->edition())
-  {
-    cout << _("up-to-date") << endl;
-  }
-  else if (installed)
+  if ( installed )
   {
-    cout << str::form(_("out-of-date (version %s installed)"),
-        installed.resolvable()->edition().asString().c_str())
-      << endl;
+    if ( updateCand )
+    {
+      cout << str::form(_("out-of-date (version %s installed)"),
+                       installed.resolvable()->edition().asString().c_str())
+           << endl;
+    }
+    else
+    {
+      cout << _("up-to-date") << endl;
+    }
   }
   else
     cout << _("not installed") << endl;
index 5d9322e..0d63bb3 100644 (file)
@@ -11,7 +11,7 @@
 # norootforbuild
 
 Name:           @PACKAGE@
-BuildRequires:  libzypp-devel >= 9.8.0
+BuildRequires:  libzypp-devel >= 9.11.0
 BuildRequires:  boost-devel >= 1.33.1
 BuildRequires:  gettext-devel >= 0.15
 BuildRequires:  readline-devel >= 5.1