base-files: emit diagnostics on sysupgrade abort
authorRodrigo Balerdi <lanchon@gmail.com>
Fri, 15 Apr 2022 03:44:26 +0000 (00:44 -0300)
committerDaniel Golle <daniel@makrotopia.org>
Tue, 19 Apr 2022 15:28:25 +0000 (16:28 +0100)
Emit diagnostics if nand sysupgrade is aborted because UBI partition
cannot be attached. Also avoid redudndant checks.

Signed-off-by: Rodrigo Balerdi <lanchon@gmail.com>
package/base-files/files/lib/upgrade/nand.sh

index 8720a78b4b4d98e87b06cf974073e4f2aae9d143..8f008d6a0671c5a29e18f408994b0dc4522f0dbe 100644 (file)
@@ -136,18 +136,23 @@ nand_upgrade_prepare_ubi() {
                ubiattach -m "$mtdnum"
                sync
                ubidev="$( nand_find_ubi "$CI_UBIPART" )"
-       fi
 
-       if [ ! "$ubidev" ]; then
-               ubiformat /dev/mtd$mtdnum -y
-               ubiattach -m "$mtdnum"
-               sync
-               ubidev="$( nand_find_ubi "$CI_UBIPART" )"
-               [ ! "$ubidev" ] && return 1
-               [ "$has_env" -gt 0 ] && {
-                       ubimkvol /dev/$ubidev -n 0 -N ubootenv -s 1MiB
-                       ubimkvol /dev/$ubidev -n 1 -N ubootenv2 -s 1MiB
-               }
+               if [ ! "$ubidev" ]; then
+                       ubiformat /dev/mtd$mtdnum -y
+                       ubiattach -m "$mtdnum"
+                       sync
+                       ubidev="$( nand_find_ubi "$CI_UBIPART" )"
+
+                       if [ ! "$ubidev" ]; then
+                               echo "cannot attach ubi mtd partition $CI_UBIPART"
+                               return 1
+                       fi
+
+                       if [ "$has_env" -gt 0 ]; then
+                               ubimkvol /dev/$ubidev -n 0 -N ubootenv -s 1MiB
+                               ubimkvol /dev/$ubidev -n 1 -N ubootenv2 -s 1MiB
+                       fi
+               fi
        fi
 
        local kern_ubivol="$( nand_find_volume $ubidev $CI_KERNPART )"