// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: apt-cache.cc,v 1.32 1999/03/29 19:28:52 jgg Exp $
+// $Id: apt-cache.cc,v 1.36 1999/05/14 02:51:36 jgg Exp $
/* ######################################################################
apt-cache - Manages the cache files
apt-cache provides some functions fo manipulating the cache files.
It uses the command line interface common to all the APT tools. The
only really usefull function right now is dumpavail which is used
- by the dselect method. Everything else is ment as a debug aide.
+ by the dselect method. Everything else is meant as a debug aide.
Returns 100 on failure, 0 on success.
}
cout << "Reverse Provides: " << endl;
for (pkgCache::PrvIterator Prv = Pkg.ProvidesList(); Prv.end() != true; Prv++)
- cout << Prv.OwnerPkg().Name() << " " << Prv.OwnerVer().VerStr();
- cout << endl;
-
+ cout << Prv.OwnerPkg().Name() << " " << Prv.OwnerVer().VerStr() << endl;
}
return true;
return true;
}
/*}}}*/
-// GetCandidateVer - Returns the Candidate install version /*{{{*/
-// ---------------------------------------------------------------------
-/* This should really use the DepCache or something.. Copied from there.
- Allow current is required to filter out the status file when emitting
- an available file. */
-static pkgCache::VerIterator GetCandidateVer(pkgCache::PkgIterator Pkg,
- bool AllowCurrent = true)
-{
- /* Not source/not automatic versions cannot be a candidate version
- unless they are already installed */
- for (pkgCache::VerIterator I = Pkg.VersionList(); I.end() == false; I++)
- {
- if (Pkg.CurrentVer() == I && AllowCurrent == true)
- return I;
-
- for (pkgCache::VerFileIterator J = I.FileList(); J.end() == false; J++)
- if ((J.File()->Flags & pkgCache::Flag::NotSource) == 0 &&
- (J.File()->Flags & pkgCache::Flag::NotAutomatic) == 0)
- return I;
- }
-
- return pkgCache::VerIterator(*GCache,0);
-}
- /*}}}*/
// DumpAvail - Print out the available list /*{{{*/
// ---------------------------------------------------------------------
/* This is needed to make dpkg --merge happy */
for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; P++)
{
// Find the proper version to use. We should probably use the DepCache.
- pkgCache::VerIterator V = GetCandidateVer(P,false);
+ pkgCache::VerIterator V = Cache.GetCandidateVer(P,false);
if (V.end() == true || V.FileList().File() != I)
continue;
for (;I.end() != true; I++)
{
// We search against the install version as that makes the most sense..
- pkgCache::VerIterator V = GetCandidateVer(I);
+ pkgCache::VerIterator V = Cache.GetCandidateVer(I);
if (V.end() == true)
continue;
}
// Find the proper version to use. We should probably use the DepCache.
- pkgCache::VerIterator V = GetCandidateVer(Pkg);
+ pkgCache::VerIterator V = Cache.GetCandidateVer(Pkg);
if (V.end() == true || V.FileList().end() == true)
continue;
if (DisplayRecord(V) == false)
cout << endl;
cout << "apt-cache is a low-level tool used to manipulate APT's binary" << endl;
cout << "cache files stored in " << _config->FindFile("Dir::Cache") << endl;
- cout << "It is not ment for ordinary use only as a debug aide." << endl;
+ cout << "It is not meant for ordinary use only as a debug aide." << endl;
cout << endl;
cout << "Commands:" << endl;
cout << " add - Add an package file to the source cache" << endl;
if (CmdL.DispatchArg(CmdsA,false) == false && _error->PendingError() == false)
{
// Open the cache file
- FileFd CacheF(_config->FindFile("Dir::Cache::pkgcache"),FileFd::ReadOnly);
- MMap Map(CacheF,MMap::Public | MMap::ReadOnly);
+ pkgSourceList List;
+ List.ReadMainList();
+
+ // Generate it and map it
+ OpProgress Prog;
+ MMap *Map = pkgMakeStatusCacheMem(List,Prog);
if (_error->PendingError() == false)
{
- pkgCache Cache(Map);
+ pkgCache Cache(*Map);
GCache = &Cache;
if (_error->PendingError() == false)
CmdL.DispatchArg(CmdsB);
- }
+ }
+ delete Map;
}
// Print any errors or warnings found during parsing