From d059cc2668f284a7db77a15d1d742326d464e963 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 5 Sep 2014 12:03:28 +0200 Subject: Fix incorrect upgradable listing in "apt list" (thanks to Michael Musenbrock) The "apt list" command was using only the pkgDepCache but not the pkgPolicy to figure out if a package is upgradable. This lead to incorrect display of upgradable package when the user used the policy to pin-down packages. Thanks to Michael Musenbrock for the initial patch. Closes: #753297 --- apt-private/private-cacheset.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'apt-private/private-cacheset.cc') diff --git a/apt-private/private-cacheset.cc b/apt-private/private-cacheset.cc index e37e7b227..159e1d8f1 100644 --- a/apt-private/private-cacheset.cc +++ b/apt-private/private-cacheset.cc @@ -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)); -- cgit v1.2.3 From 592d06b6f3c2ef2ae47c38005ae3c4e96a0841f2 Mon Sep 17 00:00:00 2001 From: Michael Vogt Date: Fri, 5 Sep 2014 12:50:15 +0200 Subject: Ensure we have a Policy in CacheFile.BuildDepCache() This partly reverts d059cc2 and fixes bug #753297 in a more general way by ensuring that CacheFile.BuildDepCache() builds a pkgPolicy if there isn't one already. --- apt-private/private-cacheset.cc | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'apt-private/private-cacheset.cc') diff --git a/apt-private/private-cacheset.cc b/apt-private/private-cacheset.cc index 159e1d8f1..e37e7b227 100644 --- a/apt-private/private-cacheset.cc +++ b/apt-private/private-cacheset.cc @@ -55,10 +55,7 @@ bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile, } else if (_config->FindB("APT::Cmd::Upgradable") == true) { - pkgPolicy *policy = CacheFile.GetPolicy(); - if(P.CurrentVer() && - state.Upgradable() && - policy->GetCandidateVer(P) != P.CurrentVer()) + if(P.CurrentVer() && state.Upgradable()) { pkgPolicy *policy = CacheFile.GetPolicy(); output_set.insert(policy->GetCandidateVer(P)); -- cgit v1.2.3 From 25594bb5bddc031afc4d62f3164cd9116d778517 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 2 Sep 2014 18:20:49 +0200 Subject: make GetLocalitySortedVersionSet more generic MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit No reason in and of by itself at the moment, but prepares for the goal of having 'apt search' and 'apt-cache search' using the same code now that they at least support the same stuff. The 'apt' code is just a multitude slower at the moment… Git-Dch: Ignore --- apt-private/private-cacheset.cc | 89 +++++++++++++++++++++-------------------- 1 file changed, 46 insertions(+), 43 deletions(-) (limited to 'apt-private/private-cacheset.cc') diff --git a/apt-private/private-cacheset.cc b/apt-private/private-cacheset.cc index e37e7b227..eb77be274 100644 --- a/apt-private/private-cacheset.cc +++ b/apt-private/private-cacheset.cc @@ -14,74 +14,77 @@ #include -bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile, - LocalitySortedVersionSet &output_set, - OpProgress &progress) +bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile, + APT::VersionContainerInterface * const vci, + OpProgress * const progress) { Matcher null_matcher = Matcher(); - return GetLocalitySortedVersionSet(CacheFile, output_set, + return GetLocalitySortedVersionSet(CacheFile, vci, null_matcher, progress); } -bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile, - LocalitySortedVersionSet &output_set, +bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile, + APT::VersionContainerInterface * const vci, Matcher &matcher, - OpProgress &progress) + OpProgress * const progress) { pkgCache *Cache = CacheFile.GetPkgCache(); pkgDepCache *DepCache = CacheFile.GetDepCache(); + APT::CacheSetHelper helper(false); int Done=0; - progress.SubProgress(Cache->Head().PackageCount, _("Sorting")); + if (progress != NULL) + progress->SubProgress(Cache->Head().PackageCount, _("Sorting")); + + bool const insertCurrentVer = _config->FindB("APT::Cmd::Installed", false); + bool const insertUpgradable = _config->FindB("APT::Cmd::Upgradable", false); + bool const insertManualInstalled = _config->FindB("APT::Cmd::Manual-Installed", false); + for (pkgCache::PkgIterator P = Cache->PkgBegin(); P.end() == false; ++P) { - if (Done%500 == 0) - progress.Progress(Done); - Done++; + if (progress != NULL) + { + if (Done % 500 == 0) + progress->Progress(Done); + ++Done; + } + + // exclude virtual pkgs + if (P->VersionList == 0) + continue; if ((matcher)(P) == false) - continue; + continue; - // exclude virtual pkgs - if (P.VersionList() == 0) - continue; pkgDepCache::StateCache &state = (*DepCache)[P]; - if (_config->FindB("APT::Cmd::Installed") == true) + if (insertCurrentVer == true) { - if (P.CurrentVer() != NULL) - { - output_set.insert(P.CurrentVer()); - } + if (P->CurrentVer != 0) + vci->FromPackage(vci, CacheFile, P, APT::VersionContainerInterface::INSTALLED, helper); } - else if (_config->FindB("APT::Cmd::Upgradable") == true) + else if (insertUpgradable == true) { - if(P.CurrentVer() && state.Upgradable()) - { - pkgPolicy *policy = CacheFile.GetPolicy(); - output_set.insert(policy->GetCandidateVer(P)); - } + if(P.CurrentVer() && state.Upgradable()) + vci->FromPackage(vci, CacheFile, P, APT::VersionContainerInterface::CANDIDATE, helper); } - else if (_config->FindB("APT::Cmd::Manual-Installed") == true) + else if (insertManualInstalled == true) { - if (P.CurrentVer() && - ((*DepCache)[P].Flags & pkgCache::Flag::Auto) == false) - { - pkgPolicy *policy = CacheFile.GetPolicy(); - output_set.insert(policy->GetCandidateVer(P)); - } + if (P.CurrentVer() && + ((*DepCache)[P].Flags & pkgCache::Flag::Auto) == false) + vci->FromPackage(vci, CacheFile, P, APT::VersionContainerInterface::CANDIDATE, helper); } - else + else { - pkgPolicy *policy = CacheFile.GetPolicy(); - 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()); + if (vci->FromPackage(vci, CacheFile, P, APT::VersionContainerInterface::CANDIDATE, helper) == false) + { + // 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) + vci->insert(P.VersionList()); + } } } - progress.Done(); + if (progress != NULL) + progress->Done(); return true; } -- cgit v1.2.3 From fdba4d53d6b9b594531c34792798f4044a25157e Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Wed, 3 Sep 2014 18:16:16 +0200 Subject: rework cachesets API to allow future extension MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The introduction of Fnmatch showed that each new selector would require multiple new virtual methods in the CacheSetHelper to work correctly, which isn't that great. We now flip to a single virtual method which handles all cases separated by an enum – as new enum values can be added without an ABI break. Great care was taken to make old code work with the new way of organisation, which means in return that you might be bombarded with deprecation warnings now if you don't adapt, but code should still compile and work as before as can be seen in apt itself with this commit. Git-Dch: Ignore --- apt-private/private-cacheset.cc | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'apt-private/private-cacheset.cc') diff --git a/apt-private/private-cacheset.cc b/apt-private/private-cacheset.cc index eb77be274..cb68024db 100644 --- a/apt-private/private-cacheset.cc +++ b/apt-private/private-cacheset.cc @@ -60,22 +60,22 @@ bool GetLocalitySortedVersionSet(pkgCacheFile &CacheFile, if (insertCurrentVer == true) { if (P->CurrentVer != 0) - vci->FromPackage(vci, CacheFile, P, APT::VersionContainerInterface::INSTALLED, helper); + vci->FromPackage(vci, CacheFile, P, APT::CacheSetHelper::INSTALLED, helper); } else if (insertUpgradable == true) { if(P.CurrentVer() && state.Upgradable()) - vci->FromPackage(vci, CacheFile, P, APT::VersionContainerInterface::CANDIDATE, helper); + vci->FromPackage(vci, CacheFile, P, APT::CacheSetHelper::CANDIDATE, helper); } else if (insertManualInstalled == true) { if (P.CurrentVer() && ((*DepCache)[P].Flags & pkgCache::Flag::Auto) == false) - vci->FromPackage(vci, CacheFile, P, APT::VersionContainerInterface::CANDIDATE, helper); + vci->FromPackage(vci, CacheFile, P, APT::CacheSetHelper::CANDIDATE, helper); } else { - if (vci->FromPackage(vci, CacheFile, P, APT::VersionContainerInterface::CANDIDATE, helper) == false) + if (vci->FromPackage(vci, CacheFile, P, APT::CacheSetHelper::CANDIDATE, helper) == false) { // no candidate, this may happen for packages in // dpkg "deinstall ok config-file" state - we pick the first ver -- cgit v1.2.3