* cmdline/apt-get.cc:
authorDavid Kalnischkies <kalnischkies@gmail.com>
Wed, 11 Apr 2012 10:12:24 +0000 (12:12 +0200)
committerDavid Kalnischkies <kalnischkies@gmail.com>
Wed, 11 Apr 2012 10:12:24 +0000 (12:12 +0200)
  - print list of autoremoves in alphabetical order (Closes: #639008)

cmdline/apt-get.cc
debian/changelog
test/integration/test-bug-613420-new-garbage-dependency

index 52618ae..6d7f802 100644 (file)
@@ -1711,12 +1711,13 @@ bool DoAutomaticRemove(CacheFile &Cache)
    bool smallList = (hideAutoRemove == false &&
                strcasecmp(_config->Find("APT::Get::HideAutoRemove","").c_str(),"small") == 0);
 
-   string autoremovelist, autoremoveversions;
    unsigned long autoRemoveCount = 0;
    APT::PackageSet tooMuch;
+   APT::PackageList autoRemoveList;
    // look over the cache to see what can be removed
-   for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); ! Pkg.end(); ++Pkg)
+   for (unsigned J = 0; J < Cache->Head().PackageCount; ++J)
    {
+      pkgCache::PkgIterator Pkg(Cache,Cache.List[J]);
       if (Cache[Pkg].Garbage)
       {
         if(Pkg.CurrentVer() != 0 || Cache[Pkg].Install())
@@ -1733,6 +1734,8 @@ bool DoAutomaticRemove(CacheFile &Cache)
         }
         else
         {
+           if (hideAutoRemove == false && Cache[Pkg].Delete() == false)
+              autoRemoveList.insert(Pkg);
            // if the package is a new install and already garbage we don't need to
            // install it in the first place, so nuke it instead of show it
            if (Cache[Pkg].Install() == true && Pkg.CurrentVer() == 0)
@@ -1742,16 +1745,8 @@ bool DoAutomaticRemove(CacheFile &Cache)
               Cache->MarkDelete(Pkg, false);
            }
            // only show stuff in the list that is not yet marked for removal
-           else if(hideAutoRemove == false && Cache[Pkg].Delete() == false) 
-           {
+           else if(hideAutoRemove == false && Cache[Pkg].Delete() == false)
               ++autoRemoveCount;
-              // we don't need to fill the strings if we don't need them
-              if (smallList == false)
-              {
-                autoremovelist += Pkg.FullName(true) + " ";
-                autoremoveversions += string(Cache[Pkg].CandVersion) + "\n";
-              }
-           }
         }
       }
    }
@@ -1786,14 +1781,7 @@ bool DoAutomaticRemove(CacheFile &Cache)
                    std::clog << "Save " << Pkg << " as another installed garbage package depends on it" << std::endl;
                 Cache->MarkInstall(Pkg, false);
                 if (hideAutoRemove == false)
-                {
                    ++autoRemoveCount;
-                   if (smallList == false)
-                   {
-                      autoremovelist += Pkg.FullName(true) + " ";
-                      autoremoveversions += string(Cache[Pkg].CandVersion) + "\n";
-                   }
-                }
                 tooMuch.erase(Pkg);
                 Changed = true;
                 break;
@@ -1803,6 +1791,18 @@ bool DoAutomaticRemove(CacheFile &Cache)
       } while (Changed == true);
    }
 
+   std::string autoremovelist, autoremoveversions;
+   if (smallList == false && autoRemoveCount != 0)
+   {
+      for (APT::PackageList::const_iterator Pkg = autoRemoveList.begin(); Pkg != autoRemoveList.end(); ++Pkg)
+      {
+        if (Cache[Pkg].Garbage == false)
+           continue;
+        autoremovelist += Pkg.FullName(true) + " ";
+        autoremoveversions += string(Cache[Pkg].CandVersion) + "\n";
+      }
+   }
+
    // Now see if we had destroyed anything (if we had done anything)
    if (Cache->BrokenCount() != 0)
    {
index 85382b6..4e337df 100644 (file)
@@ -73,6 +73,8 @@ apt (0.8.16~exp14) UNRELEASED; urgency=low
     - use libz2 library for (de)compression instead of the bzip2 binary as
       the first is a dependency of dpkg and the later just priority:optional
       so we gain 'easier' access to bz2-compressed Translation files this way
+  * cmdline/apt-get.cc:
+    - print list of autoremoves in alphabetical order (Closes: #639008)
 
   [ Bogdan Purcareata ]
   * doc/apt-get.8.xml:
@@ -82,7 +84,7 @@ apt (0.8.16~exp14) UNRELEASED; urgency=low
       number of auto-removed packages both before and after the list
       of packages (Closes: #665833)
 
- -- David Kalnischkies <kalnischkies@gmail.com>  Thu, 05 Apr 2012 21:36:16 +0200
+ -- David Kalnischkies <kalnischkies@gmail.com>  Wed, 11 Apr 2012 12:09:33 +0200
 
 apt (0.8.16~exp13) experimental; urgency=low
 
index 34cf38c..7a08871 100755 (executable)
@@ -22,7 +22,7 @@ testequal "Reading package lists...
 Building dependency tree...
 Reading state information...
 The following packages were automatically installed and are no longer required:
-  openoffice.org-officebean libreoffice-officebean
+  libreoffice-officebean openoffice.org-officebean
 Use 'apt-get autoremove' to remove them.
 The following extra packages will be installed:
   libreoffice-core libreoffice-officebean openoffice.org-officebean