// Stats - Dump some nice statistics /*{{{*/
// ---------------------------------------------------------------------
/* */
-static bool Stats(CommandLine &)
+static bool Stats(CommandLine &CmdL)
{
pkgCacheFile CacheFile;
pkgCache *Cache = CacheFile.GetPkgCache();
+
+ if (CmdL.FileSize() > 1) {
+ _error->Error(_("apt-cache stats does not take any arguments"));
+ return false;
+ }
if (unlikely(Cache == NULL))
return false;
}
// Display all solutions
- SPtrArray<pkgCache::Version *> List = D.AllTargets();
- pkgPrioSortList(*Cache,List);
- for (pkgCache::Version **I = List; *I != 0; I++)
+ std::unique_ptr<pkgCache::Version *[]> List(D.AllTargets());
+ pkgPrioSortList(*Cache,List.get());
+ for (pkgCache::Version **I = List.get(); *I != 0; I++)
{
pkgCache::VerIterator V(*Cache,*I);
if (V != Cache->VerP + V.ParentPkg()->VersionList ||
struct ExDescFile
{
pkgCache::DescFile *Df;
+ pkgCache::VerIterator V;
map_id_t ID;
};
if (D.end() == true)
continue;
DFList[G->ID].Df = D.FileList();
+ DFList[G->ID].V = V;
DFList[G->ID].ID = G->ID;
}
if (D.end() == true)
continue;
DFList[id].Df = D.FileList();
+ DFList[id].V = V;
DFList[id].ID = id;
size_t const PrvPatternOffset = id * NumPatterns;
for (unsigned I = 0; I < NumPatterns; ++I)
- PatternMatch[PrvPatternOffset + I] = PatternMatch[PatternOffset + I];
+ PatternMatch[PrvPatternOffset + I] |= PatternMatch[PatternOffset + I];
}
}
if (matchedAll == true)
{
if (ShowFull == true)
- {
- const char *Start;
- const char *End;
- P.GetRec(Start,End);
- fwrite(Start,End-Start,1,stdout);
- putc('\n',stdout);
- }
+ DisplayRecord(CacheFile, J->V);
else
printf("%s - %s\n",P.Name().c_str(),P.ShortDesc().c_str());
}
pkgCache::PkgIterator I = Cache->PkgBegin();
for (;I.end() != true; ++I)
{
- if (Plcy->GetPriority(I) == 0)
+ // Old code for debugging
+ if (_config->FindI("APT::Policy", 1) < 1) {
+ if (Plcy->GetPriority(I) == 0)
+ continue;
+
+ // Print the package name and the version we are forcing to
+ cout << " " << I.FullName(true) << " -> ";
+
+ pkgCache::VerIterator V = Plcy->GetMatch(I);
+ if (V.end() == true)
+ cout << _("(not found)") << endl;
+ else
+ cout << V.VerStr() << endl;
+
continue;
+ }
+ // New code
+ for (pkgCache::VerIterator V = I.VersionList(); !V.end(); V++) {
+ auto Prio = Plcy->GetPriority(V, false);
+ if (Prio == 0)
+ continue;
- // Print the package name and the version we are forcing to
- cout << " " << I.FullName(true) << " -> ";
-
- pkgCache::VerIterator V = Plcy->GetMatch(I);
- if (V.end() == true)
- cout << _("(not found)") << endl;
- else
- cout << V.VerStr() << endl;
- }
-
+ cout << " ";
+ // Print the package name and the version we are forcing to
+ ioprintf(cout, _("%s -> %s with priority %d\n"), I.FullName(true).c_str(), V.VerStr(), Prio);
+ }
+ }
return true;
}
cout << V.VerStr() << endl;
// Pinned version
- if (Plcy->GetPriority(Pkg) != 0)
+ if (_config->FindI("APT::Policy", 1) < 1 && Plcy->GetPriority(Pkg) != 0)
{
cout << _(" Package pin: ");
V = Plcy->GetMatch(Pkg);
cout << " *** " << V.VerStr();
else
cout << " " << V.VerStr();
- cout << " " << Plcy->GetPriority(V) << endl;
+ if (_config->FindI("APT::Policy", 1) < 1)
+ cout << " " << Plcy->GetPriority(Pkg) << endl;
+ else
+ cout << " " << Plcy->GetPriority(V) << endl;
for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; ++VF)
{
// Locate the associated index files so we can derive a description