X-Git-Url: https://git.saurik.com/apt.git/blobdiff_plain/258b9e512c4001e806c5c0966acecd3d742ec6e9..2853201580944cb4e5a2a8a810e800e89e9a0475:/apt-private/private-show.cc diff --git a/apt-private/private-show.cc b/apt-private/private-show.cc index 34214d955..03229476e 100644 --- a/apt-private/private-show.cc +++ b/apt-private/private-show.cc @@ -219,6 +219,7 @@ static bool DisplayRecordV2(pkgCacheFile &CacheFile, pkgCache::VerIterator const RW.push_back(pkgTagSection::Tag::Remove("Description")); RW.push_back(pkgTagSection::Tag::Remove("Description-md5")); // improve + RW.push_back(pkgTagSection::Tag::Rewrite("Package", V.ParentPkg().FullName(true))); RW.push_back(pkgTagSection::Tag::Rewrite("Installed-Size", installed_size)); RW.push_back(pkgTagSection::Tag::Remove("Size")); RW.push_back(pkgTagSection::Tag::Rewrite("Download-Size", package_size)); @@ -257,6 +258,8 @@ bool ShowPackage(CommandLine &CmdL) /*{{{*/ CacheSetHelperVirtuals helper(true, GlobalError::NOTICE); APT::CacheSetHelper::VerSelector const select = _config->FindB("APT::Cache::AllVersions", true) ? APT::CacheSetHelper::ALL : APT::CacheSetHelper::CANDIDATE; + if (select == APT::CacheSetHelper::CANDIDATE && CacheFile.GetDepCache() == nullptr) + return false; APT::VersionList const verset = APT::VersionList::FromCommandLine(CacheFile, CmdL.FileList + 1, select, helper); int const ShowVersion = _config->FindI("APT::Cache::Show::Version", 1); for (APT::VersionList::const_iterator Ver = verset.begin(); Ver != verset.end(); ++Ver) @@ -298,6 +301,14 @@ bool ShowPackage(CommandLine &CmdL) /*{{{*/ return true; } /*}}}*/ +static std::string Sha1FromString(std::string const &input) /*{{{*/ +{ + // XXX: move to hashes.h: HashString::FromString() ? + SHA1Summation sha1; + sha1.Add(input.c_str(), input.length()); + return sha1.Result().Value(); +} + /*}}}*/ bool ShowSrcPackage(CommandLine &CmdL) /*{{{*/ { pkgCacheFile CacheFile; @@ -311,6 +322,8 @@ bool ShowSrcPackage(CommandLine &CmdL) /*{{{*/ return false; bool found = false; + // avoid showing identical records + std::set seen; for (const char **I = CmdL.FileList + 1; *I != 0; I++) { SrcRecs.Restart(); @@ -322,9 +335,14 @@ bool ShowSrcPackage(CommandLine &CmdL) /*{{{*/ if (_config->FindB("APT::Cache::Only-Source", false) == true) if (Parse->Package() != *I) continue; - std::cout << Parse->AsStr() << std::endl;; - found = true; - found_this = true; + std::string sha1str = Sha1FromString(Parse->AsStr()); + if (std::find(seen.begin(), seen.end(), sha1str) == seen.end()) + { + std::cout << Parse->AsStr() << std::endl;; + found = true; + found_this = true; + seen.insert(sha1str); + } } if (found_this == false) { _error->Warning(_("Unable to locate package %s"),*I); @@ -340,13 +358,15 @@ bool ShowSrcPackage(CommandLine &CmdL) /*{{{*/ bool Policy(CommandLine &CmdL) { pkgCacheFile CacheFile; - pkgCache *Cache = CacheFile.GetPkgCache(); - pkgPolicy *Plcy = CacheFile.GetPolicy(); - pkgSourceList *SrcList = CacheFile.GetSourceList(); - if (unlikely(Cache == NULL || Plcy == NULL || SrcList == NULL)) + pkgSourceList const * const SrcList = CacheFile.GetSourceList(); + if (unlikely(SrcList == nullptr)) + return false; + pkgCache * const Cache = CacheFile.GetPkgCache(); + if (unlikely(Cache == nullptr)) + return false; + pkgPolicy * const Plcy = CacheFile.GetPolicy(); + if (unlikely(Plcy == nullptr)) return false; - - bool OldPolicy = _config->FindI("APT::Policy", 1) < 1; // Print out all of the package files if (CmdL.FileList[1] == 0) @@ -378,24 +398,6 @@ bool Policy(CommandLine &CmdL) pkgCache::PkgIterator I = Cache->PkgBegin(); for (;I.end() != true; ++I) { - // Old code for debugging - if (OldPolicy) - { - if (Plcy->GetPriority(I) == 0) - continue; - - // Print the package name and the version we are forcing to - std::cout << " " << I.FullName(true) << " -> "; - - pkgCache::VerIterator V = Plcy->GetMatch(I); - if (V.end() == true) - std::cout << _("(not found)") << std::endl; - else - std::cout << V.VerStr() << std::endl; - - continue; - } - // New code for (pkgCache::VerIterator V = I.VersionList(); !V.end(); ++V) { auto Prio = Plcy->GetPriority(V, false); if (Prio == 0) @@ -440,17 +442,6 @@ bool Policy(CommandLine &CmdL) else std::cout << V.VerStr() << std::endl; - // Pinned version - if (OldPolicy && Plcy->GetPriority(Pkg) != 0) - { - std::cout << _(" Package pin: "); - V = Plcy->GetMatch(Pkg); - if (V.end() == true) - std::cout << _("(not found)") << std::endl; - else - std::cout << V.VerStr() << std::endl; - } - // Show the priority tables std::cout << _(" Version table:") << std::endl; for (V = Pkg.VersionList(); V.end() == false; ++V) @@ -459,10 +450,8 @@ bool Policy(CommandLine &CmdL) std::cout << " *** " << V.VerStr(); else std::cout << " " << V.VerStr(); - if (_config->FindI("APT::Policy", 1) < 1) - std::cout << " " << Plcy->GetPriority(Pkg) << std::endl; - else - std::cout << " " << Plcy->GetPriority(V) << std::endl; + + std::cout << " " << Plcy->GetPriority(V) << std::endl; for (pkgCache::VerFileIterator VF = V.FileList(); VF.end() == false; ++VF) { // Locate the associated index files so we can derive a description