From 8218c642342e431d7e69831bd1a6741b40345bf1 Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Tue, 2 Jun 2020 12:47:12 +0200 Subject: Consider if a fix is successful before claiming it is For protected packages the "Fixing" done via KillList in the ProblemResolver will usually not happen as the state change is not allowed, so the debug message is just confusing and the resolver is needlessly looping here (which might push it over the edge), so if we didn't do our thing successfully here we short-circuit a bit to help the next iteration come to a solution. --- apt-pkg/algorithms.cc | 41 +++++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/algorithms.cc b/apt-pkg/algorithms.cc index ea6d4c39a..c12924c5f 100644 --- a/apt-pkg/algorithms.cc +++ b/apt-pkg/algorithms.cc @@ -841,7 +841,7 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix) pkgCache::DepIterator End; size_t OldSize = 0; - KillList.resize(0); + KillList.clear(); enum {OrRemove,OrKeep} OrOp = OrRemove; for (pkgCache::DepIterator D = Cache[I].InstVerIter(Cache).DependsList(); @@ -1099,33 +1099,38 @@ bool pkgProblemResolver::ResolveInternal(bool const BrokenFix) // Apply the kill list now if (Cache[I].InstallVer != 0) { - for (auto J = KillList.begin(); J != KillList.end(); J++) + for (auto const &J : KillList) { - Change = true; - if ((Cache[J->Dep] & pkgDepCache::DepGNow) == 0) + bool foundSomething = false; + if ((Cache[J.Dep] & pkgDepCache::DepGNow) == 0) { - if (J->Dep.IsNegative() == true) + if (J.Dep.IsNegative() && Cache.MarkDelete(J.Pkg, false, 0, false)) { - if (Debug == true) - clog << " Fixing " << I.FullName(false) << " via remove of " << J->Pkg.FullName(false) << endl; - Cache.MarkDelete(J->Pkg, false, 0, false); + if (Debug) + std::clog << " Fixing " << I.FullName(false) << " via remove of " << J.Pkg.FullName(false) << '\n'; + foundSomething = true; } } - else + else if (Cache.MarkKeep(J.Pkg, false, false)) { - if (Debug == true) - clog << " Fixing " << I.FullName(false) << " via keep of " << J->Pkg.FullName(false) << endl; - Cache.MarkKeep(J->Pkg, false, false); + if (Debug) + std::clog << " Fixing " << I.FullName(false) << " via keep of " << J.Pkg.FullName(false) << '\n'; + foundSomething = true; } - if (Counter > 1) + if (not foundSomething || Counter > 1) { - if (Scores[I->ID] > Scores[J->Pkg->ID]) - Scores[J->Pkg->ID] = Scores[I->ID]; - } - } + if (Scores[I->ID] > Scores[J.Pkg->ID]) + { + Scores[J.Pkg->ID] = Scores[I->ID]; + Change = true; + } + } + if (foundSomething) + Change = true; + } } - } + } } if (Debug == true) -- cgit v1.2.3