From fbb4ba4cfe3b5376f8be5462a745b4445fcb6b8d Mon Sep 17 00:00:00 2001 From: SangYoun Kwak Date: Mon, 27 Jun 2022 18:59:42 +0900 Subject: [PATCH] Add critical log where upgrade status is changing Change-Id: Ib6030b3236750d538149fe69c7f032c300da5668 Signed-off-by: SangYoun Kwak --- upgrade/rw-update-macro.inc | 10 ++++++++++ upgrade/update-finalize.sh.in | 25 ++++++++++++++++++++++++- upgrade/update.sh.in | 17 +++++++++++++++++ 3 files changed, 51 insertions(+), 1 deletion(-) diff --git a/upgrade/rw-update-macro.inc b/upgrade/rw-update-macro.inc index 3ad1365..5ed8aea 100644 --- a/upgrade/rw-update-macro.inc +++ b/upgrade/rw-update-macro.inc @@ -27,6 +27,16 @@ NOTIFY() echo -e "${COLOR_NOTIFY}${LOG_TEXT}${COLOR_RESET}" } +CRITICAL_LOG() +{ + LOG="[$SCRIPT_NAME]$1" + dlogsend -k "$LOG" + if [ "$2" != "" ]; then + echo "$LOG" >> "$2" + fi + echo "$LOG" +} + # Convert version to 4 digits convert_version() { i=0 diff --git a/upgrade/update-finalize.sh.in b/upgrade/update-finalize.sh.in index b7d08fc..acb2a14 100755 --- a/upgrade/update-finalize.sh.in +++ b/upgrade/update-finalize.sh.in @@ -4,6 +4,29 @@ PATH=/bin:/usr/bin:/sbin:/usr/sbin RW_MACRO=@TZ_SYS_UPGRADE@/rw-update-macro.inc +HAL_SET_UPGRADE_STATUS=/usr/bin/device_board_set_upgrade_status + +SCRIPT_NAME=$(basename $0) +CRITICAL_LOG() +{ + LOG="[$SCRIPT_NAME]$1" + dlogsend -k "$LOG" + if [ "$2" != "" ]; then + echo "$LOG" >> "$2" + fi + echo "$LOG" +} + +SET_UPGRADE_STATUS() +{ + ${HAL_SET_UPGRADE_STATUS} "$1" + if [ $? -eq 0 ]; then + CRITICAL_LOG "set_upgrade_status success: ${1}" + else + CRITICAL_LOG "set_upgrade_status failed: ${1}" + fi +} + if [ -f $RW_MACRO ]; then source $RW_MACRO @@ -20,7 +43,7 @@ if [ -z ${UPDATE_PREPARE_ERR+x} ] && [ "${UPDATE_SUCCESS}" == "1" ]; then COMMIT_CHANGES /usr/bin/device_board_clear_partition_ab_cloned /usr/bin/device_board_set_boot_success - /usr/bin/device_board_set_upgrade_status 100 + SET_UPGRADE_STATUS 100 reboot -f else reboot -f fota diff --git a/upgrade/update.sh.in b/upgrade/update.sh.in index 47a96d8..662fe64 100755 --- a/upgrade/update.sh.in +++ b/upgrade/update.sh.in @@ -20,6 +20,8 @@ HAL_PROGRESS_MAX=99 RW_MACRO=@TZ_SYS_UPGRADE@/rw-update-macro.inc RW_UPDATE_FLAG=/opt/.do_rw_update +SCRIPT_NAME=$(basename $0) + DEBUG() { LOG_TEXT=$1 @@ -38,6 +40,16 @@ NOTIFY() echo -e "${COLOR_NOTIFY}${LOG_TEXT}${COLOR_RESET}" } +CRITICAL_LOG() +{ + LOG="[$SCRIPT_NAME]$1" + dlogsend -k "$LOG" + if [ "$2" != "" ]; then + echo "$LOG" >> "$2" + fi + echo "$LOG" +} + PROGRESS_DIR=/tmp/upgrade PROGRESS_INIT() { @@ -74,6 +86,11 @@ SET_UPDATE_RESULT() SET_UPGRADE_STATUS() { ${HAL_SET_UPGRADE_STATUS} "$1" + if [ $? -eq 0 ]; then + CRITICAL_LOG "set_upgrade_status success: ${1}" + else + CRITICAL_LOG "set_upgrade_status failed: ${1}" + fi } if [[ $(