summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--apt-private/private-install.cc12
-rw-r--r--debian/NEWS7
-rw-r--r--doc/examples/configure-index4
3 files changed, 21 insertions, 2 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);
diff --git a/debian/NEWS b/debian/NEWS
index 13fc64182..9d9c963c2 100644
--- a/debian/NEWS
+++ b/debian/NEWS
@@ -1,3 +1,10 @@
+apt (2.1.16) UNRELEASED; urgency=medium
+
+ Automatically remove unused kernels on dist-upgrade. To revert to previous
+ behavior, set APT::Get::AutomaticRemove::Kernels to false.
+
+ -- Julian Andres Klode <jak@debian.org> Mon, 04 Jan 2021 10:47:14 +0100
+
apt (1.9.11) experimental; urgency=medium
apt(8) now waits for the lock indefinitely if connected to a tty, or
diff --git a/doc/examples/configure-index b/doc/examples/configure-index
index 571bf2369..15b020198 100644
--- a/doc/examples/configure-index
+++ b/doc/examples/configure-index
@@ -80,7 +80,9 @@ APT
Remove "<BOOL>";
AllowUnauthenticated "<BOOL>"; // skip security
- AutomaticRemove "<BOOL>";
+ AutomaticRemove "<BOOL>" {
+ "Kernels" "<BOOL>"; // Allow removing kernels even if not removing other packages (true for dist-upgrade)
+ };
HideAutoRemove "<STRING_OR_BOOL>"; // yes, no, small
Simulate "<BOOL>";