diff options
| author | Julian Andres Klode <julian.klode@canonical.com> | 2025-02-17 21:42:29 +0100 |
|---|---|---|
| committer | Julian Andres Klode <julian.klode@canonical.com> | 2025-02-18 10:56:45 +0100 |
| commit | 4175a005f98dba139208035d820bcc14de711a5a (patch) | |
| tree | 0909c3c5324b68e438decf522904b40cd858bd29 /apt-pkg/solver3.cc | |
| parent | e8b240eb3aab7e2584e245f03700ede30a3fc23a (diff) | |
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.
Diffstat (limited to 'apt-pkg/solver3.cc')
| -rw-r--r-- | apt-pkg/solver3.cc | 26 |
1 files changed, 24 insertions, 2 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<pkgCache::Package, bool> 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)); |
