summaryrefslogtreecommitdiff
path: root/apt-pkg/solver3.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2025-10-07 21:49:44 +0200
committerJulian Andres Klode <jak@debian.org>2025-10-25 18:10:32 +0200
commitffc9001b513606869c3cf94fb85a792503974d1f (patch)
treebaace007014864fb1f5992516d8c70413f3007c7 /apt-pkg/solver3.cc
parent7e5652d0d0d9408abb8d514259b7faa46aaaa790 (diff)
solver3: Eagerly satisfy previously satisfied Recommends
When a user ran `apt install gpg`, the solver decided to remove `gnupg` and `seahorse` because `seahorse` was only pulled in as a Recommends of ubuntu-desktop and Recommends were resolved after all other dependencies. Solve this to most extent by introducing eager optionality: These dependencies, while they do not take part in classic unit propagation, are otherwise treated like hard dependencies and resolved as soon as possible rather than after any hard dependencies. This ensures that the Recommends of ubuntu-desktop on seahorse is retained correctly, and as a result, gnupg is updated to the latest version. Oops: 6c8e32eb-665d-11f0-a985-fa163ec8ca8c
Diffstat (limited to 'apt-pkg/solver3.cc')
-rw-r--r--apt-pkg/solver3.cc7
1 files changed, 5 insertions, 2 deletions
diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc
index a386b967c..65e3940b4 100644
--- a/apt-pkg/solver3.cc
+++ b/apt-pkg/solver3.cc
@@ -223,8 +223,8 @@ bool APT::Solver::Work::operator<(APT::Solver::Work const &b) const
{
if ((not clause->optional && size < 2) != (not b.clause->optional && b.size < 2))
return not b.clause->optional && b.size < 2;
- if (clause->optional != b.clause->optional)
- return clause->optional;
+ if (clause->eager != b.clause->eager)
+ return not clause->eager;
if (clause->group != b.clause->group)
return clause->group > b.clause->group;
if ((size < 2) != (b.size < 2))
@@ -955,6 +955,7 @@ APT::Solver::Clause APT::Solver::TranslateOrGroup(pkgCache::DepIterator start, p
if (unlikely(debug >= 3))
std::cerr << "Promoting previously satisfied clause to hard dependency: " << clause.toString(cache, true) << std::endl;
clause.optional = false;
+ clause.eager = true;
}
else if (
IsUpgrade && not(AllowRemove && AllowInstall) // promote Recommends to Depends in upgrade, not in dist-upgrade.
@@ -965,6 +966,7 @@ APT::Solver::Clause APT::Solver::TranslateOrGroup(pkgCache::DepIterator start, p
if (unlikely(debug >= 3))
std::cerr << "Promoting new clause to hard dependency: " << clause.toString(cache) << std::endl;
clause.optional = false;
+ clause.eager = true;
}
else if (not existing.end() && importantToKeep(start) && satisfied)
{
@@ -975,6 +977,7 @@ APT::Solver::Clause APT::Solver::TranslateOrGroup(pkgCache::DepIterator start, p
clause.solutions.erase(std::remove_if(clause.solutions.begin(), clause.solutions.end(), [this](auto var)
{ return var.CastPkg(cache)->CurrentVer == nullptr; }),
clause.solutions.end());
+ clause.eager = true;
}
}