From 7d6e0e3d72c491fff0f0326c45a8b89404563314 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 11 Feb 2025 18:05:38 +0100 Subject: solver3: Correctly call MarkKeep() for kept back packages This fixes the difference in test-unpack-different-version-unpacked, but more importantly this is needed for phasing to be displayed correctly once that is implemented. --- apt-pkg/solver3.cc | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) (limited to 'apt-pkg/solver3.cc') diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc index f6ee1d243..0ece03b63 100644 --- a/apt-pkg/solver3.cc +++ b/apt-pkg/solver3.cc @@ -978,21 +978,25 @@ bool APT::Solver::ToDepCache(pkgDepCache &depcache) const depcache[P].Garbage = 0; if ((*this)[P].decision == Decision::MUST) { - for (auto V = P.VersionList(); not V.end(); V++) - { + pkgCache::VerIterator cand; + for (auto V = P.VersionList(); cand.end() && not V.end(); V++) if ((*this)[V].decision == Decision::MUST) - { - depcache.SetCandidateVersion(V); - break; - } - } - auto reason = (*this)[depcache.GetCandidateVersion(P)].reason; + cand = V; + + auto reason = (*this)[cand].reason; if (auto RP = reason.Pkg(); RP == P.MapPointer()) reason = (*this)[P].reason; - depcache.MarkInstall(P, false, 0, reason.empty() && not(depcache[P].Flags & pkgCache::Flag::Auto)); - if (not P->CurrentVer) - depcache.MarkAuto(P, not reason.empty()); + if (cand != P.CurrentVer()) + { + depcache.SetCandidateVersion(cand); + depcache.MarkInstall(P, false, 0, reason.empty() && not(depcache[P].Flags & pkgCache::Flag::Auto)); + if (not P->CurrentVer) + depcache.MarkAuto(P, not reason.empty()); + } + else + depcache.MarkKeep(P, false, reason.empty() && not(depcache[P].Flags & pkgCache::Flag::Auto)); + depcache[P].Marked = 1; depcache[P].Garbage = 0; } -- cgit v1.2.3-70-g09d2