Cancel the RW Update if there is no .do_rw_update files 09/272009/2
authorMateusz Moscicki <m.moscicki2@partner.samsung.com>
Fri, 4 Mar 2022 15:37:08 +0000 (16:37 +0100)
committerMateusz Moscicki <m.moscicki2@partner.samsung.com>
Fri, 11 Mar 2022 13:14:32 +0000 (14:14 +0100)
This change is to prevent re-executing an upgrade if the system was
booted in FOTA mode for reasons other than the actual upgrade.

Change-Id: Ib5dc49c42b8878d8389f17d678526ff51f1ba39d

upgrade/update.sh.in

index 0d23538..7471a2b 100755 (executable)
@@ -15,6 +15,7 @@ UPDATE_DATA_DIR=/opt/data/update
 SDB_RULE=${UPDATE_DATA_DIR}/99-sdb-switch.rules
 
 RW_MACRO=@TZ_SYS_UPGRADE@/rw-update-macro.inc
+RW_UPDATE_FLAG=/opt/.do_rw_update
 
 DEBUG()
 {
@@ -67,6 +68,12 @@ SET_UPDATE_RESULT()
        echo "$1" > ${UPDATE_RESULT_FILE}
 }
 
+if [[ $(</proc/cmdline) =~ partition_ab= ]] && [ ! -f ${RW_UPDATE_FLAG} ]
+then
+       NOTIFY "${RW_UPDATE_FLAG} file does not exist. Cancel RW Upgrade."
+       exit
+fi
+
 NOTIFY "----------------------------------------------------------------------"
 NOTIFY "System RW update: rw update started"
 
@@ -130,7 +137,7 @@ if [ -e ${SDB_RULE} ]; then
        rm ${SDB_RULE}
 fi
 
-rm /opt/.do_rw_update
+rm ${RW_UPDATE_FLAG}
 
 /bin/sync
 NOTIFY "----------------------------------------------------------------------"