diff options
| author | Julian Andres Klode <julian.klode@canonical.com> | 2024-10-29 14:06:51 +0100 |
|---|---|---|
| committer | Julian Andres Klode <julian.klode@canonical.com> | 2024-12-19 18:24:37 +0100 |
| commit | 71727c2a761889855b3c1aaf4243649e98032f67 (patch) | |
| tree | fd1753d3042128c580b12a649651c3d8ce243e50 | |
| parent | f6198e45b4cd924f390f977077d96b4545da0c91 (diff) | |
apt show: Add pinning information for --full
Add new fields `APT-Pin`, `APT-Candidate`, and `APT-Release` to the
output, same as in EDSP (limited to one release for now).
| -rw-r--r-- | apt-private/private-show.cc | 12 | ||||
| -rwxr-xr-x | test/integration/test-apt-cli-show | 3 |
2 files changed, 15 insertions, 0 deletions
diff --git a/apt-private/private-show.cc b/apt-private/private-show.cc index 58c5d92c9..3e969ab89 100644 --- a/apt-private/private-show.cc +++ b/apt-private/private-show.cc @@ -221,6 +221,10 @@ static bool DisplayRecordV2(pkgCacheFile &CacheFile, pkgRecords &Recs, /*{{{*/ // Check and load the package list file pkgCache::PkgFileIterator I = Vf.File(); + // Extract the policy object for use later + pkgDepCache::Policy *Policy = CacheFile.GetPolicy(); + if (Policy == nullptr) + return false; // find matching sources.list metaindex pkgSourceList *SrcList = CacheFile.GetSourceList(); pkgIndexFile *Index; @@ -283,6 +287,14 @@ static bool DisplayRecordV2(pkgCacheFile &CacheFile, pkgRecords &Recs, /*{{{*/ if (manual_installed != nullptr) RW.push_back(pkgTagSection::Tag::Rewrite("APT-Manual-Installed", manual_installed)); RW.push_back(pkgTagSection::Tag::Rewrite("APT-Sources", source_index_file)); + if (_config->FindB("APT::Cache::ShowFull", false)) + { + RW.push_back(pkgTagSection::Tag::Rewrite("APT-Pin", std::to_string(Policy->GetPriority(V)))); + if (Policy->GetCandidateVer(V.ParentPkg()) == V) + RW.push_back(pkgTagSection::Tag::Rewrite("APT-Candidate", "yes")); + if (auto Release = I.RelStr(); not I.Flagged(pkgCache::Flag::NotSource) && not Release.empty()) + RW.push_back(pkgTagSection::Tag::Rewrite("APT-Release", Release)); + } FileFd stdoutfd; if (stdoutfd.OpenDescriptor(STDOUT_FILENO, FileFd::WriteOnly, false) == false || diff --git a/test/integration/test-apt-cli-show b/test/integration/test-apt-cli-show index 010775d9b..8f9aa036f 100755 --- a/test/integration/test-apt-cli-show +++ b/test/integration/test-apt-cli-show @@ -57,6 +57,9 @@ SHA256: 0000000000000000000000000000000000000000000000000000000000000000 Download-Size: 42 B APT-Manual-Installed: yes APT-Sources: file:$APTARCHIVE unstable/main all Packages +APT-Pin: 500 +APT-Candidate: yes +APT-Release: a=unstable,n=sid,c=main,b=all Description: Some description That has multiple lines " apt show foo --full |
