Allow upgrade of Tizen with dynamic partitions 78/301478/2 accepted/tizen_unified_riscv accepted/tizen/unified/20240112.154550 accepted/tizen/unified/riscv/20240115.113627
authorJacek Kryszyn <j.kryszyn@samsung.com>
Thu, 16 Nov 2023 10:10:52 +0000 (11:10 +0100)
committerJacek Kryszyn <j.kryszyn@samsung.com>
Thu, 14 Dec 2023 14:34:20 +0000 (15:34 +0100)
This change adds support of dynamic partitions mapped from super
partition during upgrade.

Change-Id: I2bd8988646786af42ea20b55830a41a6e7cba97f

packaging/initrd-recovery.spec
src/bootmode-fota/40-fota.list.in
src/bootmode-fota/fota-init.sh

index 5f45d36..dce8808 100644 (file)
@@ -18,6 +18,7 @@ Requires: bash
 Requires: procps
 Requires: device-mapper
 Requires: verity-tools
+Requires: parse-dynparts
 
 %description
 This is a special booting mode and executes system recovery mode on user
index cefb6da..aa5b07f 100644 (file)
@@ -39,6 +39,7 @@ WITHLIBS="
 /usr/sbin/dmsetup
 /usr/sbin/bow-restore
 /usr/sbin/fstrim
+/usr/sbin/parse-dynparts
 "
 
 # LinkFileName:Target
index 4954334..2c084b9 100755 (executable)
@@ -31,6 +31,20 @@ do_reboot() {
        done
 }
 
+function map_from_super() {
+    local part_name="$1"
+    local part_table="$2"
+    echo "$part_table" | /usr/sbin/dmsetup create "$part_name" &>/dev/null
+    if [ $? = 0 ]
+    then
+        echo "/dev/mapper/$part_name"
+        return 0
+    else
+        echo "WARNING : SUPER FOUND BUT $part_name NOT FOUND" >&2
+        return 1
+    fi
+}
+
 #------------------------------------------------
 #       get partition id
 #------------------------------------------------
@@ -43,7 +57,33 @@ get_partition_id() {
         echo "Using A/B slot: ${P_SLOT}"
     fi
 
-    PART_ROOTFS=`/sbin/blkid -t PARTLABEL=rootfs${P_SUFFIX} -o device -l`
+    SUPERFS=`/sbin/blkid -t PARTLABEL=super -o device -l`
+    if [ x$SUPERFS = "x" ]
+    then
+        SUPERFS=`/sbin/blkid -t LABEL=super -o device -l`
+    fi
+
+    if [ x$SUPERFS != "x" ]
+    then
+        PARSE_DYNPARTS=`/usr/sbin/parse-dynparts "$SUPERFS" --list-tables`
+
+        while read -r part_name part_table; do
+            if [ "$part_name" = "rootfs${P_SUFFIX}" ]
+            then
+                PART_ROOTFS=`map_from_super "$part_name" "$part_table"`
+            fi
+
+            if [ "$part_name" = "hal${P_SUFFIX}" ]
+            then
+                PART_HAL=`map_from_super "$part_name" "$part_table"`
+            fi
+        done <<< "$PARSE_DYNPARTS"
+    fi
+
+    if [ x$PART_ROOTFS = "x" ]
+    then
+        PART_ROOTFS=`/sbin/blkid -t PARTLABEL=rootfs${P_SUFFIX} -o device -l`
+    fi
     if [ x$PART_ROOTFS = "x" ]
     then
         PART_ROOTFS=`/sbin/blkid -L rootfs`
@@ -61,7 +101,10 @@ get_partition_id() {
         PART_RAMDISK=`/sbin/blkid -L ramdisk`
     fi
 
-    PART_HAL=`/sbin/blkid -t PARTLABEL=hal${P_SUFFIX} -o device -l`
+    if [ x$HALFS = "x" ]
+    then
+        PART_HAL=`/sbin/blkid -t PARTLABEL=hal${P_SUFFIX} -o device -l`
+    fi
     if [ x$PART_HAL = "x" ]
     then
         PART_HAL=`/sbin/blkid -L hal`