]> git.saurik.com Git - apt.git/commitdiff
fix apt list output for pkgs in dpkg ^rc state
authorMichael Vogt <mvo@ubuntu.com>
Tue, 8 Apr 2014 07:04:15 +0000 (09:04 +0200)
committerMichael Vogt <mvo@ubuntu.com>
Tue, 8 Apr 2014 07:04:15 +0000 (09:04 +0200)
Packages in the "deinstall ok config-file" have no candidate or
instaleld version. So they must be special cased in the apt list
generation.

apt-private/private-cacheset.cc
apt-private/private-output.cc
test/integration/test-apt-cli-list

index 4a63c7e8178756d1fc433b98014850e6d0be31e5..e37e7b227455e7a44aebc76a2a71d0a1ba203e6c 100644 (file)
@@ -73,7 +73,13 @@ bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
       else 
       {
          pkgPolicy *policy = CacheFile.GetPolicy();
       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();
       }
    }
    progress.Done();
index bbd8545ad1cc1c979ee510b42b213d605cfd41a0..757999167fc280492154980b8d45c58f82950293 100644 (file)
@@ -146,6 +146,10 @@ static std::string GetArchitecture(pkgCacheFile &CacheFile, pkgCache::PkgIterato
    pkgCache::VerIterator inst = P.CurrentVer();
    pkgCache::VerIterator cand = policy->GetCandidateVer(P);
 
    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();
 }
                                                                        /*}}}*/
    return inst ? inst.Arch() : cand.Arch();
 }
                                                                        /*}}}*/
index 47cfb624ae8132b080c67483c883e3cff8c50708..6fc4bc7f6410715755322cea573ac690483a7fd9 100755 (executable)
@@ -51,3 +51,8 @@ bar/now 1.0 i386 [installed,local]
   an autogenerated dummy bar=1.0/installed
 " apt list bar --verbose
 
   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
+