summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg/deb')
-rw-r--r--apt-pkg/deb/dpkgpm.cc15
1 files changed, 13 insertions, 2 deletions
diff --git a/apt-pkg/deb/dpkgpm.cc b/apt-pkg/deb/dpkgpm.cc
index 3d0fd622c..8938cb3d4 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -1233,6 +1233,15 @@ void pkgDPkgPM::StopPtyMagic() /*{{{*/
*/
bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
{
+ auto const ItemIsEssential = [](pkgDPkgPM::Item const &I) {
+ static auto const cachegen = _config->Find("pkgCacheGen::Essential");
+ if (cachegen == "none" || cachegen == "native")
+ return true;
+ if (unlikely(I.Pkg.end()))
+ return true;
+ return (I.Pkg->Flags & pkgCache::Flag::Essential) != 0;
+ };
+
pkgPackageManager::SigINTStop = false;
d->progress = progress;
@@ -1350,13 +1359,15 @@ bool pkgDPkgPM::Go(APT::Progress::PackageManager *progress)
{
case Item::Remove:
ADDARGC("--force-depends");
- ADDARGC("--force-remove-essential");
+ if (std::any_of(I, J, ItemIsEssential))
+ ADDARGC("--force-remove-essential");
ADDARGC("--remove");
break;
case Item::Purge:
ADDARGC("--force-depends");
- ADDARGC("--force-remove-essential");
+ if (std::any_of(I, J, ItemIsEssential))
+ ADDARGC("--force-remove-essential");
ADDARGC("--purge");
break;