From 891efe3b201a104445ea723a3a5b9b434a78c364 Mon Sep 17 00:00:00 2001 From: Julian Andres Klode Date: Wed, 17 Nov 2021 16:29:09 +0100 Subject: Do not remove Essential/Protected due to dependencies Suggesting the removal of Essential and Protected packages as a solution leads to situations where YouTubers end up removing their desktop. Let's not remove such packages ourselves. --- apt-pkg/depcache.cc | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'apt-pkg/depcache.cc') diff --git a/apt-pkg/depcache.cc b/apt-pkg/depcache.cc index 460fb296e..7c19fd7ca 100644 --- a/apt-pkg/depcache.cc +++ b/apt-pkg/depcache.cc @@ -930,6 +930,24 @@ static bool IsModeChangeOk(pkgDepCache &Cache, pkgDepCache::ModeList const mode, << " of " << APT::PrettyPkg(&Cache, Pkg) << std::endl; return false; } + // Do not allow removals of essential packages not explicitly triggered by the user + else if (mode == pkgDepCache::ModeDelete && (Pkg->Flags & pkgCache::Flag::Essential) == pkgCache::Flag::Essential && + not _config->FindB("APT::Get::Allow-Solver-Remove-Essential", false)) + { + if (unlikely(DebugMarker == true)) + std::clog << OutputInDepth(Depth) << "Essential prevents Mark" << PrintMode(mode) + << " of " << APT::PrettyPkg(&Cache, Pkg) << std::endl; + return false; + } + // Do not allow removals of essential packages not explicitly triggered by the user + else if (mode == pkgDepCache::ModeDelete && (Pkg->Flags & pkgCache::Flag::Important) == pkgCache::Flag::Important && + not _config->FindB("APT::Get::Allow-Solver-Remove-Essential", false)) + { + if (unlikely(DebugMarker == true)) + std::clog << OutputInDepth(Depth) << "Protected prevents Mark" << PrintMode(mode) + << " of " << APT::PrettyPkg(&Cache, Pkg) << std::endl; + return false; + } return true; } -- cgit v1.2.3-70-g09d2