upgrade-scripts: Store the log message before exit_error 99/301099/5
authorJaehoon Chung <jh80.chung@samsung.com>
Wed, 8 Nov 2023 11:20:15 +0000 (20:20 +0900)
committerJaehoon Chung <jh80.chung@samsung.com>
Mon, 20 Nov 2023 07:01:24 +0000 (16:01 +0900)
The created files of tmp directory will be removed after rebooting.
That makes a difficult to debug when there is a problem.
To remain the log message, copy all log files from /tmp/ to /var/log/fota/ before exit_error.
If error is occurred, there should be the log files.

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

index e11a0cf..a3aba08 100644 (file)
@@ -305,6 +305,28 @@ set_upgrade_status() {
 
 exit_error() {
        set_upgrade_status -1
+       LOG_DIR="/var/log/fota"
+
+       if [ ! -d "$LOG_DIR" ]; then
+               /usr/bin/mkdir -p "$LOG_DIR"
+       fi
+
+       if [ -e /tmp/upgrade-prepare-partitions.log ]; then
+               /usr/bin/mv /tmp/upgrade-prepare-partitions.log $LOG_DIR/
+       fi
+
+       if [ -e /tmp/upgrade-trigger.log ]; then
+               /usr/bin/mv /tmp/upgrade-trigger.log $LOG_DIR/
+       fi
+
+       if [ -e /tmp/upgrade-partial.log ]; then
+               /usr/bin/mv /tmp/upgrade-partial.log $LOG_DIR/
+       fi
+
+       if [ -e /tmp/update-fota.log ]; then
+               /usr/bin/mv /tmp/update-fota.log $LOG_DIR/
+       fi
+
        exit 1
 }