X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/b5cabd30cc1be1c6c1ca675ceb359bab577c1905..2a49601f69e08f06fb2727d869d420daacdd09d5:/cmdline/apt-cache.cc?ds=inline

diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc
index 6813d2978..0a2c28d23 100644
--- a/cmdline/apt-cache.cc
+++ b/cmdline/apt-cache.cc
@@ -13,9 +13,9 @@
    ##################################################################### */
 									/*}}}*/
 // Include Files							/*{{{*/
+#include<config.h>
+
 #include <apt-pkg/error.h>
-#include <cassert>
-#include <apt-pkg/pkgcachegen.h>
 #include <apt-pkg/cachefile.h>
 #include <apt-pkg/cacheset.h>
 #include <apt-pkg/init.h>
@@ -23,6 +23,7 @@
 #include <apt-pkg/sourcelist.h>
 #include <apt-pkg/cmndline.h>
 #include <apt-pkg/strutl.h>
+#include <apt-pkg/fileutl.h>
 #include <apt-pkg/pkgrecords.h>
 #include <apt-pkg/srcrecords.h>
 #include <apt-pkg/version.h>
@@ -30,18 +31,21 @@
 #include <apt-pkg/tagfile.h>
 #include <apt-pkg/algorithms.h>
 #include <apt-pkg/sptr.h>
+#include <apt-pkg/pkgsystem.h>
+#include <apt-pkg/indexfile.h>
+#include <apt-pkg/metaindex.h>
 
-#include <config.h>
-#include <apti18n.h>
-
+#include <cassert>
 #include <locale.h>
 #include <iostream>
 #include <unistd.h>
 #include <errno.h>
 #include <regex.h>
 #include <stdio.h>
-
 #include <iomanip>
+#include <algorithm>
+
+#include <apti18n.h>
 									/*}}}*/
 
 using namespace std;
@@ -61,12 +65,12 @@ public:
       return CacheSetHelper::canNotFindNewestVer(Cache, Pkg);
    }
 
-   virtual APT::VersionSet canNotFindAllVer(pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
+   virtual void canNotFindAllVer(APT::VersionContainerInterface * vci, pkgCacheFile &Cache, pkgCache::PkgIterator const &Pkg) {
       virtualPkgs.insert(Pkg);
-      return CacheSetHelper::canNotFindAllVer(Cache, Pkg);
+      CacheSetHelper::canNotFindAllVer(vci, Cache, Pkg);
    }
 
-   CacheSetHelperVirtuals(bool const &ShowErrors = true, GlobalError::MsgType const &ErrorType = GlobalError::NOTICE) : CacheSetHelper(ShowErrors, ErrorType) {}
+   CacheSetHelperVirtuals(bool const ShowErrors = true, GlobalError::MsgType const &ErrorType = GlobalError::NOTICE) : CacheSetHelper(ShowErrors, ErrorType) {}
 };
 									/*}}}*/
 // LocalitySort - Sort a version list by package file locality		/*{{{*/
@@ -104,7 +108,7 @@ void LocalitySort(pkgCache::DescFile **begin,
 // UnMet - Show unmet dependencies					/*{{{*/
 // ---------------------------------------------------------------------
 /* */
-bool ShowUnMet(pkgCache::VerIterator const &V, bool const &Important)
+bool ShowUnMet(pkgCache::VerIterator const &V, bool const Important)
 {
 	 bool Header = false;
 	 for (pkgCache::DepIterator D = V.DependsList(); D.end() == false;)
@@ -121,9 +125,7 @@ bool ShowUnMet(pkgCache::VerIterator const &V, bool const &Important)
 		  continue;
 
 	    // Skip conflicts and replaces
-	    if (End->Type == pkgCache::Dep::DpkgBreaks ||
-		End->Type == pkgCache::Dep::Replaces ||
-		End->Type == pkgCache::Dep::Conflicts)
+	    if (End.IsNegative() == true)
 	       continue;
 
 	    // Verify the or group
@@ -143,7 +145,7 @@ bool ShowUnMet(pkgCache::VerIterator const &V, bool const &Important)
 	       
 	       if (Start == End)
 		  break;
-	       Start++;
+	       ++Start;
 	    }
 	    while (1);
 
@@ -171,7 +173,7 @@ bool ShowUnMet(pkgCache::VerIterator const &V, bool const &Important)
 	       if (Start == End)
 		  break;
 	       cout << " | ";
-	       Start++;
+	       ++Start;
 	    }
 	    while (1);
 	    
@@ -189,7 +191,7 @@ bool UnMet(CommandLine &CmdL)
 
    if (CmdL.FileSize() <= 1)
    {
-      for (pkgCache::PkgIterator P = CacheFile.GetPkgCache()->PkgBegin(); P.end() == false; P++)
+      for (pkgCache::PkgIterator P = CacheFile.GetPkgCache()->PkgBegin(); P.end() == false; ++P)
 	 for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V)
 	    if (ShowUnMet(V, Important) == false)
 	       return false;
@@ -197,9 +199,9 @@ bool UnMet(CommandLine &CmdL)
    else
    {
       CacheSetHelperVirtuals helper(true, GlobalError::NOTICE);
-      APT::VersionSet verset = APT::VersionSet::FromCommandLine(CacheFile, CmdL.FileList + 1,
-				APT::VersionSet::CANDIDATE, helper);
-      for (APT::VersionSet::iterator V = verset.begin(); V != verset.end(); ++V)
+      APT::VersionList verset = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1,
+				APT::VersionList::CANDIDATE, helper);
+      for (APT::VersionList::iterator V = verset.begin(); V != verset.end(); ++V)
 	 if (ShowUnMet(V, Important) == false)
 	    return false;
    }
@@ -213,19 +215,19 @@ bool DumpPackage(CommandLine &CmdL)
 {
    pkgCacheFile CacheFile;
    APT::CacheSetHelper helper(true, GlobalError::NOTICE);
-   APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1, helper);
+   APT::PackageList pkgset = APT::PackageList::FromCommandLine(CacheFile, CmdL.FileList + 1, helper);
 
-   for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
+   for (APT::PackageList::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
    {
       cout << "Package: " << Pkg.FullName(true) << endl;
       cout << "Versions: " << endl;
-      for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; Cur++)
+      for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; ++Cur)
       {
 	 cout << Cur.VerStr();
-	 for (pkgCache::VerFileIterator Vf = Cur.FileList(); Vf.end() == false; Vf++)
+	 for (pkgCache::VerFileIterator Vf = Cur.FileList(); Vf.end() == false; ++Vf)
 	    cout << " (" << Vf.File().FileName() << ")";
 	 cout << endl;
-	 for (pkgCache::DescIterator D = Cur.DescriptionList(); D.end() == false; D++)
+	 for (pkgCache::DescIterator D = Cur.DescriptionList(); D.end() == false; ++D)
 	 {
 	    cout << " Description Language: " << D.LanguageCode() << endl
 		 << "                 File: " << D.FileList().File().FileName() << endl
@@ -237,7 +239,7 @@ bool DumpPackage(CommandLine &CmdL)
       cout << endl;
       
       cout << "Reverse Depends: " << endl;
-      for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() != true; D++)
+      for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() != true; ++D)
       {
 	 cout << "  " << D.ParentPkg().FullName(true) << ',' << D.TargetPkg().FullName(true);
 	 if (D->Version != 0)
@@ -247,24 +249,24 @@ bool DumpPackage(CommandLine &CmdL)
       }
       
       cout << "Dependencies: " << endl;
-      for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; Cur++)
+      for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; ++Cur)
       {
 	 cout << Cur.VerStr() << " - ";
-	 for (pkgCache::DepIterator Dep = Cur.DependsList(); Dep.end() != true; Dep++)
+	 for (pkgCache::DepIterator Dep = Cur.DependsList(); Dep.end() != true; ++Dep)
 	    cout << Dep.TargetPkg().FullName(true) << " (" << (int)Dep->CompareOp << " " << DeNull(Dep.TargetVer()) << ") ";
 	 cout << endl;
       }      
 
       cout << "Provides: " << endl;
-      for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; Cur++)
+      for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; ++Cur)
       {
 	 cout << Cur.VerStr() << " - ";
-	 for (pkgCache::PrvIterator Prv = Cur.ProvidesList(); Prv.end() != true; Prv++)
+	 for (pkgCache::PrvIterator Prv = Cur.ProvidesList(); Prv.end() != true; ++Prv)
 	    cout << Prv.ParentPkg().FullName(true) << " ";
 	 cout << endl;
       }
       cout << "Reverse Provides: " << endl;
-      for (pkgCache::PrvIterator Prv = Pkg.ProvidesList(); Prv.end() != true; Prv++)
+      for (pkgCache::PrvIterator Prv = Pkg.ProvidesList(); Prv.end() != true; ++Prv)
 	 cout << Prv.OwnerPkg().FullName(true) << " " << Prv.OwnerVer().VerStr() << endl;
    }
 
@@ -292,7 +294,7 @@ bool Stats(CommandLine &Cmd)
    int DVirt = 0;
    int Missing = 0;
    pkgCache::PkgIterator I = Cache->PkgBegin();
-   for (;I.end() != true; I++)
+   for (;I.end() != true; ++I)
    {
       if (I->VersionList != 0 && I->ProvidesList == 0)
       {
@@ -355,11 +357,11 @@ bool Stats(CommandLine &Cmd)
    cout << _("Total globbed strings: ") << Count << " (" << SizeToStr(Size) << ')' << endl;
 
    unsigned long DepVerSize = 0;
-   for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; P++)
+   for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P)
    {
-      for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; V++)
+      for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V)
       {
-	 for (pkgCache::DepIterator D = V.DependsList(); D.end() == false; D++)
+	 for (pkgCache::DepIterator D = V.DependsList(); D.end() == false; ++D)
 	 {
 	    if (D->Version != 0)
 	       DepVerSize += strlen(D.TargetVer()) + 1;
@@ -396,17 +398,17 @@ bool Dump(CommandLine &Cmd)
 
    cout << "Using Versioning System: " << Cache->VS->Label << endl;
    
-   for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; P++)
+   for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P)
    {
       cout << "Package: " << P.FullName(true) << endl;
-      for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; V++)
+      for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; ++V)
       {
 	 cout << " Version: " << V.VerStr() << endl;
 	 cout << "     File: " << V.FileList().File().FileName() << endl;
-	 for (pkgCache::DepIterator D = V.DependsList(); D.end() == false; D++)
+	 for (pkgCache::DepIterator D = V.DependsList(); D.end() == false; ++D)
 	    cout << "  Depends: " << D.TargetPkg().FullName(true) << ' ' << 
 	                     DeNull(D.TargetVer()) << endl;
-	 for (pkgCache::DescIterator D = V.DescriptionList(); D.end() == false; D++)
+	 for (pkgCache::DescIterator D = V.DescriptionList(); D.end() == false; ++D)
 	 {
 	    cout << " Description Language: " << D.LanguageCode() << endl
 		 << "                 File: " << D.FileList().File().FileName() << endl
@@ -415,7 +417,7 @@ bool Dump(CommandLine &Cmd)
       }      
    }
 
-   for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F.end() == false; F++)
+   for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F.end() == false; ++F)
    {
       cout << "File: " << F.FileName() << endl;
       cout << " Type: " << F.IndexType() << endl;
@@ -451,7 +453,7 @@ bool DumpAvail(CommandLine &Cmd)
    memset(VFList,0,sizeof(*VFList)*Count);
    
    // Map versions that we want to write out onto the VerList array.
-   for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; P++)
+   for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P)
    {    
       if (P->VersionList == 0)
 	 continue;
@@ -468,7 +470,7 @@ bool DumpAvail(CommandLine &Cmd)
       }
       
       pkgCache::VerFileIterator VF = V.FileList();
-      for (; VF.end() == false ; VF++)
+      for (; VF.end() == false ; ++VF)
 	 if ((VF.File()->Flags & pkgCache::Flag::NotSource) == 0)
 	    break;
       
@@ -482,9 +484,9 @@ bool DumpAvail(CommandLine &Cmd)
          handling works OK. */
       if (VF.end() == true)
       {
-	 for (pkgCache::VerIterator Cur = P.VersionList(); Cur.end() != true; Cur++)
+	 for (pkgCache::VerIterator Cur = P.VersionList(); Cur.end() != true; ++Cur)
 	 {
-	    for (VF = Cur.FileList(); VF.end() == false; VF++)
+	    for (VF = Cur.FileList(); VF.end() == false; ++VF)
 	    {	 
 	       if ((VF.File()->Flags & pkgCache::Flag::NotSource) == 0)
 	       {
@@ -586,15 +588,16 @@ bool ShowDepends(CommandLine &CmdL, bool const RevDepends)
       return false;
 
    CacheSetHelperVirtuals helper(false);
-   APT::VersionSet verset = APT::VersionSet::FromCommandLine(CacheFile, CmdL.FileList + 1, APT::VersionSet::CANDIDATE, helper);
+   APT::VersionList verset = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1, APT::VersionList::CANDIDATE, helper);
    if (verset.empty() == true && helper.virtualPkgs.empty() == true)
-      return false;
+      return _error->Error(_("No packages found"));
    std::vector<bool> Shown(Cache->Head().PackageCount);
 
    bool const Recurse = _config->FindB("APT::Cache::RecurseDepends", false);
    bool const Installed = _config->FindB("APT::Cache::Installed", false);
    bool const Important = _config->FindB("APT::Cache::Important", false);
    bool const ShowDepType = _config->FindB("APT::Cache::ShowDependencyType", RevDepends == false);
+   bool const ShowVersion = _config->FindB("APT::Cache::ShowVersion", false);
    bool const ShowPreDepends = _config->FindB("APT::Cache::ShowPre-Depends", true);
    bool const ShowDepends = _config->FindB("APT::Cache::ShowDepends", true);
    bool const ShowRecommends = _config->FindB("APT::Cache::ShowRecommends", Important == false);
@@ -617,7 +620,7 @@ bool ShowDepends(CommandLine &CmdL, bool const RevDepends)
 	 if (RevDepends == true)
 	    cout << "Reverse Depends:" << endl;
 	 for (pkgCache::DepIterator D = RevDepends ? Pkg.RevDependsList() : Ver.DependsList();
-	      D.end() == false; D++)
+	      D.end() == false; ++D)
 	 {
 	    switch (D->Type) {
 	    case pkgCache::Dep::PreDepends: if (!ShowPreDepends) continue; break;
@@ -644,10 +647,13 @@ bool ShowDepends(CommandLine &CmdL, bool const RevDepends)
 		if (ShowDepType == true)
 		  cout << D.DepType() << ": ";
 		if (Trg->VersionList == 0)
-		  cout << "<" << Trg.FullName(true) << ">" << endl;
+		  cout << "<" << Trg.FullName(true) << ">";
 		else
-		  cout << Trg.FullName(true) << endl;
-	    
+		  cout << Trg.FullName(true);
+		if (ShowVersion == true && D->Version != 0)
+		   cout << " (" << pkgCache::CompTypeDeb(D->CompareOp) << ' ' << D.TargetVer() << ')';
+		cout << std::endl;
+
 		if (Recurse == true && Shown[Trg->ID] == false)
 		{
 		  Shown[Trg->ID] = true;
@@ -743,7 +749,7 @@ bool XVcg(CommandLine &CmdL)
    memset(Flags,0,sizeof(*Flags)*Cache->Head().PackageCount);
    
    // Map the shapes
-   for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++)
+   for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg)
    {   
       if (Pkg->VersionList == 0)
       {
@@ -790,7 +796,7 @@ bool XVcg(CommandLine &CmdL)
    while (Act == true)
    {
       Act = false;
-      for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++)
+      for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg)
       {
 	 // See we need to show this package
 	 if (Show[Pkg->ID] == None || Show[Pkg->ID] >= DoneNR)
@@ -816,14 +822,14 @@ bool XVcg(CommandLine &CmdL)
 	    continue;
 	 
 	 pkgCache::VerIterator Ver = Pkg.VersionList();
-	 for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; D++)
+	 for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; ++D)
 	 {
 	    // See if anything can meet this dep
 	    // Walk along the actual package providing versions
 	    bool Hit = false;
 	    pkgCache::PkgIterator DPkg = D.TargetPkg();
 	    for (pkgCache::VerIterator I = DPkg.VersionList();
-		      I.end() == false && Hit == false; I++)
+		      I.end() == false && Hit == false; ++I)
 	    {
 	       if (Cache->VS->CheckDep(I.VerStr(),D->CompareOp,D.TargetVer()) == true)
 		  Hit = true;
@@ -831,7 +837,7 @@ bool XVcg(CommandLine &CmdL)
 	    
 	    // Follow all provides
 	    for (pkgCache::PrvIterator I = DPkg.ProvidesList(); 
-		      I.end() == false && Hit == false; I++)
+		      I.end() == false && Hit == false; ++I)
 	    {
 	       if (Cache->VS->CheckDep(I.ProvideVersion(),D->CompareOp,D.TargetVer()) == false)
 		  Hit = true;
@@ -848,10 +854,7 @@ bool XVcg(CommandLine &CmdL)
 	       {
 		  /* If a conflicts does not meet anything in the database
 		     then show the relation but do not recurse */
-		  if (Hit == false && 
-		      (D->Type == pkgCache::Dep::Conflicts ||
-		       D->Type == pkgCache::Dep::DpkgBreaks ||
-		       D->Type == pkgCache::Dep::Obsoletes))
+		  if (Hit == false && D.IsNegative() == true)
 		  {
 		     if (Show[D.TargetPkg()->ID] == None && 
 			 Show[D.TargetPkg()->ID] != ToShow)
@@ -894,7 +897,7 @@ bool XVcg(CommandLine &CmdL)
    
    /* Draw the box colours after the fact since we can not tell what colour
       they should be until everything is finished drawing */
-   for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++)
+   for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg)
    {
       if (Show[Pkg->ID] < DoneNR)
 	 continue;
@@ -958,7 +961,7 @@ bool Dotty(CommandLine &CmdL)
    memset(Flags,0,sizeof(*Flags)*Cache->Head().PackageCount);
    
    // Map the shapes
-   for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++)
+   for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg)
    {   
       if (Pkg->VersionList == 0)
       {
@@ -1005,7 +1008,7 @@ bool Dotty(CommandLine &CmdL)
    while (Act == true)
    {
       Act = false;
-      for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++)
+      for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg)
       {
 	 // See we need to show this package
 	 if (Show[Pkg->ID] == None || Show[Pkg->ID] >= DoneNR)
@@ -1029,14 +1032,14 @@ bool Dotty(CommandLine &CmdL)
 	    continue;
 	 
 	 pkgCache::VerIterator Ver = Pkg.VersionList();
-	 for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; D++)
+	 for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; ++D)
 	 {
 	    // See if anything can meet this dep
 	    // Walk along the actual package providing versions
 	    bool Hit = false;
 	    pkgCache::PkgIterator DPkg = D.TargetPkg();
 	    for (pkgCache::VerIterator I = DPkg.VersionList();
-		      I.end() == false && Hit == false; I++)
+		      I.end() == false && Hit == false; ++I)
 	    {
 	       if (Cache->VS->CheckDep(I.VerStr(),D->CompareOp,D.TargetVer()) == true)
 		  Hit = true;
@@ -1044,7 +1047,7 @@ bool Dotty(CommandLine &CmdL)
 	    
 	    // Follow all provides
 	    for (pkgCache::PrvIterator I = DPkg.ProvidesList(); 
-		      I.end() == false && Hit == false; I++)
+		      I.end() == false && Hit == false; ++I)
 	    {
 	       if (Cache->VS->CheckDep(I.ProvideVersion(),D->CompareOp,D.TargetVer()) == false)
 		  Hit = true;
@@ -1060,9 +1063,7 @@ bool Dotty(CommandLine &CmdL)
 	       {
 		  /* If a conflicts does not meet anything in the database
 		     then show the relation but do not recurse */
-		  if (Hit == false && 
-		      (D->Type == pkgCache::Dep::Conflicts ||
-		       D->Type == pkgCache::Dep::Obsoletes))
+		  if (Hit == false && D.IsNegative() == true)
 		  {
 		     if (Show[D.TargetPkg()->ID] == None && 
 			 Show[D.TargetPkg()->ID] != ToShow)
@@ -1082,6 +1083,7 @@ bool Dotty(CommandLine &CmdL)
 	       {
 		  case pkgCache::Dep::Conflicts:
 		  case pkgCache::Dep::Obsoletes:
+		  case pkgCache::Dep::DpkgBreaks:
 		  printf("[color=springgreen];\n");
 		  break;
 		  
@@ -1100,7 +1102,7 @@ bool Dotty(CommandLine &CmdL)
    
    /* Draw the box colours after the fact since we can not tell what colour
       they should be until everything is finished drawing */
-   for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; Pkg++)
+   for (pkgCache::PkgIterator Pkg = Cache->PkgBegin(); Pkg.end() == false; ++Pkg)
    {
       if (Show[Pkg->ID] < DoneNR)
 	 continue;
@@ -1115,59 +1117,10 @@ bool Dotty(CommandLine &CmdL)
    }
    
    printf("}\n");
+   delete[] Show;
+   delete[] Flags;
+   delete[] ShapeMap;
    return true;
-}
-									/*}}}*/
-// DoAdd - Perform an adding operation					/*{{{*/
-// ---------------------------------------------------------------------
-/* */
-bool DoAdd(CommandLine &CmdL)
-{
-   return _error->Error("Unimplemented");
-#if 0   
-   // Make sure there is at least one argument
-   if (CmdL.FileSize() <= 1)
-      return _error->Error("You must give at least one file name");
-   
-   // Open the cache
-   FileFd CacheF(_config->FindFile("Dir::Cache::pkgcache"),FileFd::WriteAny);
-   if (_error->PendingError() == true)
-      return false;
-   
-   DynamicMMap Map(CacheF,MMap::Public);
-   if (_error->PendingError() == true)
-      return false;
-
-   OpTextProgress Progress(*_config);
-   pkgCacheGenerator Gen(Map,Progress);
-   if (_error->PendingError() == true)
-      return false;
-
-   unsigned long Length = CmdL.FileSize() - 1;
-   for (const char **I = CmdL.FileList + 1; *I != 0; I++)
-   {
-      Progress.OverallProgress(I - CmdL.FileList,Length,1,"Generating cache");
-      Progress.SubProgress(Length);
-
-      // Do the merge
-      FileFd TagF(*I,FileFd::ReadOnly);
-      debListParser Parser(TagF);
-      if (_error->PendingError() == true)
-	 return _error->Error("Problem opening %s",*I);
-      
-      if (Gen.SelectFile(*I,"") == false)
-	 return _error->Error("Problem with SelectFile");
-	 
-      if (Gen.MergeList(Parser) == false)
-	 return _error->Error("Problem with MergeList");
-   }
-
-   Progress.Done();
-   GCache = &Gen.GetCache();
-   Stats(CmdL);
-   
-   return true;
-#endif   
 }
 									/*}}}*/
 // DisplayRecord - Displays the complete record for the package		/*{{{*/
@@ -1182,7 +1135,7 @@ bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V)
 
    // Find an appropriate file
    pkgCache::VerFileIterator Vf = V.FileList();
-   for (; Vf.end() == false; Vf++)
+   for (; Vf.end() == false; ++Vf)
       if ((Vf.File()->Flags & pkgCache::Flag::NotSource) == 0)
 	 break;
    if (Vf.end() == true)
@@ -1194,7 +1147,7 @@ bool DisplayRecord(pkgCacheFile &CacheFile, pkgCache::VerIterator V)
       return _error->Error(_("Package file %s is out of sync."),I.FileName());
 
    FileFd PkgF;
-   if (PkgF.Open(I.FileName(), FileFd::ReadOnlyGzip) == false)
+   if (PkgF.Open(I.FileName(), FileFd::ReadOnly, FileFd::Extension) == false)
       return false;
 
    // Read the record
@@ -1321,20 +1274,20 @@ bool Search(CommandLine &CmdL)
 	 continue;
       pkgCache::VerIterator V = Plcy->GetCandidateVer(P);
       if (V.end() == false)
-	 DFList[G->ID].Df = V.DescriptionList().FileList();
+	 DFList[G->ID].Df = V.TranslatedDescription().FileList();
 
       if (DFList[G->ID].NameMatch == false)
 	 continue;
 
       // Include all the packages that provide matching names too
-      for (pkgCache::PrvIterator Prv = P.ProvidesList() ; Prv.end() == false; Prv++)
+      for (pkgCache::PrvIterator Prv = P.ProvidesList() ; Prv.end() == false; ++Prv)
       {
 	 pkgCache::VerIterator V = Plcy->GetCandidateVer(Prv.OwnerPkg());
 	 if (V.end() == true)
 	    continue;
 
 	 unsigned long id = Prv.OwnerPkg().Group()->ID;
-	 DFList[id].Df = V.DescriptionList().FileList();
+	 DFList[id].Df = V.TranslatedDescription().FileList();
 	 DFList[id].NameMatch = true;
       }
    }
@@ -1383,9 +1336,8 @@ bool Search(CommandLine &CmdL)
        return _error->Error("Write to stdout failed");
    return true;
 }
-
-
-/* show automatically installed packages (sorted) */
+									/*}}}*/
+/* ShowAuto - show automatically installed packages (sorted)		{{{*/
 bool ShowAuto(CommandLine &CmdL)
 {
    pkgCacheFile CacheFile;
@@ -1397,15 +1349,16 @@ bool ShowAuto(CommandLine &CmdL)
    std::vector<string> packages;
    packages.reserve(Cache->HeaderP->PackageCount / 3);
    
-   for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; P++)
+   for (pkgCache::PkgIterator P = Cache->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++)
+    for (vector<string>::iterator I = packages.begin(); I != packages.end(); ++I)
             cout << *I << "\n";
 
+   _error->Notice(_("This command is deprecated. Please use 'apt-mark showauto' instead."));
    return true;
 }
 									/*}}}*/
@@ -1416,10 +1369,10 @@ bool ShowPackage(CommandLine &CmdL)
 {
    pkgCacheFile CacheFile;
    CacheSetHelperVirtuals helper(true, GlobalError::NOTICE);
-   APT::VersionSet::Version const select = _config->FindB("APT::Cache::AllVersions", true) ?
-			APT::VersionSet::ALL : APT::VersionSet::CANDIDATE;
-   APT::VersionSet const verset = APT::VersionSet::FromCommandLine(CacheFile, CmdL.FileList + 1, select, helper);
-   for (APT::VersionSet::const_iterator Ver = verset.begin(); Ver != verset.end(); ++Ver)
+   APT::VersionList::Version const select = _config->FindB("APT::Cache::AllVersions", true) ?
+			APT::VersionList::ALL : APT::VersionList::CANDIDATE;
+   APT::VersionList const verset = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1, select, helper);
+   for (APT::VersionList::const_iterator Ver = verset.begin(); Ver != verset.end(); ++Ver)
       if (DisplayRecord(CacheFile, Ver) == false)
 	 return false;
 
@@ -1446,7 +1399,7 @@ bool ShowPkgNames(CommandLine &CmdL)
 
    if (CmdL.FileList[1] != 0)
    {
-      for (;I.end() != true; I++)
+      for (;I.end() != true; ++I)
       {
 	 if (All == false && I->FirstPackage == 0)
 	    continue;
@@ -1460,7 +1413,7 @@ bool ShowPkgNames(CommandLine &CmdL)
    }
    
    // Show all pkgs
-   for (;I.end() != true; I++)
+   for (;I.end() != true; ++I)
    {
       if (All == false && I->FirstPackage == 0)
 	 continue;
@@ -1531,7 +1484,7 @@ bool Policy(CommandLine &CmdL)
    if (CmdL.FileList[1] == 0)
    {
       cout << _("Package files:") << endl;   
-      for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F.end() == false; F++)
+      for (pkgCache::PkgFileIterator F = Cache->FileBegin(); F.end() == false; ++F)
       {
 	 // Locate the associated index files so we can derive a description
 	 pkgIndexFile *Indx;
@@ -1553,7 +1506,7 @@ bool Policy(CommandLine &CmdL)
       // Show any packages have explicit pins
       cout << _("Pinned packages:") << endl;
       pkgCache::PkgIterator I = Cache->PkgBegin();
-      for (;I.end() != true; I++)
+      for (;I.end() != true; ++I)
       {
 	 if (Plcy->GetPriority(I) == 0)
 	    continue;
@@ -1571,7 +1524,6 @@ bool Policy(CommandLine &CmdL)
       return true;
    }
 
-   string const myArch = _config->Find("APT::Architecture");
    char const * const msgInstalled = _("  Installed: ");
    char const * const msgCandidate = _("  Candidate: ");
    short const InstalledLessCandidate =
@@ -1583,15 +1535,9 @@ bool Policy(CommandLine &CmdL)
 
    // Print out detailed information for each package
    APT::CacheSetHelper helper(true, GlobalError::NOTICE);
-   APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1, helper);
-   for (APT::PackageSet::const_iterator I = pkgset.begin(); I != pkgset.end(); ++I)
+   APT::PackageList pkgset = APT::PackageList::FromCommandLine(CacheFile, CmdL.FileList + 1, helper);
+   for (APT::PackageList::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
    {
-      pkgCache::PkgIterator Pkg = I.Group().FindPkg("any");
-
-      for (; Pkg.end() != true; Pkg = I.Group().NextPkg(Pkg)) {
-      if (strcmp(Pkg.Arch(),"all") == 0)
-	 continue;
-
       cout << Pkg.FullName(true) << ":" << endl;
 
       // Installed version
@@ -1622,14 +1568,14 @@ bool Policy(CommandLine &CmdL)
       
       // Show the priority tables
       cout << _("  Version table:") << endl;
-      for (V = Pkg.VersionList(); V.end() == false; V++)
+      for (V = Pkg.VersionList(); V.end() == false; ++V)
       {
 	 if (Pkg.CurrentVer() == V)
 	    cout << " *** " << V.VerStr();
 	 else
 	    cout << "     " << V.VerStr();
 	 cout << " " << Plcy->GetPriority(Pkg) << endl;
-	 for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; VF++)
+	 for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; ++VF)
 	 {
 	    // Locate the associated index files so we can derive a description
 	    pkgIndexFile *Indx;
@@ -1640,7 +1586,6 @@ bool Policy(CommandLine &CmdL)
 		   Indx->Describe(true).c_str());
 	 }
       }
-      }
    }
    
    return true;
@@ -1664,14 +1609,15 @@ bool Madison(CommandLine &CmdL)
       _error->Discard();
 
    APT::CacheSetHelper helper(true, GlobalError::NOTICE);
-   APT::PackageSet pkgset = APT::PackageSet::FromCommandLine(CacheFile, CmdL.FileList + 1, helper);
-   for (APT::PackageSet::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
+   for (const char **I = CmdL.FileList + 1; *I != 0; I++)
    {
-      if (Pkg.end() == false)
+      _error->PushToStack();
+      APT::PackageList pkgset = APT::PackageList::FromString(CacheFile, *I, helper);
+      for (APT::PackageList::const_iterator Pkg = pkgset.begin(); Pkg != pkgset.end(); ++Pkg)
       {
-         for (pkgCache::VerIterator V = Pkg.VersionList(); V.end() == false; V++)
+         for (pkgCache::VerIterator V = Pkg.VersionList(); V.end() == false; ++V)
          {
-            for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; VF++)
+            for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; ++VF)
             {
 // This might be nice, but wouldn't uniquely identify the source -mdz
 //                if (VF.File().Archive() != 0)
@@ -1681,11 +1627,11 @@ bool Madison(CommandLine &CmdL)
 //                }
 
                // Locate the associated index files so we can derive a description
-               for (pkgSourceList::const_iterator S = SrcList->begin(); S != SrcList->end(); S++)
+               for (pkgSourceList::const_iterator S = SrcList->begin(); S != SrcList->end(); ++S)
                {
                     vector<pkgIndexFile *> *Indexes = (*S)->GetIndexFiles();
                     for (vector<pkgIndexFile *>::const_iterator IF = Indexes->begin();
-                         IF != Indexes->end(); IF++)
+                         IF != Indexes->end(); ++IF)
                     {
                          if ((*IF)->FindInCache(*(VF.File().Cache())) == VF.File())
                          {
@@ -1698,16 +1644,21 @@ bool Madison(CommandLine &CmdL)
          }
       }
 
-      
       SrcRecs.Restart();
       pkgSrcRecords::Parser *SrcParser;
-      while ((SrcParser = SrcRecs.Find(Pkg.Name(),false)) != 0)
+      bool foundSomething = false;
+      while ((SrcParser = SrcRecs.Find(*I, false)) != 0)
       {
+         foundSomething = true;
          // Maybe support Release info here too eventually
          cout << setw(10) << SrcParser->Package() << " | "
               << setw(10) << SrcParser->Version() << " | "
               << SrcParser->Index().Describe(true) << endl;
       }
+      if (foundSomething == true)
+	 _error->RevertToStack();
+      else
+	 _error->MergeWithStack();
    }
 
    return true;
@@ -1729,7 +1680,7 @@ bool GenCaches(CommandLine &Cmd)
 /* */
 bool ShowHelp(CommandLine &Cmd)
 {
-   ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,VERSION,
+   ioprintf(cout,_("%s %s for %s compiled on %s %s\n"),PACKAGE,PACKAGE_VERSION,
 	    COMMON_ARCH,__DATE__,__TIME__);
    
    if (_config->FindB("version") == true)
@@ -1737,15 +1688,13 @@ bool ShowHelp(CommandLine &Cmd)
 
    cout << 
     _("Usage: apt-cache [options] command\n"
-      "       apt-cache [options] add file1 [file2 ...]\n"
       "       apt-cache [options] showpkg pkg1 [pkg2 ...]\n"
       "       apt-cache [options] showsrc pkg1 [pkg2 ...]\n"
       "\n"
-      "apt-cache is a low-level tool used to manipulate APT's binary\n"
-      "cache files, and query information from them\n"
+      "apt-cache is a low-level tool used to query information\n"
+      "from APT's binary cache files\n"
       "\n"
       "Commands:\n"
-      "   add - Add a package file to the source cache\n"
       "   gencaches - Build both the package and source cache\n"
       "   showpkg - Show some general information for a single package\n"
       "   showsrc - Show source records\n"
@@ -1755,7 +1704,6 @@ 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"
@@ -1775,15 +1723,6 @@ bool ShowHelp(CommandLine &Cmd)
    return true;
 }
 									/*}}}*/
-// CacheInitialize - Initialize things for apt-cache			/*{{{*/
-// ---------------------------------------------------------------------
-/* */
-void CacheInitialize()
-{
-   _config->Set("quiet",0);
-   _config->Set("help",false);
-}
-									/*}}}*/
 int main(int argc,const char *argv[])					/*{{{*/
 {
    CommandLine::Args Args[] = {
@@ -1804,7 +1743,7 @@ int main(int argc,const char *argv[])					/*{{{*/
       {'c',"config-file",0,CommandLine::ConfigFile},
       {'o',"option",0,CommandLine::ArbItem},
       {0,"installed","APT::Cache::Installed",0},
-      {0,"pre-depends","APT::Cache::ShowPreDepends",0},
+      {0,"pre-depends","APT::Cache::ShowPre-Depends",0},
       {0,"depends","APT::Cache::ShowDepends",0},
       {0,"recommends","APT::Cache::ShowRecommends",0},
       {0,"suggests","APT::Cache::ShowSuggests",0},
@@ -1814,7 +1753,6 @@ int main(int argc,const char *argv[])					/*{{{*/
       {0,"enhances","APT::Cache::ShowEnhances",0},
       {0,0,0,0}};
    CommandLine::Dispatch CmdsA[] = {{"help",&ShowHelp},
-                                    {"add",&DoAdd},
                                     {"gencaches",&GenCaches},
                                     {"showsrc",&ShowSrcPackage},
                                     {0,0}};
@@ -1835,8 +1773,6 @@ int main(int argc,const char *argv[])					/*{{{*/
                                     {"madison",&Madison},
                                     {0,0}};
 
-   CacheInitialize();
-
    // Set up gettext support
    setlocale(LC_ALL,"");
    textdomain(PACKAGE);