Change critical error logs to be logged as critical_logs 44/275444/1
authorSangYoun Kwak <sy.kwak@samsung.com>
Tue, 24 May 2022 01:34:32 +0000 (10:34 +0900)
committerHyotaek Shim <hyotaek.shim@samsung.com>
Wed, 25 May 2022 02:37:18 +0000 (02:37 +0000)
Change-Id: If1edd58b6c493c5f29959cc52bc52fbe617ab89b
Signed-off-by: SangYoun Kwak <sy.kwak@samsung.com>
(cherry picked from commit cc7ba5bb5aac8c61fb38eb5f89651791d9151293)

clone_partitions/clone_partitions.sh
scripts/upgrade-common.inc
scripts/upgrade-fota.sh
scripts/upgrade-full.sh
scripts/upgrade-legacy.sh
scripts/upgrade-partial.sh

index 939324fe1b5eab9cd62d52eb1c478b0d3210bc65..ee21340b5a56f628c74d67da99656d55df3caf28 100644 (file)
@@ -1,6 +1,33 @@
 #!/bin/bash
 PATH=/bin:/usr/bin:/sbin:/usr/sbin
 
+SCRIPT_NAME="clone_partitions.sh"
+
+#------------------------------------------------
+#       critical_log msg [file]
+#------------------------------------------------
+critical_log() {
+       # log format: [script_name][tag]actual_log
+       LOG="[${SCRIPT_NAME}]$1"
+       dlogsend -k "$LOG"
+       if [ "$2" != "" ]; then
+               echo "$LOG" >> "$2"
+       fi
+       echo "$LOG"
+}
+
+#------------------------------------------------
+#       log msg [file]
+#------------------------------------------------
+log() {
+       # log format: [script_name][tag]actual_log
+       LOG="[${SCRIPT_NAME}]$1"
+       if [ "$2" != "" ]; then
+               echo "$LOG" >> "$2"
+       fi
+       echo "$LOG"
+}
+
 set -o errexit
 trap 'echo "Aborting due to errexit on ${0##*/}:$LINENO. Exit code: $?" >&2' ERR
 set -o errtrace -e -o pipefail
@@ -10,13 +37,13 @@ if [ ! -z "${UPGRADE_DEBUG}" ]; then
 fi
 
 if [ "$(device_board_get_partition_ab_cloned)" -eq "1" ]; then
-       echo "[Info] Partitions already cloned"
+       log "[Info] Partitions already cloned"
        exit 0
 fi
 
 if /usr/libexec/upgrade-support/upgrade-prepare-partitions.sh; then
-       echo "[Info] Partitions have been cloned"
+       log "[Info] Partitions have been cloned"
        device_board_set_partition_ab_cloned
 else
-       echo "[Error] Partitions have not been cloned"
+       critical_log "[Error] Partitions have not been cloned"
 fi
index bf1ff93f8fe56581c443dc4aee19a71aa116f4f2..c313ad898e9b54e91829b85eb0496085e5e0980d 100644 (file)
@@ -6,6 +6,23 @@ HAL_PART_LIST_FILE="background_copy.list"
 CONFIG_FILE="update.cfg"
 SET_UPGRADE_STATUS="/usr/bin/device_board_set_upgrade_status"
 
+#------------------------------------------------
+#       critical_log msg [file]
+#------------------------------------------------
+critical_log() {
+       # log format: [script_name][tag]actual_log
+       LOG="[${SCRIPT_NAME}]$1"
+       dlogsend -k "$LOG"
+       if [ "$2" != "" ]; then
+               echo "$LOG" >> "$2"
+       fi
+       echo "$LOG"
+}
+
+critical_flog() {
+       critical_log "$1" "$LOG_FILE"
+}
+
 #------------------------------------------------
 #       log msg [file]
 #------------------------------------------------
index 41581abd0b50638e01d81d5074d7e5574d562017..0067b5cb34aad174e3ee4c507deaf0f24d936f7e 100755 (executable)
@@ -78,14 +78,14 @@ should_mount_rootfs() {
 mount() {
        if should_mount_rootfs; then
                if ! mount_partition rootfs "$FOTA_UPDATE_PREFIX" "rw"; then
-                       flog "[Error] Unable to mount rootfs"
+                       critical_flog "[Error] Unable to mount rootfs"
                        return 1
                fi
        else
                mkdir -p "$FOTA_UPDATE_PREFIX/opt"
        fi
        if ! mount_partition system-data "$FOTA_UPDATE_PREFIX/opt" "rw"; then
-               flog "[Error] Unable to mount opt"
+               critical_flog "[Error] Unable to mount opt"
                return 1
        fi
        untrap
@@ -103,13 +103,13 @@ reboot_to_fota() {
 
        flog "[Info] Switching board partition from $CURRENT_AB, to $NEXT_AB"
        if ! device_board_switch_partition $NEXT_AB; then
-               flog "[Error] Failed to switch board slot to $NEXT_AB"
+               critical_flog "[Error] Failed to switch board slot to $NEXT_AB"
                exit 1
        fi
        /bin/sync
        flog "[Info] Rebooting to fota"
        if ! /sbin/reboot fota; then
-               flog "[Error] Failed to reboot fota"
+               critical_flog "[Error] Failed to reboot fota"
                exit 1
        fi
 }
index 12126c71b5a57e2f4d5021586f81afb606e74cab..85dd3e51f9f864d31824adeb9a5c003acbfef780 100755 (executable)
@@ -40,13 +40,13 @@ reboot_to_fota() {
 
        flog "[Info] Switching board partition from $CURRENT_AB, to $NEXT_AB"
        if ! device_board_switch_partition $NEXT_AB; then
-               flog "[Error] Failed to switch board slot to $NEXT_AB"
+               critical_flog "[Error] Failed to switch board slot to $NEXT_AB"
                exit 1
        fi
        /bin/sync
        flog "[Info] Rebooting to fota"
        if ! /sbin/reboot fota; then
-               flog "[Error] Failed to reboot fota"
+               critical_flog "[Error] Failed to reboot fota"
                exit 1
        fi
 }
index 823cd43dce952037475d2c5eef49e09fe2afc3dc..73fc85d8a30188546ad3b7dfc499cb476e47cda8 100644 (file)
@@ -38,7 +38,7 @@ flash_pre_image() {
 
        /bin/tar xvfp "$DELTA_TAR" -C "$FOTA_DIR" "$CONFIG_FILE"
        if [ ! -e "$FOTA_DIR/$CONFIG_FILE" ]; then
-               log "[Error] There is no $CONFIG_FILE" "$LOG_FILE"
+               critical_log "[Error] There is no $CONFIG_FILE" "$LOG_FILE"
                return
        fi
 
@@ -109,6 +109,6 @@ sync
 # go to fota mode
 log "[Info] Go TOTA update..." "$LOG_FILE"
 if ! /sbin/reboot fota; then
-       log "[Error] Failed to reboot fota" "$LOG_FILE"
+       critical_log "[Error] Failed to reboot fota" "$LOG_FILE"
        exit 100
 fi
index 9f8ff762ec3bd6a4423ae75d484a44acc1abeba3..7295ec14c72e1de6a1867699248324da1cdaa506 100755 (executable)
@@ -168,19 +168,19 @@ copy_delta
 unpack_file "$DELTA_TAR" "$CONFIG_FILE"
 upgrade_images "$DELTA_TAR"
 if ! prepare_for_ua; then
-       flog "[Error] Unable to prepare_for_ua"
+       critical_flog "[Error] Unable to prepare_for_ua"
        cleanup
        exit_error
 fi
 
 if ! run_setup_script "$DELTA_TAR"; then
-       flog "[Error] Unable to run_setup_script"
+       critical_flog "[Error] Unable to run_setup_script"
        cleanup
        exit_error
 fi
 
 if ! run_ro_update; then
-       flog "[Error] Unable to run_ro_update"
+       critical_flog "[Error] Unable to run_ro_update"
        cleanup
        exit_error
 fi