X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/e8cbb49ff3647c251152ded28709ebe04b70cc4a..18e20d63eddc69b049ccf3fb01c6393d3e147a9d:/cmdline/apt-cache.cc?ds=sidebyside diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index a11594f21..6acb62cc6 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -1,6 +1,6 @@ // -*- mode: cpp; mode: fold -*- // Description /*{{{*/ -// $Id: apt-cache.cc,v 1.51 2001/06/10 02:03:33 jgg Exp $ +// $Id: apt-cache.cc,v 1.58 2002/03/26 07:38:58 jgg Exp $ /* ###################################################################### apt-cache - Manages the cache files @@ -31,7 +31,8 @@ #include #include -#include +#include +#include #include #include #include @@ -374,8 +375,9 @@ bool DumpAvail(CommandLine &Cmd) if (ReadPinFile(Plcy) == false) return false; - pkgCache::VerFile **VFList = new pkgCache::VerFile *[Cache.HeaderP->PackageCount]; - memset(VFList,0,sizeof(*VFList)*Cache.HeaderP->PackageCount); + unsigned long Count = Cache.HeaderP->PackageCount+1; + pkgCache::VerFile **VFList = new pkgCache::VerFile *[Count]; + 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++) @@ -428,7 +430,7 @@ bool DumpAvail(CommandLine &Cmd) VFList[P->ID] = VF; } - LocalitySort(VFList,Cache.HeaderP->PackageCount,sizeof(*VFList)); + LocalitySort(VFList,Count,sizeof(*VFList)); // Iterate over all the package files and write them out. char *Buffer = new char[Cache.HeaderP->MaxVerFileSize+10]; @@ -945,18 +947,34 @@ bool Search(CommandLine &CmdL) else VFList[P->ID].NameMatch = false; } - + // Doing names only, drop any that dont match.. if (NamesOnly == true && VFList[P->ID].NameMatch == false) continue; // Find the proper version to use. pkgCache::VerIterator V = Plcy.GetCandidateVer(P); - if (V.end() == true) + if (V.end() == false) + VFList[P->ID].Vf = V.FileList(); + } + + // Include all the packages that provide matching names too + for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; P++) + { + if (VFList[P->ID].NameMatch == false) continue; - VFList[P->ID].Vf = V.FileList(); + + for (pkgCache::PrvIterator Prv = P.ProvidesList() ; Prv.end() == false; Prv++) + { + pkgCache::VerIterator V = Plcy.GetCandidateVer(Prv.OwnerPkg()); + if (V.end() == false) + { + VFList[Prv.OwnerPkg()->ID].Vf = V.FileList(); + VFList[Prv.OwnerPkg()->ID].NameMatch = true; + } + } } - + LocalitySort(&VFList->Vf,Cache.HeaderP->PackageCount,sizeof(*VFList)); // Iterate over all the version records and check them @@ -1242,6 +1260,7 @@ bool ShowHelp(CommandLine &Cmd) _("Usage: apt-cache [options] command\n" " apt-cache [options] add file1 [file1 ...]\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" @@ -1250,6 +1269,7 @@ bool ShowHelp(CommandLine &Cmd) " add - Add an 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" " stats - Show some basic statistics\n" " dump - Show the entire file in a terse form\n" " dumpavail - Print an available file to stdout\n" @@ -1320,7 +1340,11 @@ int main(int argc,const char *argv[]) {0,0}}; CacheInitialize(); - + + // Set up gettext support + setlocale(LC_ALL,""); + textdomain(PACKAGE); + // Parse the command line and initialize the package library CommandLine CmdL(Args,_config); if (pkgInitConfig(*_config) == false || @@ -1345,7 +1369,7 @@ int main(int argc,const char *argv[]) if (CmdL.DispatchArg(CmdsA,false) == false && _error->PendingError() == false) { - MMap *Map; + MMap *Map = 0; if (_config->FindB("APT::Cache::Generate",true) == false) { Map = new MMap(*new FileFd(_config->FindFile("Dir::Cache::pkgcache"),