From cd245a57f273d3c069543c19d6ac31c84879ce7b Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 20 May 2024 14:59:58 +0200 Subject: 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. --- apt-pkg/solver3.cc | 2 ++ 1 file changed, 2 insertions(+) (limited to 'apt-pkg') 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; -- cgit v1.2.3-70-g09d2