scripts: upgrade-support: Add more information into log message 46/301146/4 accepted/tizen/unified/20231122.172552
authorJaehoon Chung <jh80.chung@samsung.com>
Thu, 9 Nov 2023 10:54:46 +0000 (19:54 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Mon, 20 Nov 2023 07:03:06 +0000 (16:03 +0900)
Add more information into log message.
To know exact sequence and time, add a LOG_DATE and totaltime about
background_copy.

After applying this patch,

[01/01/1970 09:29:21] [upgrade-prepare-partitions.sh][Info] Background copy rootfs, from: /dev/mmcblk0p2 to /dev/mmcblk0p12
[01/01/1970 09:32:29] [upgrade-prepare-partitions.sh][Info] Finished background copy rootfs from /dev/mmcblk0p2 to /dev/mmcblk0p12
[01/01/1970 09:32:29] [upgrade-prepare-partitions.sh][Info] Checksum verification for rootfs
[01/01/1970 09:34:47] [upgrade-prepare-partitions.sh][Info] Partition rootfs was cloned correctly
[01/01/1970 09:34:47] [upgrade-prepare-partitions.sh][Info] Background copy hal, from: /dev/mmcblk0p10 to /dev/mmcblk0p16
[01/01/1970 09:35:05] [upgrade-prepare-partitions.sh][Info] Finished background copy hal from /dev/mmcblk0p10 to /dev/mmcblk0p16
[01/01/1970 09:35:05] [upgrade-prepare-partitions.sh][Info] Finished Background copying A|B partitions for update...Total Time : 356 sec
[01/01/1970 09:35:05] [upgrade-prepare-partitions.sh]RO update preparation: upgrade-prepare-partitions.sh success
[01/01/1970 09:29:09] [upgrade-trigger.sh][Info] Triggered upgrade..
[01/01/1970 09:29:09] [upgrade-trigger.sh][Info] Using <delta.tar> delta file.
[01/01/1970 09:29:09] [upgrade-trigger.sh]set_upgrade_status success: 1
[01/01/1970 09:29:09] [upgrade-trigger.sh][Info] Package verifier is found. Verify delta.tar
[01/01/1970 09:29:09] [upgrade-trigger.sh][Info] Update package verification PASSED!
[01/01/1970 09:29:09] [upgrade-trigger.sh]set_upgrade_status success: 5
[01/01/1970 09:29:09] [upgrade-trigger.sh]Starting to prepare the partitions for upgrade..
[01/01/1970 09:35:05] [upgrade-trigger.sh]set_upgrade_status success: 20

The developers can know how long time takes for background copy with
Total Time.

Change-Id: I4cb004f14480c804dca2df3f15dddf5a83160dd3
Signed-off-by: Jaehoon Chung <jh80.chung@samsung.com>
scripts/upgrade-support/upgrade-common.inc
scripts/upgrade-support/upgrade-trigger.sh

index a3aba08..2426c11 100644 (file)
@@ -17,7 +17,7 @@ critical_log() {
        LOG="[${SCRIPT_NAME}]$1"
        dlogsend -k "$LOG"
        if [ "$2" != "" ]; then
-               echo "$LOG" >> "$2"
+               echo "[$(date +"%d/%m/%Y %H:%M:%S")]" "$LOG" >> "$2"
        fi
        echo "$LOG"
 
@@ -35,7 +35,7 @@ log() {
        # log format: [script_name][tag]actual_log
        LOG="[${SCRIPT_NAME}]$1"
        if [ "$2" != "" ]; then
-               echo "$LOG" >> "$2"
+               echo "[$(date +"%d/%m/%Y %H:%M:%S")]" "$LOG" >> "$2"
        fi
        echo "$LOG"
 
@@ -131,6 +131,7 @@ check_used_block_device() {
 
 background_copy() {
        flog "[Info] Background copying A|B partitions for update..."
+       start_duration=$(date +%s)
        for partition_name in ${PARTITION_LIST}; do
                # echo is there to suspend abort when partition will not be found e.g. hal
                if ! CURRENT_PARTITION="$(/usr/bin/blkid-print "$EMMC_DEVICE" "$partition_name" "$CURRENT_AB" |\
@@ -170,6 +171,9 @@ background_copy() {
                        fi
                fi
        done
+       end_duration=$(date +%s)
+       totaltime=$((end_duration - start_duration))
+       flog "[Info] Finished Background copying A|B partitions for update...Total Time : $totaltime sec"
        return $TRUE
 }
 
index 9e10669..64077bf 100644 (file)
@@ -46,7 +46,7 @@ log() {
        # log format: [script_name][tag]actual_log
        LOG="[${SCRIPT_NAME}]$1"
        if [ "$2" != "" ]; then
-               echo "$LOG" >> "$2"
+               echo "[$(date +"%d/%m/%Y %H:%M:%S")]" "$LOG" >> "$2"
        fi
        echo "$LOG"
 
@@ -65,6 +65,8 @@ do_update() {
                set_upgrade_status 5
 
                if [ "$(device_board_get_partition_ab_cloned)" -eq 0 ]; then
+                       log "Starting to prepare the partitions for upgrade.." "$LOG_FILE"
+
                        unpack_file "${DOWNLOAD_DELTA}" "${SCRIPT_UPGRADE_PREPARE_PARTITIONS}"
                        if ! "${FOTA_DIR}/${SCRIPT_UPGRADE_PREPARE_PARTITIONS}"; then
                                exit_error
@@ -83,6 +85,7 @@ do_update() {
                unpack_file "${DOWNLOAD_DELTA}" "${SCRIPT_UPGRADE_FOTA}"
 
                if ! "${FOTA_DIR}/${SCRIPT_UPGRADE_PARTIAL}" "${DOWNLOAD_DELTA}"; then
+                       log "[Error] Failed to run $SCRIPT_UPGRADE_PARTIAL ${DOWNLOAD_DELTA}"
                        exit_error
                fi
 
@@ -130,6 +133,7 @@ if [ "$#" != "1" ] || [ ! -f "$1" ]; then
        exit 1
 fi
 
+log "[Info] Triggered upgrade.." "$LOG_FILE"
 log "[Info] Using <$DOWNLOAD_DELTA> delta file." "$LOG_FILE"
 
 prepare_fota_dir