From 791fd71cd9b946c369ed14588aeb08d563bbd400 Mon Sep 17 00:00:00 2001 From: Olaf Meeuwissen Date: Fri, 25 Aug 2023 11:54:27 +0900 Subject: [PATCH] fix: Honor APT::Get::Purge setting when removing packages Re #345 --- unattended-upgrade | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/unattended-upgrade b/unattended-upgrade index d4956738..fbb6a0cf 100755 --- a/unattended-upgrade +++ b/unattended-upgrade @@ -1896,6 +1896,7 @@ def do_auto_remove(cache, # type: UnattendedUpgradesCache pkgs_removed = [] # type: List[str] pkgs_kept_installed = [] # type: List[str] + purge = apt_pkg.config.find_b("APT::Get::Purge", False) if minimal_steps: for pkgname in auto_removable: if should_stop(): @@ -1904,7 +1905,7 @@ def do_auto_remove(cache, # type: UnattendedUpgradesCache logging.debug("marking %s for removal" % pkgname) if pkgname in pkgs_removed: continue - cache[pkgname].mark_delete() + cache[pkgname].mark_delete(purge) if not is_autoremove_valid(cache, pkgname, auto_removable): # this situation can occur when removing newly unused packages # would also remove old unused packages which are not set @@ -1923,7 +1924,7 @@ def do_auto_remove(cache, # type: UnattendedUpgradesCache cache.clear() else: for pkgname in auto_removable: - cache[pkgname].mark_delete() + cache[pkgname].mark_delete(purge) if is_autoremove_valid(cache, "", auto_removable): # do it in one step if not dry_run: