From 8cd4bd5f708b69d536395675da4fce18d7f9c3f3 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Sat, 25 Oct 2025 21:25:23 +0200 Subject: solver3: Do not lose notion that we backtracked Record a silly string if we backtracked such that we are aware of it. We need to handle this in a broader fashion, but this was at least breaking test-apt-never-markauto-sections with remove-manual LP: #2129819 --- apt-pkg/solver3.cc | 6 +++++- apt-pkg/solver3.h | 2 ++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc index 65e3940b4..4d7e0ff0b 100644 --- a/apt-pkg/solver3.cc +++ b/apt-pkg/solver3.cc @@ -1007,6 +1007,7 @@ void APT::Solver::UndoOne() auto &state = (*this)[solvedItem.assigned]; state.decision = Decision::NONE; state.reason = nullptr; + state.reasonStr = nullptr; state.depth = 0; } @@ -1071,6 +1072,8 @@ bool APT::Solver::Pop() if (not choice.empty() && not Enqueue(choice, false, {})) return false; + (*this)[choice].reasonStr = "backtracked"; + if (unlikely(debug >= 2)) std::cerr << "Backtracked to choice " << choice.toString(cache) << "\n"; @@ -1366,7 +1369,8 @@ bool APT::Solver::ToDepCache(pkgDepCache &depcache) const } else if (P->CurrentVer || depcache[P].Install()) { - depcache.MarkDelete(P, false, 0, not(*this)[P].reason); + bool automatic = (not (*this)[P].reason) && (not (*this)[P].reasonStr); + depcache.MarkDelete(P, false, 0, automatic); depcache[P].Marked = 0; depcache[P].Garbage = 1; } diff --git a/apt-pkg/solver3.h b/apt-pkg/solver3.h index 8d834b313..5590df5cc 100644 --- a/apt-pkg/solver3.h +++ b/apt-pkg/solver3.h @@ -477,6 +477,8 @@ struct APT::Solver::State // Vars < 0 are package ID, reasons > 0 are version IDs. const Clause *reason{}; + const char *reasonStr{}; + // \brief The depth at which the decision has been taken depth_type depth{0}; -- cgit v1.2.3-70-g09d2