// -*- 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
#include <config.h>
#include <apti18n.h>
-#include <iostream.h>
+#include <locale.h>
+#include <iostream>
#include <unistd.h>
#include <errno.h>
#include <regex.h>
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++)
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];
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
_("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"
" 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"
{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 ||
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"),