]> git.saurik.com Git - apt.git/blobdiff - cmdline/apt-cache.cc
More Fixes
[apt.git] / cmdline / apt-cache.cc
index 8dc56a72b5763a6502c32cbf3747e25fa771e4eb..227b13c96e8fa421ee9ba0691ce7d0aad38330b9 100644 (file)
@@ -1,6 +1,6 @@
 // -*- mode: cpp; mode: fold -*-
 // Description                                                         /*{{{*/
-// $Id: apt-cache.cc,v 1.40 1999/10/18 04:15:25 jgg Exp $
+// $Id: apt-cache.cc,v 1.42 1999/12/09 07:32:45 jgg Exp $
 /* ######################################################################
    
    apt-cache - Manages the cache files
@@ -589,12 +589,58 @@ bool ShowPackage(CommandLine &CmdL)
       }
       
       // Find the proper version to use. We should probably use the DepCache.
-      pkgCache::VerIterator V = Cache.GetCandidateVer(Pkg);
-      if (V.end() == true || V.FileList().end() == true)
+      if (_config->FindB("APT::Cache::AllVersions","true") == true)
+      {
+        pkgCache::VerIterator V;
+        for (V = Pkg.VersionList(); V.end() == false; V++)
+        {
+           if (DisplayRecord(V) == false)
+              return false;
+        }
+      }
+      else
+      {
+        pkgCache::VerIterator V = Cache.GetCandidateVer(Pkg);
+        if (V.end() == true || V.FileList().end() == true)
+           continue;
+        if (DisplayRecord(V) == false)
+           return false;
+      }      
+   }
+   return true;
+}
+                                                                       /*}}}*/
+// ShowPkgNames - Show package names                                   /*{{{*/
+// ---------------------------------------------------------------------
+/* This does a prefix match on the first argument */
+bool ShowPkgNames(CommandLine &CmdL)
+{
+   pkgCache &Cache = *GCache;
+   pkgCache::PkgIterator I = Cache.PkgBegin();
+   bool All = _config->FindB("APT::Cache::AllNames","false");
+   
+   if (CmdL.FileList[1] != 0)
+   {
+      for (;I.end() != true; I++)
+      {
+        if (All == false && I->VersionList == 0)
+           continue;
+        
+        if (strncmp(I.Name(),CmdL.FileList[1],strlen(CmdL.FileList[1])) == 0)
+           cout << I.Name() << endl;
+      }
+
+      return true;
+   }
+   
+   // Show all pkgs
+   for (;I.end() != true; I++)
+   {
+      if (All == false && I->VersionList == 0)
         continue;
-      if (DisplayRecord(V) == false)
-        return false;
+      cout << I.Name() << endl;
    }
+   
    return true;
 }
                                                                        /*}}}*/
@@ -664,6 +710,7 @@ bool ShowHelp(CommandLine &Cmd)
    cout << "   search - Search the package list for a regex pattern" << endl;
    cout << "   show - Show a readable record for the package" << endl;
    cout << "   depends - Show raw dependency information for a package" << endl;
+   cout << "   pkgnames - List the names of all packages" << endl;
    cout << endl;
    cout << "Options:" << endl;
    cout << "  -h   This help text." << endl;
@@ -698,7 +745,9 @@ int main(int argc,const char *argv[])
       {'i',"important","APT::Cache::Important",0},
       {'f',"full","APT::Cache::ShowFull",0},
       {'g',"no-generate","APT::Cache::NoGenerate",0},
+      {'a',"all-versions","APT::Cache::AllVersions",0},
       {0,"names-only","APT::Cache::NamesOnly",0},
+      {0,"all-names","APT::Cache::AllNames",0},
       {'c',"config-file",0,CommandLine::ConfigFile},
       {'o',"option",0,CommandLine::ArbItem},
       {0,0,0,0}};
@@ -716,6 +765,7 @@ int main(int argc,const char *argv[])
                                     {"search",&Search},
                                     {"depends",&Depends},
                                     {"show",&ShowPackage},
+                                    {"pkgnames",&ShowPkgNames},
                                     {0,0}};
 
    CacheInitialize();