mediatek: mt7622: bpi-r64: fix sysupgrade on empty disk
authorDaniel Golle <daniel@makrotopia.org>
Mon, 1 Mar 2021 19:31:51 +0000 (19:31 +0000)
committerDaniel Golle <daniel@makrotopia.org>
Mon, 1 Mar 2021 19:35:08 +0000 (19:35 +0000)
Signed-off-by: Daniel Golle <daniel@makrotopia.org>
target/linux/mediatek/mt7622/base-files/lib/upgrade/platform.sh

index 07efe1336342d2c08c5dcf2c2f6bdd94b588436e..4e45c026ab30f179c181131c83fbbbf87fe49309 100755 (executable)
@@ -16,6 +16,13 @@ get_rootdev() {
        local rootvol rootdev
        rootvol=$(get_cmdline_var root)
        rootvol=$(basename $rootvol)
+       [ -e /sys/class/block/$rootvol ] || {
+               rootvol=${rootvol%%[0-9]}
+               [ -e /sys/class/block/$rootvol ] && echo $rootvol
+               rootvol=${rootvol%%p}
+               [ -e /sys/class/block/$rootvol ] && echo $rootvol
+               return
+       }
        [ -e /sys/class/block/$rootvol/partition ] || {
                echo $rootvol
                return
@@ -89,13 +96,13 @@ platform_check_image() {
 }
 
 platform_copy_config_mmc() {
+       [ -e "$UPGRADE_BACKUP" ] || return
        local rootdev=$(cat /tmp/sysupgrade.rootdev)
        blockdev --rereadpt /dev/$rootdev
        local datadev=$(get_partition $rootdev rootfs_data)
        [ "$datadev" ] || echo "no rootfs_data partition, cannot keep configuration." >&2
        dd if="$UPGRADE_BACKUP" of=/dev/$datadev
        sync
-       sleep 4
 }
 
 platform_copy_config() {