From c64e6e77231d5f5153caa83743b372fb4a8337f3 Mon Sep 17 00:00:00 2001 From: James Valleroy Date: Mon, 10 Apr 2023 10:36:27 -0400 Subject: [PATCH] upgrades: Check apt result during dist-upgrade In case apt full-upgrade fails for any reason, do not continue. Otherwise, may get stuck unattended-upgrade later (#2266). Since the dist-upgrade flag remains set, Plinth should retry the dist-upgrade later. Signed-off-by: James Valleroy Reviewed-by: Sunil Mohan Adapa --- plinth/modules/upgrades/privileged.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/plinth/modules/upgrades/privileged.py b/plinth/modules/upgrades/privileged.py index 7403f7dc8..b537702ae 100644 --- a/plinth/modules/upgrades/privileged.py +++ b/plinth/modules/upgrades/privileged.py @@ -518,7 +518,13 @@ def _perform_dist_upgrade(): ', '.join(DIST_UPGRADE_PACKAGES_WITH_PROMPTS) + '...', flush=True) with apt_hold(DIST_UPGRADE_PACKAGES_WITH_PROMPTS): print('Running apt full-upgrade...', flush=True) - run_apt_command(['full-upgrade']) + returncode = run_apt_command(['full-upgrade']) + + # Check if apt upgrade was successful. + if returncode: + raise RuntimeError( + 'Apt full-upgrade was not successful. Distribution upgrade ' + 'will be retried at a later time.') _update_searx(reenable_searx)