diff options
author | David Kalnischkies <david@kalnischkies.de> | 2016-07-03 13:57:25 +0200 |
---|---|---|
committer | David Kalnischkies <david@kalnischkies.de> | 2016-08-10 23:18:04 +0200 |
commit | d3930f8716f439c229cd3d11813823d847a2ecff (patch) | |
tree | 6739fad5c8a90dd75329729924468477fced617b /apt-pkg/deb/dpkgpm.cc | |
parent | 77a324fccc75b8573799a7f79ca1b3f8b0d35be7 (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.
Diffstat (limited to 'apt-pkg/deb/dpkgpm.cc')
-rw-r--r-- | apt-pkg/deb/dpkgpm.cc | 15 |
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; |