From 55d4d1b51c0d2b78b76f2b233714ed3914b695cf Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Sun, 17 May 2020 19:47:29 +0200 Subject: Deal with protected solution providers first MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For positive dependencies this isn't giving much as the dependency should already be satisfied by such a provider if its protectiveness would help, but it doesn't hurt to check them first and for negative dependencies it means that we check those first which are the most likely to fail to be removed – which is a good idea. --- apt-pkg/depcache.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index eb0a02f8f..393c9977a 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -983,13 +983,16 @@ bool pkgDepCache::IsModeChangeOk(ModeList const mode, PkgIterator const &Pkg, /*}}}*/ struct CompareProviders /*{{{*/ { + pkgDepCache const &Cache; pkgCache::PkgIterator const Pkg; - explicit CompareProviders(pkgCache::DepIterator const &Dep) : Pkg(Dep.TargetPkg()) {}; - //bool operator() (APT::VersionList::iterator const &AV, APT::VersionList::iterator const &BV) + explicit CompareProviders(pkgDepCache const &pCache, pkgCache::DepIterator const &Dep) : Cache{pCache}, Pkg{Dep.TargetPkg()} {} bool operator() (pkgCache::VerIterator const &AV, pkgCache::VerIterator const &BV) { pkgCache::PkgIterator const A = AV.ParentPkg(); pkgCache::PkgIterator const B = BV.ParentPkg(); + // Deal with protected first as if they don't work we usually have a problem + if (Cache[A].Protect() != Cache[B].Protect()) + return Cache[A].Protect(); // Prefer MA:same packages if other architectures for it are installed if ((AV->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same || (BV->MultiArch & pkgCache::Version::Same) == pkgCache::Version::Same) @@ -1298,7 +1301,7 @@ static bool MarkInstall_InstallDependencies(pkgDepCache &Cache, bool const Debug continue; APT::VersionVector verlist = APT::VersionVector::FromDependency(CacheFile, Start, APT::CacheSetHelper::CANDIDATE); - std::sort(verlist.begin(), verlist.end(), CompareProviders{Start}); + std::sort(verlist.begin(), verlist.end(), CompareProviders{Cache, Start}); for (auto const &Ver : verlist) { auto P = Ver.ParentPkg(); -- cgit v1.2.3