X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/83d89a9f6a641adccce898eb0bc675d94bc46465..f826cfaa1c3f9fcf492fb65b22a2d964e78ae7ec:/cmdline/apt-cache.cc diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 3bdeb373c..b20227153 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.13 1998/11/27 01:52:53 jgg Exp $ +// $Id: apt-cache.cc,v 1.16 1998/12/07 00:34:22 jgg Exp $ /* ###################################################################### apt-cache - Manages the cache files @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -32,25 +33,36 @@ /* */ bool UnMet(pkgCache &Cache) { + bool Important = _config->FindB("APT::Cache::Important",false); + for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; P++) { for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; V++) { bool Header = false; - for (pkgCache::DepIterator D = V.DependsList(); D.end() == false; D++) + for (pkgCache::DepIterator D = V.DependsList(); D.end() == false;) { // Collect or groups pkgCache::DepIterator Start; pkgCache::DepIterator End; D.GlobOr(Start,End); - // Skip everything but depends +/* cout << "s: Check " << Start.TargetPkg().Name() << ',' << + End.TargetPkg().Name() << endl;*/ + + // Skip conflicts and replaces if (End->Type != pkgCache::Dep::PreDepends && End->Type != pkgCache::Dep::Depends && End->Type != pkgCache::Dep::Suggests && End->Type != pkgCache::Dep::Recommends) continue; + // Important deps only + if (Important == true) + if (End->Type != pkgCache::Dep::PreDepends && + End->Type != pkgCache::Dep::Depends) + continue; + // Verify the or group bool OK = false; pkgCache::DepIterator RealStart = Start; @@ -169,7 +181,8 @@ bool DumpPackage(pkgCache &Cache,CommandLine &CmdL) /* */ bool Stats(pkgCache &Cache) { - cout << "Total Package Names : " << Cache.Head().PackageCount << endl; + cout << "Total Package Names : " << Cache.Head().PackageCount << " (" << + SizeToStr(Cache.Head().PackageCount*Cache.Head().PackageSz) << ')' << endl; pkgCache::PkgIterator I = Cache.PkgBegin(); int Normal = 0; @@ -214,8 +227,36 @@ bool Stats(pkgCache &Cache) cout << " Mixed Virtual Packages: " << NVirt << endl; cout << " Missing: " << Missing << endl; - cout << "Total Distinct Versions: " << Cache.Head().VersionCount << endl; - cout << "Total Dependencies: " << Cache.Head().DependsCount << endl; + cout << "Total Distinct Versions: " << Cache.Head().VersionCount << " (" << + SizeToStr(Cache.Head().VersionCount*Cache.Head().VersionSz) << ')' << endl; + cout << "Total Dependencies: " << Cache.Head().DependsCount << " (" << + SizeToStr(Cache.Head().DependsCount*Cache.Head().DependencySz) << ')' << endl; + + cout << "Total Ver/File relations: " << Cache.Head().PackageCount << " (" << + SizeToStr(Cache.Head().PackageCount*Cache.Head().PackageSz) << ')' << endl; + + // String list stats + unsigned long Size = 0; + unsigned long Count = 0; + for (pkgCache::StringItem *I = Cache.StringItemP + Cache.Head().StringList; + I!= Cache.StringItemP; I = Cache.StringItemP + I->NextItem) + { + Count++; + Size += strlen(Cache.StrP + I->String); + } + cout << "Total Globbed Strings: " << Count << " (" << SizeToStr(Size) << ')' << endl; + + unsigned long Slack = 0; + for (int I = 0; I != 7; I++) + Slack += Cache.Head().Pools[I].ItemSize*Cache.Head().Pools[I].Count; + cout << "Total Slack space: " << SizeToStr(Slack) << endl; + + unsigned long Total = 0; + Total = Slack + Size + Cache.Head().DependsCount*Cache.Head().DependencySz + + Cache.Head().VersionCount*Cache.Head().VersionSz + + Cache.Head().PackageCount*Cache.Head().PackageSz; + cout << "Total Space Accounted for: " << SizeToStr(Total) << endl; + return true; } /*}}}*/ @@ -330,7 +371,7 @@ bool DoAdd(CommandLine &CmdL) return _error->Error("You must give at least one file name"); // Open the cache - FileFd CacheF(_config->FindFile("Dir::Cache::srcpkgcache"),FileFd::WriteAny); + FileFd CacheF(_config->FindFile("Dir::Cache::pkgcache"),FileFd::WriteAny); if (_error->PendingError() == true) return false; @@ -347,7 +388,8 @@ bool DoAdd(CommandLine &CmdL) 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); @@ -433,6 +475,7 @@ int main(int argc,const char *argv[]) {'p',"pkg-cache","Dir::Cache::pkgcache",CommandLine::HasArg}, {'s',"src-cache","Dir::Cache::srcpkgcache",CommandLine::HasArg}, {'q',"quiet","quiet",CommandLine::IntLevel}, + {'i',"important","APT::Cache::Important",0}, {'c',"config-file",0,CommandLine::ConfigFile}, {'o',"option",0,CommandLine::ArbItem}, {0,0,0,0}};