// -*- mode: cpp; mode: fold -*-
// Description /*{{{*/
-// $Id: apt-cache.cc,v 1.45 2001/02/22 06:26:27 jgg Exp $
+// $Id: apt-cache.cc,v 1.51 2001/06/10 02:03:33 jgg Exp $
/* ######################################################################
apt-cache - Manages the cache files
/*}}}*/
pkgCache *GCache = 0;
+pkgSourceList *SrcList = 0;
// LocalitySort - Sort a version list by package file locality /*{{{*/
// ---------------------------------------------------------------------
{
cout << " " << D.ParentPkg().Name() << ',' << D.TargetPkg().Name();
if (D->Version != 0)
- cout << ' ' << D.TargetVer() << endl;
+ cout << ' ' << DeNull(D.TargetVer()) << endl;
else
cout << endl;
}
{
cout << Cur.VerStr() << " - ";
for (pkgCache::DepIterator Dep = Cur.DependsList(); Dep.end() != true; Dep++)
- cout << Dep.TargetPkg().Name() << " (" << (int)Dep->CompareOp << " " << Dep.TargetVer() << ") ";
+ cout << Dep.TargetPkg().Name() << " (" << (int)Dep->CompareOp << " " << DeNull(Dep.TargetVer()) << ") ";
cout << endl;
}
cout << " Version: " << V.VerStr() << endl;
cout << " File: " << V.FileList().File().FileName() << endl;
for (pkgCache::DepIterator D = V.DependsList(); D.end() == false; D++)
- cout << " Depends: " << D.TargetPkg().Name() << ' ' << D.TargetVer() << endl;
+ cout << " Depends: " << D.TargetPkg().Name() << ' ' <<
+ DeNull(D.TargetVer()) << endl;
}
}
cout << " ID: " << F->ID << endl;
cout << " Flags: " << F->Flags << endl;
cout << " Time: " << TimeRFC1123(F->mtime) << endl;
- cout << " Archive: " << F.Archive() << endl;
- cout << " Component: " << F.Component() << endl;
- cout << " Version: " << F.Version() << endl;
- cout << " Origin: " << F.Origin() << endl;
- cout << " Site: " << F.Site() << endl;
- cout << " Label: " << F.Label() << endl;
- cout << " Architecture: " << F.Architecture() << endl;
+ cout << " Archive: " << DeNull(F.Archive()) << endl;
+ cout << " Component: " << DeNull(F.Component()) << endl;
+ cout << " Version: " << DeNull(F.Version()) << endl;
+ cout << " Origin: " << DeNull(F.Origin()) << endl;
+ cout << " Site: " << DeNull(F.Site()) << endl;
+ cout << " Label: " << DeNull(F.Label()) << endl;
+ cout << " Architecture: " << DeNull(F.Architecture()) << endl;
}
return true;
if ((File->Flags & pkgCache::Flag::NotSource) == pkgCache::Flag::NotSource)
{
pkgTagSection Tags;
- TFRewriteData RW[] = {{"Status",0},{}};
+ TFRewriteData RW[] = {{"Status",0},{"Config-Version",0},{}};
const char *Zero = 0;
if (Tags.Scan(Buffer+Jitter,VF.Size+1) == false ||
TFRewrite(stdout,Tags,&Zero,RW) == false)
while ((Parse = SrcRecs.Find(*I,false)) != 0)
cout << Parse->AsStr() << endl;;
}
+ return true;
+}
+ /*}}}*/
+// Policy - Show the results of the preferences file /*{{{*/
+// ---------------------------------------------------------------------
+/* */
+bool Policy(CommandLine &CmdL)
+{
+ if (SrcList == 0)
+ return _error->Error("Generate must be enabled for this function");
+
+ pkgCache &Cache = *GCache;
+ pkgPolicy Plcy(&Cache);
+ if (ReadPinFile(Plcy) == false)
+ return false;
+
+ // Print out all of the package files
+ if (CmdL.FileList[1] == 0)
+ {
+ cout << _("Package Files:") << endl;
+ for (pkgCache::PkgFileIterator F = Cache.FileBegin(); F.end() == false; F++)
+ {
+ // Locate the associated index files so we can derive a description
+ pkgIndexFile *Indx;
+ if (SrcList->FindIndex(F,Indx) == false &&
+ _system->FindIndex(F,Indx) == false)
+ return _error->Error(_("Cache is out of sync, can't x-ref a package file"));
+ printf(_("%4i %s\n"),
+ Plcy.GetPriority(F),Indx->Describe(true).c_str());
+
+ // Print the reference information for the package
+ string Str = F.RelStr();
+ if (Str.empty() == false)
+ printf(" release %s\n",F.RelStr().c_str());
+ if (F.Site() != 0 && F.Site()[0] != 0)
+ printf(" origin %s\n",F.Site());
+ }
+
+ // Show any packages have explicit pins
+ cout << _("Pinned Packages:") << endl;
+ pkgCache::PkgIterator I = Cache.PkgBegin();
+ for (;I.end() != true; I++)
+ {
+ if (Plcy.GetPriority(I) == 0)
+ continue;
+
+ // Print the package name and the version we are forcing to
+ cout << " " << I.Name() << " -> ";
+
+ pkgCache::VerIterator V = Plcy.GetMatch(I);
+ if (V.end() == true)
+ cout << _("(not found)") << endl;
+ else
+ cout << V.VerStr() << endl;
+ }
+
+ return true;
+ }
+
+ // Print out detailed information for each package
+ for (const char **I = CmdL.FileList + 1; *I != 0; I++)
+ {
+ pkgCache::PkgIterator Pkg = Cache.FindPkg(*I);
+ if (Pkg.end() == true)
+ {
+ _error->Warning(_("Unable to locate package %s"),*I);
+ continue;
+ }
+
+ cout << Pkg.Name() << ":" << endl;
+
+ // Installed version
+ cout << _(" Installed: ");
+ if (Pkg->CurrentVer == 0)
+ cout << _("(none)") << endl;
+ else
+ cout << Pkg.CurrentVer().VerStr() << endl;
+
+ // Candidate Version
+ cout << _(" Candidate: ");
+ pkgCache::VerIterator V = Plcy.GetCandidateVer(Pkg);
+ if (V.end() == true)
+ cout << _("(none)") << endl;
+ else
+ cout << V.VerStr() << endl;
+
+ // Pinned version
+ if (Plcy.GetPriority(Pkg) != 0)
+ {
+ cout << _(" Package Pin: ");
+ V = Plcy.GetMatch(Pkg);
+ if (V.end() == true)
+ cout << _("(not found)") << endl;
+ else
+ cout << V.VerStr() << endl;
+ }
+
+ // Show the priority tables
+ cout << _(" Version Table:") << endl;
+ for (V = Pkg.VersionList(); V.end() == false; V++)
+ {
+ if (Pkg.CurrentVer() == V)
+ cout << " *** " << V.VerStr();
+ else
+ cout << " " << V.VerStr();
+ cout << " " << Plcy.GetPriority(Pkg) << endl;
+ for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; VF++)
+ {
+ // Locate the associated index files so we can derive a description
+ pkgIndexFile *Indx;
+ if (SrcList->FindIndex(VF.File(),Indx) == false &&
+ _system->FindIndex(VF.File(),Indx) == false)
+ return _error->Error(_("Cache is out of sync, can't x-ref a package file"));
+ printf(_(" %4i %s\n"),Plcy.GetPriority(VF.File()),
+ Indx->Describe(true).c_str());
+ }
+ }
+ }
+
return true;
}
/*}}}*/
" dump - Show the entire file in a terse form\n"
" dumpavail - Print an available file to stdout\n"
" unmet - Show unmet dependencies\n"
- " check - Check the cache a bit\n"
" search - Search the package list for a regex pattern\n"
" show - Show a readable record for the package\n"
" depends - Show raw dependency information for a package\n"
" pkgnames - List the names of all packages\n"
" dotty - Generate package graphs for GraphVis\n"
+ " policy - Show policy settings\n"
"\n"
"Options:\n"
" -h This help text.\n"
{"dotty",&Dotty},
{"show",&ShowPackage},
{"pkgnames",&ShowPkgNames},
+ {"policy",&Policy},
{0,0}};
CacheInitialize();
else
{
// Open the cache file
- pkgSourceList List;
- List.ReadMainList();
+ SrcList = new pkgSourceList;
+ SrcList->ReadMainList();
// Generate it and map it
OpProgress Prog;
- pkgMakeStatusCache(List,Prog,&Map,true);
+ pkgMakeStatusCache(*SrcList,Prog,&Map,true);
}
if (_error->PendingError() == false)