]> git.saurik.com Git - apt.git/blobdiff - apt-private/private-cacheset.cc
Fix incorrect upgradable listing in "apt list" (thanks to Michael Musenbrock)
[apt.git] / apt-private / private-cacheset.cc
index 4a63c7e8178756d1fc433b98014850e6d0be31e5..159e1d8f188d044685b9765cf38f77fc5a1fb729 100644 (file)
@@ -55,7 +55,10 @@ bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile,
       }
       else if (_config->FindB("APT::Cmd::Upgradable") == true)
       {
-         if(P.CurrentVer() && state.Upgradable())
+         pkgPolicy *policy = CacheFile.GetPolicy();
+         if(P.CurrentVer() && 
+            state.Upgradable() && 
+            policy->GetCandidateVer(P) != P.CurrentVer())
          {
              pkgPolicy *policy = CacheFile.GetPolicy();
              output_set.insert(policy->GetCandidateVer(P));
@@ -73,7 +76,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();