- show in 'lu' what will 'up' actually propose to install (bnc #395480)
authorJan Kupec <jkupec@suse.cz>
Mon, 29 Sep 2008 10:08:06 +0000 (10:08 +0000)
committerJan Kupec <jkupec@suse.cz>
Mon, 29 Sep 2008 10:08:06 +0000 (10:08 +0000)
- new --all/-a option for 'lu' to show the original raw list of
  packages for which newer versions exist

src/Zypper.cc
src/update.cc

index 400ab88..d1c6813 100644 (file)
@@ -1400,7 +1400,8 @@ void Zypper::processCommandOptions()
       // rug compatibility option, we have --repo
       {"catalog",     required_argument, 0, 'c'},
       {"type",        required_argument, 0, 't'},
-      {"best-effort", no_argument, 0, 0 },
+      {"all",         no_argument,       0, 'a'},
+      {"best-effort", no_argument,       0,  0 },
       {"help", no_argument, 0, 'h'},
       {0, 0, 0, 0}
     };
@@ -1413,13 +1414,16 @@ void Zypper::processCommandOptions()
       "List all available updates.\n"
       "\n"
       "  Command options:\n"
-      "-t, --type <type>               Type of package (%s).\n"
-      "                                Default: %s.\n"
-      "-r, --repo <alias|#|URI>        List only updates from the specified repository.\n"
-      "    --best-effort               Do a 'best effort' approach to update. Updates\n"
-      "                                to a lower than the latest version are\n"
-      "                                also acceptable.\n"
-    ), "package, patch, pattern, product", "patch");
+      "-t, --type <type>             Type of package (%s).\n"
+      "                              Default: %s.\n"
+      "-r, --repo <alias|#|URI>      List only updates from the specified repository.\n"
+      "    --best-effort             Do a 'best effort' approach to update. Updates\n"
+      "                              to a lower than the latest version are\n"
+      "                              also acceptable.\n"
+      "-a, --all                     List all packages for which newer versions are\n"
+      "                              available, regardless whether they are\n"
+      "                              installable or not.\n"
+    ), "package, patch, pattern, product", "package");
     break;
   }
 
index bb3adb3..ff69dcf 100755 (executable)
@@ -261,10 +261,24 @@ static void
 find_updates( const ResKind & kind, Candidates & candidates )
 {
   const zypp::ResPool& pool = God->pool();
+  DBG << "Looking for update candidates of kind " << kind << endl;
+
+  // package updates
+  if (kind == ResKind::package && !Zypper::instance()->cOpts().count("all"))
+  {
+    God->resolver()->doUpdate();
+    ResPool::const_iterator
+      it = God->pool().begin(),
+      e  = God->pool().end();
+    for (; it != e; ++it)
+      if (it->status().isToBeInstalled())
+        candidates.insert(*it);
+    return;
+  }
+
   ResPool::byKind_iterator
     it = pool.byKindBegin (kind),
     e  = pool.byKindEnd (kind);
-  DBG << "Looking for update candidates of kind " << kind << endl;
   for (; it != e; ++it)
   {
     if (it->status().isUninstalled())