From 81804cefd8c24c98e7a0216a9d4277516e19b6e2 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Thu, 20 Mar 2025 21:15:14 +0100 Subject: solver3: Do not install new packages for Suggests As a followup to the previous commit, restore the exact behavior of the old solver to break the Suggests on upgrade here by erasing any choices not previously installed. This ensures that the Suggests never installs any new package, but it will still retain previously installed packages when solver3 is doing autoremove. --- apt-pkg/solver3.cc | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'apt-pkg') diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc index 66e307133..620156ac3 100644 --- a/apt-pkg/solver3.cc +++ b/apt-pkg/solver3.cc @@ -862,6 +862,11 @@ APT::Solver::Clause APT::Solver::TranslateOrGroup(pkgCache::DepIterator start, p if (unlikely(debug >= 3)) std::cerr << "Try to keep satisfied: " << clause.toString(cache, true) << std::endl; clause.group = Group::SatisfySuggests; + // Erase the non-installed solutions. We will process this last and try to keep the previously installed + // "best" solution installed. + clause.solutions.erase(std::remove_if(clause.solutions.begin(), clause.solutions.end(), [this](auto var) + { return var.CastPkg(cache)->CurrentVer == nullptr; }), + clause.solutions.end()); } else if (not important) { -- cgit v1.2.3-70-g09d2