From 4c48b5618ba15d4e33625cec81843891910e81a2 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Tue, 11 Feb 2025 12:11:20 +0100 Subject: solver3: Defer 3.0 'deep' autoremoval to 3.1, fix autoremove Restore the depcache's MarkRequired logic for 3.0 solver; and change the MarkInstall() call to pass a more correct value for FromUser, to not override an existing automatic status. --- apt-pkg/depcache.cc | 2 +- apt-pkg/edsp.cc | 2 +- apt-pkg/solver3.cc | 2 +- apt-pkg/solver3.h | 3 ++- 4 files changed, 5 insertions(+), 4 deletions(-) (limited to 'apt-pkg') diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index ef93a54bb..b66f2bc66 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -2496,7 +2496,7 @@ static bool MarkPackage(pkgCache::PkgIterator const &Pkg, // pkgDepCache::MarkRequired - the main mark algorithm /*{{{*/ bool pkgDepCache::MarkRequired(InRootSetFunc &userFunc) { - if (_config->Find("APT::Solver", "internal") != "internal") + if (_config->Find("APT::Solver", "internal") != "internal" && _config->Find("APT::Solver") != "3.0") return true; // init the states diff --git a/apt-pkg/edsp.cc b/apt-pkg/edsp.cc index 88f572f18..dd9ae18fc 100644 --- a/apt-pkg/edsp.cc +++ b/apt-pkg/edsp.cc @@ -754,7 +754,7 @@ static bool CreateDumpFile(char const * const id, char const * const type, FileF // EDSP::ResolveExternal - resolve problems by asking external for help {{{*/ bool EDSP::ResolveExternal(const char* const solver, pkgDepCache &Cache, unsigned int const flags, OpProgress *Progress) { - if (strcmp(solver, "3.0") == 0) + if (strstr(solver, "3.") == solver) { APT::Solver s(Cache.GetCache(), Cache.GetPolicy()); FileFd output; diff --git a/apt-pkg/solver3.cc b/apt-pkg/solver3.cc index 8af3275eb..44a5075da 100644 --- a/apt-pkg/solver3.cc +++ b/apt-pkg/solver3.cc @@ -976,7 +976,7 @@ bool APT::Solver::ToDepCache(pkgDepCache &depcache) const if (auto RP = reason.Pkg(); RP == P.MapPointer()) reason = (*this)[P].reason; - depcache.MarkInstall(P, false, 0, reason.empty()); + depcache.MarkInstall(P, false, 0, reason.empty() && not(depcache[P].Flags & pkgCache::Flag::Auto)); if (not P->CurrentVer) depcache.MarkAuto(P, not reason.empty()); depcache[P].Marked = 1; diff --git a/apt-pkg/solver3.h b/apt-pkg/solver3.h index 91b852c98..93e4e5116 100644 --- a/apt-pkg/solver3.h +++ b/apt-pkg/solver3.h @@ -217,10 +217,11 @@ class Solver time_t startTime; /// Various configuration options + std::string version{_config->Find("APT::Solver", "3.0")}; // \brief Debug level int debug{_config->FindI("Debug::APT::Solver")}; // \brief If set, we try to keep automatically installed packages installed. - bool KeepAuto{not _config->FindB("APT::Get::AutomaticRemove")}; + bool KeepAuto{version == "3.0" || not _config->FindB("APT::Get::AutomaticRemove")}; // \brief Determines if we are in upgrade mode. bool IsUpgrade{_config->FindB("APT::Solver::Upgrade", false)}; // \brief If set, removals are allowed. -- cgit v1.2.3-70-g09d2