X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/303a1703ca47c78f2b5ff6887ba6a10907465874..45b5fa67a850b24cdb983fc2fbbe4268aa6aa632:/cmdline/apt-cache.cc diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 531744546..2e1d43ded 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.10 1998/10/19 23:45:35 jgg Exp $ +// $Id: apt-cache.cc,v 1.14 1998/12/04 22:56:53 jgg Exp $ /* ###################################################################### apt-cache - Manages the cache files @@ -27,6 +27,97 @@ #include /*}}}*/ +// UnMet - Show unmet dependencies /*{{{*/ +// --------------------------------------------------------------------- +/* */ +bool UnMet(pkgCache &Cache) +{ + bool Important = _config->FindB("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;) + { + // Collect or groups + pkgCache::DepIterator Start; + pkgCache::DepIterator End; + D.GlobOr(Start,End); + +/* 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; + do + { + // See if this dep is Ok + pkgCache::Version **VList = Start.AllTargets(); + if (*VList != 0) + { + OK = true; + delete [] VList; + break; + } + delete [] VList; + + if (Start == End) + break; + Start++; + } + while (1); + + // The group is OK + if (OK == true) + continue; + + // Oops, it failed.. + if (Header == false) + cout << "Package " << P.Name() << " version " << + V.VerStr() << " has an unmet dep:" << endl; + Header = true; + + // Print out the dep type + cout << " " << End.DepType() << ": "; + + // Show the group + Start = RealStart; + do + { + cout << Start.TargetPkg().Name(); + if (Start.TargetVer() != 0) + cout << " (" << Start.CompType() << " " << Start.TargetVer() << + ")"; + if (Start == End) + break; + cout << " | "; + Start++; + } + while (1); + + cout << endl; + } + } + } + return true; +} + /*}}}*/ // DumpPackage - Show a dump of a package record /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -44,7 +135,13 @@ bool DumpPackage(pkgCache &Cache,CommandLine &CmdL) cout << "Package: " << Pkg.Name() << endl; cout << "Versions: "; for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; Cur++) - cout << Cur.VerStr() << ','; + { + cout << Cur.VerStr(); + for (pkgCache::VerFileIterator Vf = Cur.FileList(); Vf.end() == false; Vf++) + cout << "(" << Vf.File().FileName() << ")"; + cout << ','; + } + cout << endl; cout << "Reverse Depends: " << endl; @@ -72,6 +169,7 @@ bool DumpPackage(pkgCache &Cache,CommandLine &CmdL) for (pkgCache::PrvIterator Prv = Pkg.ProvidesList(); Prv.end() != true; Prv++) cout << Prv.OwnerPkg().Name() << " " << Prv.OwnerVer().VerStr(); cout << endl; + } return true; @@ -132,6 +230,27 @@ bool Stats(pkgCache &Cache) return true; } /*}}}*/ +// Check - Check some things about the cache /*{{{*/ +// --------------------------------------------------------------------- +/* Debug aide mostly */ +bool Check(pkgCache &Cache) +{ + pkgCache::PkgIterator Pkg = Cache.PkgBegin(); + for (;Pkg.end() != true; Pkg++) + { + if (Pkg.Section() == 0 && Pkg->VersionList != 0) + cout << "Bad section " << Pkg.Name() << endl; + + for (pkgCache::VerIterator Cur = Pkg.VersionList(); + Cur.end() != true; Cur++) + { + if (Cur->Priority < 1 || Cur->Priority > 5) + cout << "Bad prio " << Pkg.Name() << ',' << Cur.VerStr() << " == " << (int)Cur->Priority << endl; + } + } + return true; +} + /*}}}*/ // Dump - show everything /*{{{*/ // --------------------------------------------------------------------- /* */ @@ -222,7 +341,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; @@ -239,7 +358,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); @@ -294,6 +414,8 @@ int ShowHelp() cout << " stats - Show some basic statistics" << endl; cout << " dump - Show the entire file in a terse form" << endl; cout << " dumpavail - Print an available file to stdout" << endl; + cout << " unmet - Show unmet dependencies" << endl; + cout << " check - Check the cache a bit" << endl; cout << endl; cout << "Options:" << endl; cout << " -h This help text." << endl; @@ -323,6 +445,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","Important",0}, {'c',"config-file",0,CommandLine::ConfigFile}, {'o',"option",0,CommandLine::ArbItem}, {0,0,0,0}}; @@ -393,6 +516,18 @@ int main(int argc,const char *argv[]) DumpAvail(Cache); break; } + + if (strcmp(CmdL.FileList[0],"unmet") == 0) + { + UnMet(Cache); + break; + } + + if (strcmp(CmdL.FileList[0],"check") == 0) + { + Check(Cache); + break; + } _error->Error("Invalid operation %s", CmdL.FileList[0]); break;