summaryrefslogtreecommitdiff
path: root/apt-private/private-install.cc
diff options
context:
space:
mode:
Diffstat (limited to 'apt-private/private-install.cc')
-rw-r--r--apt-private/private-install.cc12
1 files changed, 11 insertions, 1 deletions
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc
index af6697d7f..b110cbdc3 100644
--- a/apt-private/private-install.cc
+++ b/apt-private/private-install.cc
@@ -406,8 +406,15 @@ bool DoAutomaticRemove(CacheFile &Cache)
{
bool Debug = _config->FindB("Debug::pkgAutoRemove",false);
bool doAutoRemove = _config->FindB("APT::Get::AutomaticRemove", false);
+ bool doAutoRemoveKernels = _config->FindB("APT::Get::AutomaticRemove::Kernels", false);
bool hideAutoRemove = _config->FindB("APT::Get::HideAutoRemove");
+ std::unique_ptr<APT::CacheFilter::Matcher> kernelAutoremovalMatcher;
+ if (doAutoRemoveKernels && !doAutoRemove)
+ {
+ kernelAutoremovalMatcher = APT::KernelAutoRemoveHelper::GetProtectedKernelsFilter(Cache, true);
+ }
+
pkgDepCache::ActionGroup group(*Cache);
if(Debug)
std::cout << "DoAutomaticRemove()" << std::endl;
@@ -436,7 +443,7 @@ bool DoAutomaticRemove(CacheFile &Cache)
if(Debug)
std::cout << "We could delete " << APT::PrettyPkg(Cache, Pkg) << std::endl;
- if (doAutoRemove)
+ if (doAutoRemove || (kernelAutoremovalMatcher != nullptr && (*kernelAutoremovalMatcher)(Pkg)))
{
if(Pkg.CurrentVer() != 0 &&
Pkg->CurrentState != pkgCache::State::ConfigFiles)
@@ -692,6 +699,9 @@ bool DoCacheManipulationFromCommandLine(CommandLine &CmdL, std::vector<PseudoPkg
OpTextProgress Progress(*_config);
bool const distUpgradeMode = strcmp(CmdL.FileList[0], "dist-upgrade") == 0 || strcmp(CmdL.FileList[0], "full-upgrade") == 0;
+ if (distUpgradeMode)
+ _config->CndSet("APT::Get::AutomaticRemove::Kernels", "true");
+
bool resolver_fail = false;
if (distUpgradeMode == true || UpgradeMode != APT::Upgrade::ALLOW_EVERYTHING)
resolver_fail = APT::Upgrade::Upgrade(Cache, UpgradeMode, &Progress);