summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2020-06-02 12:47:12 +0200
committerDavid Kalnischkies <david@kalnischkies.de>2020-06-02 13:14:30 +0200
commit8218c642342e431d7e69831bd1a6741b40345bf1 (patch)
treed2e855d406be3be616887f3320ed407d0db385f7
parent33e19f1fe1655e2d6883ff8d30226fb7db02dd45 (diff)
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.
-rw-r--r--apt-pkg/algorithms.cc41
-rwxr-xr-xtest/integration/test-bug-960705-propagate-protected-to-satisfied-conflict17
2 files changed, 23 insertions, 35 deletions
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)
diff --git a/test/integration/test-bug-960705-propagate-protected-to-satisfied-conflict b/test/integration/test-bug-960705-propagate-protected-to-satisfied-conflict
index 480b6753e..e793193c3 100755
--- a/test/integration/test-bug-960705-propagate-protected-to-satisfied-conflict
+++ b/test/integration/test-bug-960705-propagate-protected-to-satisfied-conflict
@@ -28,26 +28,9 @@ Broken init:amd64 PreDepends on systemd-sysv:amd64 < 1 @ii pmR >
Added systemd-sysv:amd64 to the remove list
Broken init:amd64 PreDepends on sysvinit-core:amd64 < none @un pH >
Considering sysvinit-core:amd64 0 as a solution to init:amd64 5100
- Fixing init:amd64 via keep of systemd-sysv:amd64
Ignore MarkKeep of systemd-sysv:amd64 < 1 @ii pmR > as its mode (Delete) is protected
Investigating (1) init:amd64 < 1 @ii mK Ib >
Broken init:amd64 PreDepends on systemd-sysv:amd64 < 1 @ii pmR >
- Considering systemd-sysv:amd64 0 as a solution to init:amd64 5100
- Added systemd-sysv:amd64 to the remove list
-Broken init:amd64 PreDepends on sysvinit-core:amd64 < none @un pH >
- Considering sysvinit-core:amd64 0 as a solution to init:amd64 5100
- Fixing init:amd64 via keep of systemd-sysv:amd64
- Ignore MarkKeep of systemd-sysv:amd64 < 1 @ii pmR > as its mode (Delete) is protected
-Investigating (2) init:amd64 < 1 @ii mK Ib >
-Broken init:amd64 PreDepends on systemd-sysv:amd64 < 1 @ii pmR >
- Considering systemd-sysv:amd64 0 as a solution to init:amd64 5100
- Added systemd-sysv:amd64 to the remove list
-Broken init:amd64 PreDepends on sysvinit-core:amd64 < none @un pH >
- Considering sysvinit-core:amd64 0 as a solution to init:amd64 5100
- Fixing init:amd64 via keep of systemd-sysv:amd64
- Ignore MarkKeep of systemd-sysv:amd64 < 1 @ii pmR > as its mode (Delete) is protected
-Investigating (3) init:amd64 < 1 @ii mK Ib >
-Broken init:amd64 PreDepends on systemd-sysv:amd64 < 1 @ii pmR >
Considering systemd-sysv:amd64 5100 as a solution to init:amd64 5100
Broken init:amd64 PreDepends on sysvinit-core:amd64 < none @un pH >
Considering sysvinit-core:amd64 0 as a solution to init:amd64 5100