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
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"
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
set_upgrade_status 1
verify_img "${DOWNLOAD_DELTA}"
do_update
-
-critical_log "RO update: $SCRIPT_NAME success" "$LOG_FILE"
) 9> "$FLOCK_PATH"