upgrade-trigger.sh: Add support for launching A|B upgrade. 30/265630/11
authorErnest Borowski <e.borowski@samsung.com>
Mon, 25 Oct 2021 14:09:10 +0000 (14:09 +0000)
committerErnest Borowski <e.borowski@samsung.com>
Mon, 29 Nov 2021 15:55:19 +0000 (15:55 +0000)
This mode has different functionality therefore there are other scripts
supporting it.

When upgrade-trigger.sh detects that system uses A|B partition scheme
it executes new upgrade type using 3 stages:
1. upgrade-prepare-partitions.sh -- it is responsible for backing up
   partitions from current slot to next one
2. upgrade-partial.sh -- it is responsible for upgrading partitions
   on next slot using dd and delta.ua
3. upgrade-fota.sh -- it is responsible for finishing upgrade
   and rebooting device into fota RW mode.

Change-Id: I1c8c4fbaf3d2b4817ba7e88690cab316a5cee6e6
Signed-off-by: Ernest Borowski <e.borowski@samsung.com>
scripts/upgrade-trigger.sh

index 62167f763ae52e54e297d6e96e201957aacc247b..ceb2b2abd58153b8b2154612a487e08594e47ecd 100755 (executable)
@@ -24,6 +24,25 @@ log() {
        echo "$LOG"
 }
 
+check_ab_partition_scheme() {
+       CURRENT_AB="$(/bin/sed -E 's|.*(partition_ab=)([a-b]).*|\2|' /proc/cmdline)"
+       if [ "$CURRENT_AB" != "a" ] && [ "$CURRENT_AB" != "b" ]; then
+               log "[Info] Launching legacy update without A|B partition scheme" "$LOG_FILE"
+       else
+               log "[Info] Launching new update with A|B partition scheme" "$LOG_FILE"
+               if ! upgrade-prepare-partitions.sh; then
+                       exit 1
+               fi
+               if ! upgrade-partial.sh "$DOWNLOAD_DELTA"; then
+                       exit 1
+               fi
+               if ! upgrade-fota.sh; then
+                       exit 1
+               fi
+               exit 0
+       fi
+}
+
 rm -f "$LOG_FILE" && touch "$LOG_FILE"
 
 if [ "$#" != "1" ] || [ ! -f "$1" ]; then
@@ -42,6 +61,7 @@ else
 fi
 
 log "[Info] Using <$DELTA_TAR> delta file." "$LOG_FILE"
+check_ab_partition_scheme
 
 flash_pre_image() {
        log "[Info] Flash images for update..." "$LOG_FILE"
@@ -53,7 +73,7 @@ flash_pre_image() {
                return
        fi
 
-       while read -r PART_NAME DELTA_NAME TYPE DEV OFFSET SIZE HASH1 HASH2
+       while read -r PART_NAME DELTA_NAME TYPE DEV _OFFSET _SIZE _HASH1 _HASH2
        do
                if [ "$TYPE" = "PRE_UA" ]; then
                        /bin/tar xvfp "$DELTA_TAR" -C "$FOTA_DIR" "$DELTA_NAME"
@@ -72,9 +92,7 @@ flash_pre_image() {
                                DEV_NUM=$(/sbin/blkid -L "$PART_NAME" -o device | sed "\|$EMMC_DEVICE|!d" | \
                                                sed 's/\/dev\/mmcblk0p//')
                        fi
-                       if [ "$DEV_NUM" == "" ]; then
-                               DEV=${DEV}
-                       else
+                       if [ "$DEV_NUM" != "" ]; then
                                DEV="${EMMC_DEVICE}p${DEV_NUM}"
                        fi