summaryrefslogtreecommitdiff
path: root/apt-pkg
diff options
context:
space:
mode:
Diffstat (limited to 'apt-pkg')
-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 23d3ff977..d224a34c0 100644
--- a/apt-pkg/deb/dpkgpm.cc
+++ b/apt-pkg/deb/dpkgpm.cc
@@ -1216,6 +1216,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;
@@ -1342,13 +1351,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;