diff options
| author | Julian Andres Klode <julian.klode@canonical.com> | 2024-05-24 13:42:11 +0200 |
|---|---|---|
| committer | Julian Andres Klode <julian.klode@canonical.com> | 2024-05-24 13:43:56 +0200 |
| commit | 67a8a6470ddb8a603db02c5fab84aa225dc00f8d (patch) | |
| tree | bf3dd748f531b5be164ae8bbe4ac018383793db6 /apt-pkg | |
| parent | 4fc6affafafda1aee4cee86294ce7a2b799e2799 (diff) | |
solver3: Implement APT::Solver::RemoveManual to allow removing manual packages
This is mostly going to be useful for the test suite for now,
implement a function there to set it up so we can use it to
improve test suite correctness.
Diffstat (limited to 'apt-pkg')
| -rw-r--r-- | apt-pkg/solver3.cc | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc index d43bd5b33..ab66c9501 100644 --- a/apt-pkg/solver3.cc +++ b/apt-pkg/solver3.cc @@ -853,6 +853,7 @@ bool APT::Solver::FromDepCache(pkgDepCache &depcache) bool KeepAuto = not _config->FindB("APT::Get::AutomaticRemove"); bool AllowRemove = _config->FindB("APT::Solver::Remove", true); bool AllowInstall = _config->FindB("APT::Solver::Install", true); + bool AllowRemoveManual = _config->FindB("APT::Solver::RemoveManual", false); DefaultRootSetFunc2 rootSet(&cache); for (auto P = cache.PkgBegin(); not P.end(); P++) @@ -863,6 +864,8 @@ bool APT::Solver::FromDepCache(pkgDepCache &depcache) auto state = depcache[P]; auto maybeInstall = state.Install() || (state.Keep() && P->CurrentVer); auto reject = state.Delete() || (depcache[P].Keep() && not P->CurrentVer && depcache[P].Protect()); + auto isAuto = (depcache[P].Flags & pkgCache::Flag::Auto); + auto isOptional = isAuto || (AllowRemoveManual && not depcache[P].Protect()); if (P->SelectedState == pkgCache::State::Hold && not state.Protect()) { if (unlikely(debug >= 1)) @@ -884,14 +887,14 @@ bool APT::Solver::FromDepCache(pkgDepCache &depcache) if (depcache[P].Keep() ? not Install(P, {}) : not Install(depcache.GetCandidateVersion(P), {})) return false; } - else if (maybeInstall && not(depcache[P].Flags & pkgCache::Flag::Auto)) + else if (maybeInstall && not isOptional) { if (unlikely(debug >= 1)) std::cerr << "MANUAL " << P.FullName() << "\n"; if (depcache[P].Keep() ? not Install(P, {}) : not Install(depcache.GetCandidateVersion(P), {})) return false; } - else if (maybeInstall && (KeepAuto || rootSet.InRootSet(P)) && (depcache[P].Flags & pkgCache::Flag::Auto)) + else if (maybeInstall && isOptional && (KeepAuto || rootSet.InRootSet(P) || not isAuto)) { auto Upgrade = depcache.GetCandidateVersion(P) != P.CurrentVer(); if (unlikely(debug >= 1)) |
