From 4175a005f98dba139208035d820bcc14de711a5a Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Mon, 17 Feb 2025 21:42:29 +0100 Subject: solver3: Fix test-apt-move-and-forget-manual-sections Implement the moving of the auto bit. The whole auto-bit management is not entirely optimal yet, but this works. --- apt-pkg/solver3.cc | 26 ++++++++++++++++++++++++-- test/integration/solver3.broken | 1 - 2 files changed, 24 insertions(+), 3 deletions(-) diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc index c4fb567e1..233d7c712 100644 --- a/apt-pkg/solver3.cc +++ b/apt-pkg/solver3.cc @@ -975,6 +975,7 @@ bool APT::Solver::FromDepCache(pkgDepCache &depcache) bool APT::Solver::ToDepCache(pkgDepCache &depcache) const { + FastContiguousCacheMap movedManual(cache); pkgDepCache::ActionGroup group(depcache); for (auto P = cache.PkgBegin(); not P.end(); P++) { @@ -994,10 +995,31 @@ bool APT::Solver::ToDepCache(pkgDepCache &depcache) const if (cand != P.CurrentVer()) { + bool automatic = (not reason.empty() || (depcache[P].Flags & pkgCache::Flag::Auto)) && not movedManual[P]; depcache.SetCandidateVersion(cand); - depcache.MarkInstall(P, false, 0, reason.empty() && not(depcache[P].Flags & pkgCache::Flag::Auto)); + depcache.MarkInstall(P, false, 0, not automatic); + + // Set the automatic bit for new packages or move it on upgrades to oldlibs if (not P->CurrentVer) - depcache.MarkAuto(P, not reason.empty()); + depcache.MarkAuto(P, automatic); + else if (not(depcache[P].Flags & pkgCache::Flag::Auto) && P.CurrentVer()->Section && cand->Section && not _config->SectionInSubTree("APT::Move-Autobit-Sections", P.CurrentVer().Section()) && _config->SectionInSubTree("APT::Move-Autobit-Sections", cand.Section())) + { + bool moved = false; + for (auto const &clause : (*this)[cand].clauses) + for (auto sol : clause->solutions) + { + // New installs move the auto-bit. TODO: Should we look at whether clause is the reason for installing it? + if (sol.CastPkg(cache) == P || sol.CastPkg(cache)->CurrentVer) + continue; + std::cerr << "Move manual bit from " << P.FullName() << " to " << sol.CastPkg(cache).Name() << std::endl; + movedManual[sol.CastPkg(cache)] = true; + depcache.MarkAuto(sol.CastPkg(cache), false); + moved = true; + } + if (moved) + depcache.MarkAuto(P, true); + } + } else depcache.MarkKeep(P, false, reason.empty() && not(depcache[P].Flags & pkgCache::Flag::Auto)); diff --git a/test/integration/solver3.broken b/test/integration/solver3.broken index 2ad00555b..4a4e1532b 100644 --- a/test/integration/solver3.broken +++ b/test/integration/solver3.broken @@ -1,7 +1,6 @@ test-allow-scores-for-all-dependency-types # TBD: We are lacking single-sided conflicts preferences test-apt-get-upgrade-by-source # TBD: Upgrading by source is not supported yet, mostly same issue as above test-apt-install-order-matters-a-bit # Wontfix: Cannot fix, the order is not recorded in the depcache -test-apt-move-and-forget-manual-sections # TBD: Moving the auto bit is not implemented test-bug-470115-new-and-tighten-recommends # TBD: Calculation of what is already satisfied Recommends is broken test-prevent-markinstall-multiarch-same-versionscrew # TBD: We consider the skewed ones obsolete and remove them... test-resolve-by-keep-new-recommends # TBD: Fixing this seems to break test-bug-591882-conkeror, why? -- cgit v1.2.3-70-g09d2