summaryrefslogtreecommitdiff
path: root/apt-private
diff options
context:
space:
mode:
authorJulian Andres Klode <julian.klode@canonical.com>2021-01-08 13:22:30 +0100
committerJulian Andres Klode <julian.klode@canonical.com>2021-01-08 13:22:30 +0100
commit5fddde78ad15e1f6160f65465139d2c1e416d047 (patch)
tree2ad03279165b4b0fd17d1c753487375dd4bd2a8f /apt-private
parentcf883949f245af02049d1b24ecfd2145e1958078 (diff)
Only autoremove kernels in apt(8); respect --no-auto-remove
Automatically removing kernels in apt-get could be unexpected, so limit it to apt for now. To handle --no-auto-remove correctly, rewrite the hack that makes apt ignore APT::Get::AutomaticRemove options from config files such that it unsets the option. This then means we can do FindB("APT::Get::AutomaticRemove", true) as the default for APT::Get::AutomaticRemove::Kernels and get the behavior we want: If you set --no-auto-remove, it is respected as that FindB returns false; if you don't set it, it will be true.
Diffstat (limited to 'apt-private')
-rw-r--r--apt-private/private-cmndline.cc3
-rw-r--r--apt-private/private-install.cc4
2 files changed, 3 insertions, 4 deletions
diff --git a/apt-private/private-cmndline.cc b/apt-private/private-cmndline.cc
index 588dea06b..2049842db 100644
--- a/apt-private/private-cmndline.cc
+++ b/apt-private/private-cmndline.cc
@@ -506,8 +506,7 @@ static void BinaryCommandSpecificConfiguration(char const * const Binary, char c
// we support it anyhow, but allow it on the commandline to take effect
// even through it isn't documented as a user who doesn't want it wouldn't
// ask for it
- _config->Set("Binary::apt-get::APT::Get::AutomaticRemove", false);
- _config->Set("Binary::apt::APT::Get::AutomaticRemove", false);
+ _config->Set("APT::Get::AutomaticRemove", "");
}
}
#undef CmdMatches
diff --git a/apt-private/private-install.cc b/apt-private/private-install.cc
index b110cbdc3..402f8f4b6 100644
--- a/apt-private/private-install.cc
+++ b/apt-private/private-install.cc
@@ -699,8 +699,8 @@ 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");
+ if (distUpgradeMode && _config->Find("Binary") == "apt")
+ _config->CndSet("APT::Get::AutomaticRemove::Kernels", _config->FindB("APT::Get::AutomaticRemove", true));
bool resolver_fail = false;
if (distUpgradeMode == true || UpgradeMode != APT::Upgrade::ALLOW_EVERYTHING)