diff options
author | Julian Andres Klode <jak@debian.org> | 2021-01-04 10:17:45 +0000 |
---|---|---|
committer | Julian Andres Klode <jak@debian.org> | 2021-01-04 10:17:45 +0000 |
commit | fba6d562bda307bb1e619c255682079aa86c68ac (patch) | |
tree | c66205b3d0def0fb9b47d3a6b61edae0045dc906 /apt-private/private-install.cc | |
parent | da468783ecfb0b5a8575b1d91abae193519ef5a7 (diff) | |
parent | 38c49b8adeadf54f147140b3a5db7693e9b9b50f (diff) |
Merge branch 'pu/kernel-autoremove' into 'master'
Determine autoremovable kernels at run-time
See merge request apt-team/apt!138
Diffstat (limited to 'apt-private/private-install.cc')
-rw-r--r-- | apt-private/private-install.cc | 12 |
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); |