summaryrefslogtreecommitdiff
path: root/apt-pkg/solver3.cc
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2024-05-20 14:59:58 +0200
committerJulian Andres Klode <julian.klode@canonical.com>2024-05-24 17:01:55 +0200
commitcd245a57f273d3c069543c19d6ac31c84879ce7b (patch)
tree3107027f1e8bbbee3e02e13b822406b2c833da9d /apt-pkg/solver3.cc
parent0fa3b176652ff10276569a478c910ca866a4da5d (diff)
solver3: Solve optional dependencies before optional packages
This somewhat improves reliability of not breaking Recommends, e.g. if the Recommends gets tightened. One test case enabled by this now is the test-resolver-provider-exchange, which with a simple change to allow removal of automatically installed packages works now.
Diffstat (limited to 'apt-pkg/solver3.cc')
-rw-r--r--apt-pkg/solver3.cc2
1 files changed, 2 insertions, 0 deletions
diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc
index 3c4ca4eb7..216651a97 100644
--- a/apt-pkg/solver3.cc
+++ b/apt-pkg/solver3.cc
@@ -189,6 +189,8 @@ bool APT::Solver::Work::operator<(APT::Solver::Work const &b) const
return std::any_of(solutions.begin(), solutions.end(), [b](auto sol) -> bool
{ return std::find(b.solutions.begin(), b.solutions.end(), sol) != b.solutions.end(); });
}
+ if (optional && b.optional && reason.empty() != b.reason.empty())
+ return reason.empty();
// An optional item is less important than a required one.
if (optional != b.optional)
return optional;