From 9f13262e9affe7658fac283420ec9956667ceca2 Mon Sep 17 00:00:00 2001 From: Mateusz Moscicki Date: Thu, 1 Feb 2024 15:24:19 +0100 Subject: [PATCH] upgrade-scripts: Get rid of error info during reboot Change-Id: Ibb5cc7de302a319f0c29bb7f2c936e71f1068ae2 --- scripts/upgrade-support/upgrade-fota.sh | 10 +++++++--- scripts/upgrade-support/upgrade-trigger.sh | 19 +++++++++++++++---- 2 files changed, 22 insertions(+), 7 deletions(-) diff --git a/scripts/upgrade-support/upgrade-fota.sh b/scripts/upgrade-support/upgrade-fota.sh index b0917e8..89f55ab 100755 --- a/scripts/upgrade-support/upgrade-fota.sh +++ b/scripts/upgrade-support/upgrade-fota.sh @@ -57,6 +57,11 @@ reboot_to_fota() { cleanup_files /bin/sync flog "[Info] Rebooting to fota" + + # System will reboot, so the script will be aborted. We don't want this to be + # treated as an error. + set -u errexit + untrap if ! /sbin/reboot fota; then critical_flog "[Error] Failed to reboot fota" exit 1 @@ -79,10 +84,9 @@ if ! write_version_info "$VERSION_FILE"; then exit 1 fi +critical_log "RO update: $SCRIPT_NAME success" "$LOG_FILE" + if ! reboot_to_fota; then cleanup exit 1 fi -cleanup - -critical_log "RO update: $SCRIPT_NAME success" "$LOG_FILE" diff --git a/scripts/upgrade-support/upgrade-trigger.sh b/scripts/upgrade-support/upgrade-trigger.sh index 64077bf..638e8af 100644 --- a/scripts/upgrade-support/upgrade-trigger.sh +++ b/scripts/upgrade-support/upgrade-trigger.sh @@ -91,11 +91,24 @@ do_update() { set_upgrade_status 40 + # During the execution of ${SCRIPT_UPGRADE_FOTA} system will reboot, so the + # script will be aborted. We don't want this to be treated as an error. + untrap + set -u errexit if ! "${FOTA_DIR}/${SCRIPT_UPGRADE_FOTA}"; then - exit_error + # We want to check if we are here becasue the reboot interrupted the + # execution of ${SCRIPT_UPGRADE_FOTA} or for some other reason. + # If a reboot is currently in progress then /proc/1/exe will point to + # something other than "systemd" (e.g. deviced-shudown). + if [ "$(basename "$(readlink /proc/1/exe)")" = "systemd" ]; then + # No, it's not a reboot. Rather it is a regular error. + exit_error + else + set_upgrade_status 80 + echo "[Info] RO update: $SCRIPT_NAME success" + fi fi - set_upgrade_status 80 else echo "[Error] Non-A/B upgrade is unsupported" device_board_set_upgrade_status -1 @@ -163,6 +176,4 @@ log "[Info] Delta verification success" set_upgrade_status 1 verify_img "${DOWNLOAD_DELTA}" do_update - -critical_log "RO update: $SCRIPT_NAME success" "$LOG_FILE" ) 9> "$FLOCK_PATH" -- 2.7.4