summaryrefslogtreecommitdiff
path: root/apt-pkg/deb
diff options
context:
space:
mode:
authorDavid Kalnischkies <david@kalnischkies.de>2016-07-03 13:57:25 +0200
committerJulian Andres Klode <jak@debian.org>2016-10-05 12:02:19 +0200
commit6c36aa231b8dcde3b4698157a1ed1e7e4054a0ea (patch)
tree68f8e65daee32da082bcbb16602a25a591b1c9ca /apt-pkg/deb
parentc614d66183639638f588422e2b0b3258d4f52323 (diff)
pass --force-remove-essential to dpkg only if needed
APT (usually) knows which package is essential or not, so we can avoid passing this force flag to dpkg unconditionally if the user hasn't chosen a non-default essential handling obscuring the information. (cherry picked from commit d3930f8716f439c229cd3d11813823d847a2ecff)
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 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;