summaryrefslogtreecommitdiff
path: root/apt-pkg/solver3.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2025-03-12 18:34:48 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2025-03-12 18:52:16 +0100
commita4ce187b40f3bbd110a7cc35f9a5af5a8b7b0c9e (patch)
tree6f6bb4d49d13323d30544df9d77fe01522615454 /apt-pkg/solver3.cc
parent5c101b3d4651b2f181ac586b088894cce5008d3b (diff)
solver3: Fix Recommends/Suggests vs Enhances confusion
We accidentally considered an Enhances a reason to keep a package installed, which of course it is not, fix the determination of "existing soft dependency" to only include soft dependencies that should keep a package installed in the autoremover to solve the issue. This also fixes edsp/mantic-upgrade-rel-to-2024-05-29.edsp to not install llvm-13-dev for clang-13 which is an installed package with no upgrade. Also ensure we stop after the first match; the DependsList() is ordered by decreasing priority and we don't want to override Recommends by Suggests in case a package declares both... LP: #2101800
Diffstat (limited to 'apt-pkg/solver3.cc')
-rw-r--r--apt-pkg/solver3.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc
index 739309c59..f992d55b4 100644
--- a/apt-pkg/solver3.cc
+++ b/apt-pkg/solver3.cc
@@ -833,9 +833,17 @@ APT::Solver::Clause APT::Solver::TranslateOrGroup(pkgCache::DepIterator start, p
bool important = policy.IsImportantDep(start);
bool newOptional = true;
bool wasImportant = false;
+ auto importantToKeep = [this](pkgCache::DepIterator d)
+ {
+ return policy.IsImportantDep(d) || (KeepRecommends && d->Type == pkgCache::Dep::Recommends) || (KeepSuggests && d->Type == pkgCache::Dep::Suggests);
+ };
+
for (auto D = start.ParentPkg().CurrentVer().DependsList(); not D.end(); D++)
- if (not D.IsCritical() && not D.IsNegative() && D.TargetPkg() == start.TargetPkg())
+ if (not D.IsCritical() && importantToKeep(D) && D.TargetPkg() == start.TargetPkg())
+ {
newOptional = false, wasImportant = policy.IsImportantDep(D);
+ break;
+ }
bool satisfied = std::any_of(clause.solutions.begin(), clause.solutions.end(), [this](auto var)
{ return var.Pkg(cache) ? var.Pkg(cache)->CurrentVer != nullptr : Var(var.CastPkg(cache).CurrentVer()) == var; });