summaryrefslogtreecommitdiff
path: root/apt-private/private-install.cc
diff options
context:
space:
mode:
Diffstat (limited to 'apt-private/private-install.cc')
-rw-r--r--apt-private/private-install.cc20
1 files changed, 14 insertions, 6 deletions
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc
index 8d1bc74f0..4f71f18c4 100644
--- a/apt-private/private-install.cc
+++ b/apt-private/private-install.cc
@@ -20,6 +20,7 @@
#include <apt-pkg/prettyprinters.h>
#include <apt-pkg/strutl.h>
#include <apt-pkg/upgrade.h>
+#include <apt-pkg/version.h>
#include <algorithm>
#include <cstdlib>
@@ -620,12 +621,14 @@ bool DoAutomaticRemove(CacheFile &Cache)
for (APT::PackageSet::iterator Pkg = tooMuch.begin();
Pkg != tooMuch.end(); ++Pkg)
{
- APT::PackageSet too;
- too.insert(*Pkg);
- for (pkgCache::PrvIterator Prv = Cache[Pkg].CandidateVerIter(Cache).ProvidesList();
- Prv.end() == false; ++Prv)
- too.insert(Prv.ParentPkg());
- for (APT::PackageSet::const_iterator P = too.begin(); P != too.end(); ++P)
+ auto const PkgCand = Cache[Pkg].CandidateVerIter(Cache);
+ if (unlikely(PkgCand.end()))
+ continue;
+ std::vector<std::pair<pkgCache::PkgIterator, char const *>> too;
+ too.emplace_back(*Pkg, PkgCand.VerStr());
+ for (pkgCache::PrvIterator Prv = PkgCand.ProvidesList(); not Prv.end(); ++Prv)
+ too.emplace_back(Prv.ParentPkg(), Prv.ProvideVersion());
+ for (auto const &[P, PVerStr] : too)
{
for (pkgCache::DepIterator R = P.RevDependsList();
R.end() == false; ++R)
@@ -650,6 +653,11 @@ bool DoAutomaticRemove(CacheFile &Cache)
}
else // ignore dependency from a non-candidate version
continue;
+ if (R->Version != 0)
+ {
+ if (not Cache->VS().CheckDep(PVerStr, R->CompareOp, R.TargetVer()))
+ continue;
+ }
if (Debug == true)
std::clog << "Save " << APT::PrettyPkg(Cache, Pkg) << " as another installed package depends on it: " << APT::PrettyPkg(Cache, RP) << std::endl;
Cache->MarkInstall(Pkg, false, 0, false);