]> 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 a7dc0e800154f6c14135ec2be283c36ed09d789a..159e1d8f188d044685b9765cf38f77fc5a1fb729 100644 (file)
@@ -1,9 +1,18 @@
+#include <config.h>
+
 #include <apt-pkg/cachefile.h>
 #include <apt-pkg/pkgcache.h>
 #include <apt-pkg/depcache.h>
-#include <apt-pkg/strutl.h>
+#include <apt-pkg/cacheiterators.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/progress.h>
+#include <apt-pkg/policy.h>
+
+#include <apt-private/private-cacheset.h>
 
-#include "private-cacheset.h"
+#include <stddef.h>
+
+#include <apti18n.h>
 
 bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile, 
                                  LocalitySortedVersionSet &output_set,
@@ -46,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));
@@ -64,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();