Control: tags -1 + patch pending
On Tue, 20 Sep 2016 at 14:28:35 +0200, Raphael Geissert wrote:
> If unattended-upgrades is
> 1) launched by apt-daily,
> 2) upgrading packages under minimal steps,
> 3) signaled with SIGUSR1
>
> Then it exits after the current operation, as expected. However,
> unattended-upgrades-stamp and upgrade-stamp are both updated as if
> everything had been done.
This appears to have been fixed in git with the attached change.
smcv
>From 82e9eda882aef62dc89df9e40e473fdd8e1f4335 Mon Sep 17 00:00:00 2001
From: Balint Reczey <[email protected]>
Date: Sat, 9 Dec 2017 23:30:23 +0100
Subject: [PATCH] Exit with error when package installation failed or u-u is
signalled to stop
Closes: #838368
---
unattended-upgrade | 22 ++++++++++++++--------
1 file changed, 14 insertions(+), 8 deletions(-)
diff --git a/unattended-upgrade b/unattended-upgrade
index b68308e..9b53010 100755
--- a/unattended-upgrade
+++ b/unattended-upgrade
@@ -512,7 +512,7 @@ def upgrade_in_minimal_steps(cache, # type: apt.Cache
for pkgname in to_upgrade:
if SIGNAL_STOP_REQUEST:
logging.warning("SIGNAL received, stopping")
- return True
+ return False
pkg = cache[pkgname]
if pkg.is_upgradable:
pkg.mark_upgrade(from_user=not pkg.is_auto_installed)
@@ -1307,7 +1307,7 @@ def is_update_day():
def main(options, rootdir=""):
- # type: (Options, str) -> None
+ # type: (Options, str) -> int
# useful for testing
if rootdir:
_setup_alternative_rootdir(rootdir)
@@ -1317,7 +1317,7 @@ def main(options, rootdir=""):
# check if today is a patch day
if not is_update_day():
- return
+ return 0
# format (origin, archive), e.g. ("Ubuntu","dapper-security")
allowed_origins = get_allowed_origins()
@@ -1433,7 +1433,7 @@ def main(options, rootdir=""):
# them
if SIGNAL_STOP_REQUEST:
logging.warning("SIGNAL received, stopping")
- return
+ return 1
try:
pm.get_archives(fetcher, list, recs)
except SystemError as e:
@@ -1445,7 +1445,7 @@ def main(options, rootdir=""):
logging.error("fetch.run() result: %s", e)
if options.download_only:
- return
+ return 0
if dpkg_conffile_prompt():
# now check the downloaded debs for conffile conflicts and build
@@ -1585,8 +1585,10 @@ def main(options, rootdir=""):
sys.exit(1)
# the user wants *all* auto-removals to be removed
- if apt_pkg.config.find_b(
- "Unattended-Upgrade::Remove-Unused-Dependencies", False):
+ # (unless u-u got signalled to stop gracefully quickly)
+ if ((apt_pkg.config.find_b(
+ "Unattended-Upgrade::Remove-Unused-Dependencies", False) and
+ not SIGNAL_STOP_REQUEST)):
auto_removals = get_auto_removable(cache)
pkg_install_success = pkg_install_success and do_auto_remove(
cache, auto_removals, logfile_dpkg,
@@ -1629,6 +1631,10 @@ def main(options, rootdir=""):
# check if the user wants a reboot
if not options.dry_run:
reboot_if_requested_and_needed()
+ if pkg_install_success:
+ return 0
+ else:
+ return 1
class Options:
@@ -1697,4 +1703,4 @@ if __name__ == "__main__":
atexit.register(os.remove, pidf)
# run the main code
- main(options)
+ sys.exit(main(options))
--
2.16.1