diff options
| author | Julian Andres Klode <julian.klode@canonical.com> | 2024-05-19 17:42:34 +0200 |
|---|---|---|
| committer | Julian Andres Klode <julian.klode@canonical.com> | 2024-05-24 17:01:55 +0200 |
| commit | acb77872861834d3c5b98ca2e81e0336a388e9f0 (patch) | |
| tree | f276d3082cfc2d3ded7bf6dc556113b733437154 /apt-pkg/solver3.cc | |
| parent | b5997949909ee9d5e9981c8311aea97c7b2620fd (diff) | |
solver3: Try candidate before installed version on upgrade
This fixes --no-strict-pinning attempting to upgrade all the versions
on the system. Adjust the upgrade test case accordingly:
1) no-strict-pinning pulls in systemd despite it being pinned down due
to a dependenc (this was true before this fix)
2) no-strict-pinning does not pull in the upgrade-simple because nothing
depends on it (this is what the test fixes)
Diffstat (limited to 'apt-pkg/solver3.cc')
| -rw-r--r-- | apt-pkg/solver3.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc index ab66c9501..58fb07c01 100644 --- a/apt-pkg/solver3.cc +++ b/apt-pkg/solver3.cc @@ -46,8 +46,15 @@ struct CompareProviders3 /*{{{*/ { if (AV == BV) return false; - if (not upgrade && A->CurrentVer != 0 && A.CurrentVer() == AV) - return true; + // The current version should win, unless we are upgrading and the other is the + // candidate. + // If AV is the current version, AV only wins on upgrades if BV is not the candidate. + if (A.CurrentVer() == AV) + return upgrade ? Policy.GetCandidateVer(A) != BV : true; + // If BV is the current version, AV only wins on upgrades if it is the candidate. + if (A.CurrentVer() == BV) + return upgrade ? Policy.GetCandidateVer(A) == AV : false; + // If neither are the current version, order them by priority. if (Policy.GetPriority(AV) < Policy.GetPriority(BV)) return false; |
