From 0544704257bee51d215480a2ca4e55b3b2a55f99 Mon Sep 17 00:00:00 2001 From: viktorxda Date: Fri, 28 Apr 2023 17:15:53 +0200 Subject: [PATCH] sysupgrade: adjust get_flash_type function --- general/overlay/usr/sbin/sysupgrade | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/general/overlay/usr/sbin/sysupgrade b/general/overlay/usr/sbin/sysupgrade index 7d33cd8e..1b59a074 100755 --- a/general/overlay/usr/sbin/sysupgrade +++ b/general/overlay/usr/sbin/sysupgrade @@ -1,9 +1,9 @@ #!/bin/sh # -# OpenIPC.org | v.20221118 +# OpenIPC.org | v.20230503 # -scr_version=1.0.16 +scr_version=1.0.17 args=" $@" @@ -65,7 +65,7 @@ do_update_rootfs() { check_soc "$(head -1 ${y}/etc/hostname | cut -d- -f2)" compare_versions "$system_version" "$(get_system_version "$y")" && exit_update=1 umount "$y" && rm -rf "$y" && losetup -d "$loop" - [ "$exit_update" ] && return 0 + [ "1" = "$exit_update" ] && return 0 else die "Unable to mount $y!" fi @@ -77,15 +77,14 @@ do_update_rootfs() { do_wipe_overlay() { echo_c 33 "\nOverlayFS" echo "Erase overlay partition" - [ $(ipcinfo -F) = "nand" ] || jffs2="-j" + [ $(get_flash_type mtd) = "nand" ] || jffs2="-j" flash_eraseall $jffs2 "$(get_device "rootfs_data")" } download_firmware() { echo_c 33 "\nFirmware" osr=$(get_system_build) - ftype=$(ipcinfo -F 2>/dev/null) - [ ${#ftype} -ge 4 ] && ftype=$(get_flash_type) + ftype=$(get_flash_type) build="${soc}-${ftype}-${osr}" [ -z "$url" ] && url="https://github.com/OpenIPC/firmware/releases/download/latest/openipc.${build}.tgz" echo "Download from $url" @@ -206,10 +205,10 @@ get_system_build() { grep "BUILD_OPTION" "/etc/os-release" | head -1 | cut -d= -f2 } -# This flash type detection is deprecated and will be removed in the next updates... get_flash_type() { - has_nand=$(fw_printenv bootcmd | grep nand | wc -l) - [ "1" = "$has_nand" ] && echo "nand" || echo "nor" + local x=$(ipcinfo -F) + [ -z "$1" ] && [ "$x" = "nand" ] && $(fw_printenv bootcmd | grep -qv nand) && x=nor + echo "$x" } print_sysinfo() {