base-files: fix nand_do_platform_check fail
authorChen Minqiang <ptpt52@gmail.com>
Sun, 18 Dec 2022 00:57:20 +0000 (08:57 +0800)
committerDaniel Golle <daniel@makrotopia.org>
Sun, 29 Jan 2023 01:02:45 +0000 (01:02 +0000)
This change ensures compatibility with both types of sysupgrade-tar files.

1. For some boards like xiaomi,redmi-router-ax6s, sysupgrade-tar
   is pack in directory `vendor,name/`

2. For some boards like xiaomi,mi-router-3g, sysupgrade-tar is pack
   in directory `vendor_name/`

Signed-off-by: Chen Minqiang <ptpt52@gmail.com>
package/base-files/files/lib/upgrade/nand.sh

index a1dbd6e2663dfb147c84c7fa4546ad028edb22a3..e7ac34f5d0cf3abfa66735db2151e059a642fdb8 100644 (file)
@@ -453,7 +453,11 @@ nand_do_platform_check() {
 
        local gz="$(identify_if_gzip "$file")"
        local file_type="$(identify "$file" "" "$gz")"
-       local control_length=$( (tar xO${gz}f "$file" "sysupgrade-$board_name/CONTROL" | wc -c) 2> /dev/null)
+       local control_length=$( (tar xO${gz}f "$file" "sysupgrade-${board_name//,/_}/CONTROL" | wc -c) 2> /dev/null)
+
+       if [ "$control_length" = 0 ]; then
+               control_length=$( (tar xO${gz}f "$file" "sysupgrade-${board_name//_/,}/CONTROL" | wc -c) 2> /dev/null)
+       fi
 
        if [ "$control_length" != 0 ]; then
                nand_verify_tar_file "$file" "$gz" || return 1