From 6293e04ff36cd1cb4756fc30a4777ad6aaf8ffac Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 11 Feb 2010 15:41:04 +0100 Subject: display the architecture of the package if it is not the default architecture in apt-get, display policy for all available architectures and use GrpIterator in apt-cache pkgnames --- cmdline/apt-cache.cc | 46 +++++++++++++++++++++++++++++++--------------- 1 file changed, 31 insertions(+), 15 deletions(-) (limited to 'cmdline/apt-cache.cc') diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 7d7f58a62..cd806286c 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -1417,11 +1417,15 @@ bool ShowPackage(CommandLine &CmdL) for (const char **I = CmdL.FileList + 1; *I != 0; I++) { + // FIXME: Handle the case in which pkgname name:arch is not found pkgCache::PkgIterator Pkg = Cache.FindPkg(*I); if (Pkg.end() == true) { - _error->Warning(_("Unable to locate package %s"),*I); - continue; + Pkg = Cache.FindPkg(*I, "any"); + if (Pkg.end() == true) { + _error->Warning(_("Unable to locate package %s"),*I); + continue; + } } ++found; @@ -1457,16 +1461,17 @@ bool ShowPackage(CommandLine &CmdL) bool ShowPkgNames(CommandLine &CmdL) { pkgCache &Cache = *GCache; - pkgCache::PkgIterator I = Cache.PkgBegin(); - bool All = _config->FindB("APT::Cache::AllNames","false"); - + pkgCache::GrpIterator I = Cache.GrpBegin(); + bool const All = _config->FindB("APT::Cache::AllNames","false"); + if (CmdL.FileList[1] != 0) { for (;I.end() != true; I++) { - if (All == false && I->VersionList == 0) + if (All == false && I->FirstPackage == 0) + continue; + if (I.FindPkg("any")->VersionList == 0) continue; - if (strncmp(I.Name(),CmdL.FileList[1],strlen(CmdL.FileList[1])) == 0) cout << I.Name() << endl; } @@ -1477,7 +1482,9 @@ bool ShowPkgNames(CommandLine &CmdL) // Show all pkgs for (;I.end() != true; I++) { - if (All == false && I->VersionList == 0) + if (All == false && I->FirstPackage == 0) + continue; + if (I.FindPkg("any")->VersionList == 0) continue; cout << I.Name() << endl; } @@ -1565,19 +1572,27 @@ bool Policy(CommandLine &CmdL) return true; } - + + string const myArch = _config->Find("APT::Architecture"); + // Print out detailed information for each package for (const char **I = CmdL.FileList + 1; *I != 0; I++) { - pkgCache::PkgIterator Pkg = Cache.FindPkg(*I); + pkgCache::GrpIterator Grp = Cache.FindGrp(*I); + pkgCache::PkgIterator Pkg = Grp.FindPkg("any"); if (Pkg.end() == true) { _error->Warning(_("Unable to locate package %s"),*I); continue; } - - cout << Pkg.Name() << ":" << endl; - + + for (; Pkg.end() != true; Pkg = Grp.NextPkg(Pkg)) { + + if (myArch == Pkg.Arch()) + cout << Pkg.Name() << ":" << endl; + else + cout << Pkg.Name() << ": [" << Pkg.Arch() << "]" << endl; + // Installed version cout << _(" Installed: "); if (Pkg->CurrentVer == 0) @@ -1622,8 +1637,9 @@ bool Policy(CommandLine &CmdL) 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; -- cgit v1.2.3 From 803ea2a87f81252b2c0d541b8502ed206ce57c84 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 12 Feb 2010 00:04:31 +0100 Subject: Add yet another pseudo package which isn't as pseudo as the others: Arch all packages are now represented by arch depending packages which all depend on a package with the same name and the special arch "all". This packages has NO dependencies, but beside this the same information. It is the only package which has a size, the arch depending ones all have a zero size. While the arch depending pseudo packages are used for dependency resolution the arch "all" package is used for downloading and ordering of the package. --- cmdline/apt-cache.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'cmdline/apt-cache.cc') diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index cd806286c..275daa187 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -1587,6 +1587,8 @@ bool Policy(CommandLine &CmdL) } for (; Pkg.end() != true; Pkg = Grp.NextPkg(Pkg)) { + if (strcmp(Pkg.Arch(),"all") == 0) + continue; if (myArch == Pkg.Arch()) cout << Pkg.Name() << ":" << endl; -- cgit v1.2.3 From 75ce206243e409b170d06723430eb85a4a747882 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Fri, 26 Feb 2010 20:47:19 +0100 Subject: move ShowPkg() from apt-get to the PkgIterator and rename it to FullName() responseable for displaying a package name and the architecture in a uniform way. Pretty option can be used to not append the architecture if it is the native architecture or all - and use it all over the place in the commandline tools. --- cmdline/apt-cache.cc | 59 +++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 31 deletions(-) (limited to 'cmdline/apt-cache.cc') diff --git a/cmdline/apt-cache.cc b/cmdline/apt-cache.cc index 8323a740e..355e9aefb 100644 --- a/cmdline/apt-cache.cc +++ b/cmdline/apt-cache.cc @@ -139,7 +139,7 @@ bool UnMet(CommandLine &CmdL) // Oops, it failed.. if (Header == false) ioprintf(cout,_("Package %s version %s has an unmet dep:\n"), - P.Name(),V.VerStr()); + P.FullName(true).c_str(),V.VerStr()); Header = true; // Print out the dep type @@ -149,7 +149,7 @@ bool UnMet(CommandLine &CmdL) Start = RealStart; do { - cout << Start.TargetPkg().Name(); + cout << Start.TargetPkg().FullName(true); if (Start.TargetVer() != 0) cout << " (" << Start.CompType() << " " << Start.TargetVer() << ")"; @@ -182,7 +182,7 @@ bool DumpPackage(CommandLine &CmdL) continue; } - cout << "Package: " << Pkg.Name() << endl; + cout << "Package: " << Pkg.FullName(true) << endl; cout << "Versions: " << endl; for (pkgCache::VerIterator Cur = Pkg.VersionList(); Cur.end() != true; Cur++) { @@ -204,7 +204,7 @@ bool DumpPackage(CommandLine &CmdL) cout << "Reverse Depends: " << endl; for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() != true; D++) { - cout << " " << D.ParentPkg().Name() << ',' << D.TargetPkg().Name(); + cout << " " << D.ParentPkg().FullName(true) << ',' << D.TargetPkg().FullName(true); if (D->Version != 0) cout << ' ' << DeNull(D.TargetVer()) << endl; else @@ -216,7 +216,7 @@ bool DumpPackage(CommandLine &CmdL) { cout << Cur.VerStr() << " - "; for (pkgCache::DepIterator Dep = Cur.DependsList(); Dep.end() != true; Dep++) - cout << Dep.TargetPkg().Name() << " (" << (int)Dep->CompareOp << " " << DeNull(Dep.TargetVer()) << ") "; + cout << Dep.TargetPkg().FullName(true) << " (" << (int)Dep->CompareOp << " " << DeNull(Dep.TargetVer()) << ") "; cout << endl; } @@ -225,12 +225,12 @@ bool DumpPackage(CommandLine &CmdL) { cout << Cur.VerStr() << " - "; for (pkgCache::PrvIterator Prv = Cur.ProvidesList(); Prv.end() != true; Prv++) - cout << Prv.ParentPkg().Name() << " "; + cout << Prv.ParentPkg().FullName(true) << " "; cout << endl; } cout << "Reverse Provides: " << endl; for (pkgCache::PrvIterator Prv = Pkg.ProvidesList(); Prv.end() != true; Prv++) - cout << Prv.OwnerPkg().Name() << " " << Prv.OwnerVer().VerStr() << endl; + cout << Prv.OwnerPkg().FullName(true) << " " << Prv.OwnerVer().VerStr() << endl; } return true; @@ -353,13 +353,13 @@ bool Dump(CommandLine &Cmd) for (pkgCache::PkgIterator P = Cache.PkgBegin(); P.end() == false; P++) { - cout << "Package: " << P.Name() << endl; + cout << "Package: " << P.FullName(true) << endl; for (pkgCache::VerIterator V = P.VersionList(); V.end() == false; V++) { 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() << ' ' << + cout << " Depends: " << D.TargetPkg().FullName(true) << ' ' << DeNull(D.TargetVer()) << endl; for (pkgCache::DescIterator D = V.DescriptionList(); D.end() == false; D++) { @@ -570,11 +570,11 @@ bool Depends(CommandLine &CmdL) pkgCache::VerIterator Ver = Pkg.VersionList(); if (Ver.end() == true) { - cout << '<' << Pkg.Name() << '>' << endl; + cout << '<' << Pkg.FullName(true) << '>' << endl; continue; } - cout << Pkg.Name() << endl; + cout << Pkg.FullName(true) << endl; for (pkgCache::DepIterator D = Ver.DependsList(); D.end() == false; D++) { @@ -596,9 +596,9 @@ bool Depends(CommandLine &CmdL) // Show the package if (Trg->VersionList == 0) - cout << D.DepType() << ": <" << Trg.Name() << ">" << endl; + cout << D.DepType() << ": <" << Trg.FullName(true) << ">" << endl; else - cout << D.DepType() << ": " << Trg.Name() << endl; + cout << D.DepType() << ": " << Trg.FullName(true) << endl; if (Recurse == true) Colours[D.TargetPkg()->ID]++; @@ -614,7 +614,7 @@ bool Depends(CommandLine &CmdL) if (V != Cache.VerP + V.ParentPkg()->VersionList || V->ParentPkg == D->Package) continue; - cout << " " << V.ParentPkg().Name() << endl; + cout << " " << V.ParentPkg().FullName(true) << endl; if (Recurse == true) Colours[D.ParentPkg()->ID]++; @@ -663,11 +663,11 @@ bool RDepends(CommandLine &CmdL) pkgCache::VerIterator Ver = Pkg.VersionList(); if (Ver.end() == true) { - cout << '<' << Pkg.Name() << '>' << endl; + cout << '<' << Pkg.FullName(true) << '>' << endl; continue; } - cout << Pkg.Name() << endl; + cout << Pkg.FullName(true) << endl; cout << "Reverse Depends:" << endl; for (pkgCache::DepIterator D = Pkg.RevDependsList(); D.end() == false; D++) @@ -684,9 +684,9 @@ bool RDepends(CommandLine &CmdL) cout << " "; if (Trg->VersionList == 0) - cout << D.DepType() << ": <" << Trg.Name() << ">" << endl; + cout << D.DepType() << ": <" << Trg.FullName(true) << ">" << endl; else - cout << Trg.Name() << endl; + cout << Trg.FullName(true) << endl; if (Recurse == true) Colours[D.ParentPkg()->ID]++; @@ -702,7 +702,7 @@ bool RDepends(CommandLine &CmdL) if (V != Cache.VerP + V.ParentPkg()->VersionList || V->ParentPkg == D->Package) continue; - cout << " " << V.ParentPkg().Name() << endl; + cout << " " << V.ParentPkg().FullName(true) << endl; if (Recurse == true) Colours[D.ParentPkg()->ID]++; @@ -863,7 +863,7 @@ bool XVcg(CommandLine &CmdL) // Only graph critical deps if (D.IsCritical() == true) { - printf ("edge: { sourcename: \"%s\" targetname: \"%s\" class: 2 ",Pkg.Name(), D.TargetPkg().Name() ); + printf ("edge: { sourcename: \"%s\" targetname: \"%s\" class: 2 ",Pkg.FullName(true).c_str(), D.TargetPkg().FullName(true).c_str() ); // Colour the node for recursion if (Show[D.TargetPkg()->ID] <= DoneNR) @@ -922,10 +922,10 @@ bool XVcg(CommandLine &CmdL) continue; if (Show[Pkg->ID] == DoneNR) - printf("node: { title: \"%s\" label: \"%s\" color: orange shape: %s }\n", Pkg.Name(), Pkg.Name(), + printf("node: { title: \"%s\" label: \"%s\" color: orange shape: %s }\n", Pkg.FullName(true).c_str(), Pkg.FullName(true).c_str(), Shapes[ShapeMap[Pkg->ID]]); else - printf("node: { title: \"%s\" label: \"%s\" shape: %s }\n", Pkg.Name(), Pkg.Name(), + printf("node: { title: \"%s\" label: \"%s\" shape: %s }\n", Pkg.FullName(true).c_str(), Pkg.FullName(true).c_str(), Shapes[ShapeMap[Pkg->ID]]); } @@ -1084,7 +1084,7 @@ bool Dotty(CommandLine &CmdL) // Only graph critical deps if (D.IsCritical() == true) { - printf("\"%s\" -> \"%s\"",Pkg.Name(),D.TargetPkg().Name()); + printf("\"%s\" -> \"%s\"",Pkg.FullName(true).c_str(),D.TargetPkg().FullName(true).c_str()); // Colour the node for recursion if (Show[D.TargetPkg()->ID] <= DoneNR) @@ -1138,10 +1138,10 @@ bool Dotty(CommandLine &CmdL) // Orange box for early recursion stoppage if (Show[Pkg->ID] == DoneNR) - printf("\"%s\" [color=orange,shape=%s];\n",Pkg.Name(), + printf("\"%s\" [color=orange,shape=%s];\n",Pkg.FullName(true).c_str(), Shapes[ShapeMap[Pkg->ID]]); else - printf("\"%s\" [shape=%s];\n",Pkg.Name(), + printf("\"%s\" [shape=%s];\n",Pkg.FullName(true).c_str(), Shapes[ShapeMap[Pkg->ID]]); } @@ -1561,7 +1561,7 @@ bool Policy(CommandLine &CmdL) continue; // Print the package name and the version we are forcing to - cout << " " << I.Name() << " -> "; + cout << " " << I.FullName(true) << " -> "; pkgCache::VerIterator V = Plcy.GetMatch(I); if (V.end() == true) @@ -1590,10 +1590,7 @@ bool Policy(CommandLine &CmdL) if (strcmp(Pkg.Arch(),"all") == 0) continue; - if (myArch == Pkg.Arch()) - cout << Pkg.Name() << ":" << endl; - else - cout << Pkg.Name() << ": [" << Pkg.Arch() << "]" << endl; + cout << Pkg.FullName(true) << ":" << endl; // Installed version cout << _(" Installed: "); @@ -1691,7 +1688,7 @@ bool Madison(CommandLine &CmdL) { if ((*IF)->FindInCache(*(VF.File().Cache())) == VF.File()) { - cout << setw(10) << Pkg.Name() << " | " << setw(10) << V.VerStr() << " | " + cout << setw(10) << Pkg.FullName(true) << " | " << setw(10) << V.VerStr() << " | " << (*IF)->Describe(true) << endl; } } -- cgit v1.2.3