summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
authorJulian Andres Klode <jak@debian.org>2021-11-17 17:22:00 +0000
committerJulian Andres Klode <jak@debian.org>2021-11-17 17:22:00 +0000
commit16706bbae1a1168bd327ce1587b63d9353bab144 (patch)
tree11b77ce7cf551b65e3fe3fcedadc71e1e7f49781 /apt-pkg
parent68a6dffed6ad5e5dc4ac01319b31843951d0eb21 (diff)
parent891efe3b201a104445ea723a3a5b9b434a78c364 (diff)
Merge branch 'pu/essential-removal' into 'main'
Do not remove Essential/Protected due to dependencies See merge request apt-team/apt!198
Diffstat (limited to 'apt-pkg')
-rw-r--r--apt-pkg/depcache.cc18
1 files changed, 18 insertions, 0 deletions
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;
}