base-files: Remove nand.sh dependency from emmc upgrade
authorBrian Norris <computersforpeace@gmail.com>
Fri, 13 Jan 2023 05:32:16 +0000 (21:32 -0800)
committerChristian Marangi <ansuelsmth@gmail.com>
Sat, 21 Jan 2023 00:02:23 +0000 (01:02 +0100)
emmc_do_upgrade() relies on identify() from the nand.sh upgrade helper.
This only works because FEATURES=emmc targets also tend to include
FEATURES=nand.

Rename identify_magic() to identify_magic_long() to match the common.sh
style and make it clear it pairs with other *_long() variants (and not,
say *_word()).

Signed-off-by: Brian Norris <computersforpeace@gmail.com>
package/base-files/files/lib/upgrade/common.sh
package/base-files/files/lib/upgrade/emmc.sh
package/base-files/files/lib/upgrade/nand.sh

index 5af061f6a43990afea92f8eacd865fe5249d8300..53b8865a57887d6ac75fa2d7a13fd68a7914be3b 100644 (file)
@@ -127,6 +127,33 @@ get_magic_fat32() {
        (get_image "$@" | dd bs=1 count=5 skip=82) 2>/dev/null
 }
 
+identify_magic_long() {
+       local magic=$1
+       case "$magic" in
+               "55424923")
+                       echo "ubi"
+                       ;;
+               "31181006")
+                       echo "ubifs"
+                       ;;
+               "68737173")
+                       echo "squashfs"
+                       ;;
+               "d00dfeed")
+                       echo "fit"
+                       ;;
+               "4349"*)
+                       echo "combined"
+                       ;;
+               "1f8b"*)
+                       echo "gzip"
+                       ;;
+               *)
+                       echo "unknown $magic"
+                       ;;
+       esac
+}
+
 part_magic_efi() {
        local magic=$(get_magic_gpt "$@")
        [ "$magic" = "EFI PART" ]
index c3b02864aa916b1c8863ed020f81cae61a9935ac..49cffe1c658b338e04081e69fcfef494cd848874 100644 (file)
@@ -58,7 +58,7 @@ emmc_copy_config() {
 }
 
 emmc_do_upgrade() {
-       local file_type=$(identify $1)
+       local file_type=$(identify_magic_long "$(get_magic_long "$1")")
 
        case "$file_type" in
                "fit")  emmc_upgrade_fit $1;;
index a8e3cab0b8b112d052f27c08c4e25791cd8ba57b..a1dbd6e2663dfb147c84c7fa4546ad028edb22a3 100644 (file)
@@ -65,40 +65,12 @@ get_magic_long_tar() {
        (tar xO${3}f "$1" "$2" | dd bs=4 count=1 | hexdump -v -n 4 -e '1/1 "%02x"') 2> /dev/null
 }
 
-identify_magic() {
-       local magic=$1
-       case "$magic" in
-               "55424923")
-                       echo "ubi"
-                       ;;
-               "31181006")
-                       echo "ubifs"
-                       ;;
-               "68737173")
-                       echo "squashfs"
-                       ;;
-               "d00dfeed")
-                       echo "fit"
-                       ;;
-               "4349"*)
-                       echo "combined"
-                       ;;
-               "1f8b"*)
-                       echo "gzip"
-                       ;;
-               *)
-                       echo "unknown $magic"
-                       ;;
-       esac
-}
-
-
 identify() {
-       identify_magic $(nand_get_magic_long "$@")
+       identify_magic_long $(nand_get_magic_long "$@")
 }
 
 identify_tar() {
-       identify_magic $(get_magic_long_tar "$@")
+       identify_magic_long $(get_magic_long_tar "$@")
 }
 
 identify_if_gzip() {