summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2020-05-17 19:47:29 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2020-05-18 15:55:36 +0200
commit55d4d1b51c0d2b78b76f2b233714ed3914b695cf (patch)
tree78629794cf7c04cca28e5b7a281d9b8554ebc465
parentdcdfb4723a9969b443d1c823d735e192c731df69 (diff)
Deal with protected solution providers first
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.
-rw-r--r--apt-pkg/depcache.cc9
1 files 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();