Move the showauto command to apt-cache and sort output.
authorJulian Andres Klode <jak@debian.org>
Tue, 4 May 2010 19:28:24 +0000 (21:28 +0200)
committerJulian Andres Klode <jak@debian.org>
Tue, 4 May 2010 19:28:24 +0000 (21:28 +0200)
* cmdline/apt-cache.cc:
  - Add a showauto command to apt-cache.
  - Add apt-get markauto and unmarkauto commands.

cmdline/apt-cache.cc
cmdline/apt-get.cc
debian/changelog

index b981e2f..10dbf44 100644 (file)
@@ -14,7 +14,9 @@
                                                                        /*}}}*/
 // Include Files                                                       /*{{{*/
 #include <apt-pkg/error.h>
+#include <cassert>
 #include <apt-pkg/pkgcachegen.h>
+#include <apt-pkg/cachefile.h>
 #include <apt-pkg/init.h>
 #include <apt-pkg/progress.h>
 #include <apt-pkg/sourcelist.h>
@@ -1406,6 +1408,29 @@ bool Search(CommandLine &CmdL)
        return _error->Error("Write to stdout failed");
    return true;
 }
+
+
+/* show automatically installed packages (sorted) */
+bool ShowAuto(CommandLine &CmdL)
+{
+   OpProgress op;
+   pkgDepCache DepCache(GCache);
+   DepCache.Init(&op);
+
+   std::vector<string> packages;
+   packages.reserve(GCache->HeaderP->PackageCount / 3);
+   
+   for (pkgCache::PkgIterator P = GCache->PkgBegin(); P.end() == false; P++)
+      if (DepCache[P].Flags & pkgCache::Flag::Auto)
+         packages.push_back(P.Name());
+
+    std::sort(packages.begin(), packages.end());
+    
+    for (vector<string>::iterator I = packages.begin(); I != packages.end(); I++)
+            cout << *I << "\n";
+
+   return true;
+}
                                                                        /*}}}*/
 // ShowPackage - Dump the package record to the screen                 /*{{{*/
 // ---------------------------------------------------------------------
@@ -1777,6 +1802,7 @@ bool ShowHelp(CommandLine &Cmd)
       "   unmet - Show unmet dependencies\n"
       "   search - Search the package list for a regex pattern\n"
       "   show - Show a readable record for the package\n"
+      "   showauto - Display a list of automatically installed packages\n"
       "   depends - Show raw dependency information for a package\n"
       "   rdepends - Show reverse dependency information for a package\n"
       "   pkgnames - List the names of all packages in the system\n"
@@ -1841,6 +1867,7 @@ int main(int argc,const char *argv[])                                     /*{{{*/
                                     {"xvcg",&XVcg},
                                     {"show",&ShowPackage},
                                     {"pkgnames",&ShowPkgNames},
+                                    {"showauto",&ShowAuto},
                                     {"policy",&Policy},
                                     {"madison",&Madison},
                                     {0,0}};
index 8f9faf1..03239da 100644 (file)
@@ -2014,20 +2014,6 @@ bool DoInstall(CommandLine &CmdL)
    return InstallPackages(Cache,false);   
 }
 
-/* show automatically installed packages. */
-bool DoShowAuto(CommandLine &CmdL)
-{
-   OpProgress progress;
-   pkgCacheFile Cache;
-   if (Cache.Open(progress, false) == false)
-      return false;
-
-   for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; P++)
-      if (Cache[P].Flags & pkgCache::Flag::Auto)
-          ioprintf(c1out,_("%s\n"), P.Name());
-   return true;
-}
-
 /* mark packages as automatically/manually installed. */
 bool DoMarkAuto(CommandLine &CmdL)
 {
@@ -2854,7 +2840,6 @@ bool ShowHelp(CommandLine &CmdL)
       "   check - Verify that there are no broken dependencies\n"
       "   markauto - Mark the given packages as automatically installed\n"
       "   unmarkauto - Mark the given packages as manually installed\n"
-      "   showauto - Display a list of automatically installed packages\n"
       "\n"
       "Options:\n"
       "  -h  This help text.\n"
@@ -2961,7 +2946,6 @@ int main(int argc,const char *argv[])                                     /*{{{*/
                                    {"purge",&DoInstall},
                                   {"autoremove",&DoInstall},
                                   {"purge",&DoInstall},
-                                  {"showauto",&DoShowAuto},
                                   {"markauto",&DoMarkAuto},
                                   {"unmarkauto",&DoMarkAuto},
                                    {"dist-upgrade",&DoDistUpgrade},
index 07fc084..d414af3 100644 (file)
@@ -75,8 +75,10 @@ apt (0.7.26~exp4) UNRELEASEDexperimental; urgency=low
     - subclass pkgAcquire::{Worker,Item,ItemDesc} from WeakPointable.
   * apt-pkg/pkgcache.cc:
     - Merge fix from David to correct handling in single-arch environments.
+  * cmdline/apt-cache.cc:
+    - Add a showauto command to apt-cache.
   * cmdline/apt-get.cc:
-    - Add apt-get markauto, showauto and unmarkauto commands.
+    - Add apt-get markauto and unmarkauto commands.
 
  -- David Kalnischkies <kalnischkies@gmail.com>  Sat, 03 Apr 2010 14:58:39 +0200
 
@@ -1584,13 +1586,6 @@ apt (0.7.6) unstable; urgency=low
 
  -- Otavio Salvador <otavio@debian.org>  Wed, 01 Aug 2007 19:49:51 -0300
 
-apt (0.7.6) unstable; urgency=low
-
-  * Applied patch from Aurelien Jarno <aurel32@debian.org> to fix wrong
-    directory downloading on non-linux architectures (closes: #435597)
-
- -- Otavio Salvador <otavio@debian.org>  Wed, 01 Aug 2007 19:49:51 -0300
-
 apt (0.7.5) unstable; urgency=low
 
   [ Otavio Salvador ]