From: Michael Vogt Date: Tue, 8 Apr 2014 07:04:15 +0000 (+0200) Subject: fix apt list output for pkgs in dpkg ^rc state X-Git-Tag: 1.0.2~8^2 X-Git-Url: https://git.saurik.com/apt.git/commitdiff_plain/c8259fcde18ad9e08fffb04bf06ed64b87b1ac6a?hp=d5b21526b38f816974182c5f56db0e09a0446112 fix apt list output for pkgs in dpkg ^rc state Packages in the "deinstall ok config-file" have no candidate or instaleld version. So they must be special cased in the apt list generation. --- diff --git a/apt-private/private-cacheset.cc b/apt-private/private-cacheset.cc index 4a63c7e81..e37e7b227 100644 --- a/apt-private/private-cacheset.cc +++ b/apt-private/private-cacheset.cc @@ -73,7 +73,13 @@ bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile, else { pkgPolicy *policy = CacheFile.GetPolicy(); - output_set.insert(policy->GetCandidateVer(P)); + if (policy->GetCandidateVer(P).IsGood()) + output_set.insert(policy->GetCandidateVer(P)); + else + // no candidate, this may happen for packages in + // dpkg "deinstall ok config-file" state - we pick the first ver + // (which should be the only one) + output_set.insert(P.VersionList()); } } progress.Done(); diff --git a/apt-private/private-output.cc b/apt-private/private-output.cc index bbd8545ad..757999167 100644 --- a/apt-private/private-output.cc +++ b/apt-private/private-output.cc @@ -146,6 +146,10 @@ static std::string GetArchitecture(pkgCacheFile &CacheFile, pkgCache::PkgIterato pkgCache::VerIterator inst = P.CurrentVer(); pkgCache::VerIterator cand = policy->GetCandidateVer(P); + // this may happen for packages in dpkg "deinstall ok config-file" state + if (inst.IsGood() == false && cand.IsGood() == false) + return P.VersionList().Arch(); + return inst ? inst.Arch() : cand.Arch(); } /*}}}*/ diff --git a/test/integration/test-apt-cli-list b/test/integration/test-apt-cli-list index 47cfb624a..6fc4bc7f6 100755 --- a/test/integration/test-apt-cli-list +++ b/test/integration/test-apt-cli-list @@ -51,3 +51,8 @@ bar/now 1.0 i386 [installed,local] an autogenerated dummy bar=1.0/installed " apt list bar --verbose +# test for dpkg ^rc state +insertinstalledpackage 'conf-only' 'i386' '1.0' '' '' 'deinstall ok config-files' +testequal "Listing... +conf-only/now 1.0 i386 [residual-config]" apt list conf-only +