[PATCH 6/6] rb532: determine sysupgrade-* directory for upgrade automatically

Adrian Schmutzler freifunk at adrianschmutzler.de
Sat Aug 22 07:07:52 EDT 2020


So far, the sysupgrade-* folder used during upgrade in rb532 was
hardcoded to contain the board name. Therefore, changing board name
or BOARD_NAME variable in image/Makefile might have broken upgrade.

Improve this by adding a step to determine the folder name via
a wildcard, as it is done for generic nand_upgrade_tar() in
lib/upgrade/nand.sh and for several other targets already.

Signed-off-by: Adrian Schmutzler <freifunk at adrianschmutzler.de>
---
 target/linux/rb532/base-files/lib/upgrade/platform.sh | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/target/linux/rb532/base-files/lib/upgrade/platform.sh b/target/linux/rb532/base-files/lib/upgrade/platform.sh
index 334d6e2ff6..988bf2f0f3 100644
--- a/target/linux/rb532/base-files/lib/upgrade/platform.sh
+++ b/target/linux/rb532/base-files/lib/upgrade/platform.sh
@@ -11,7 +11,14 @@ platform_check_image() {
 }
 
 platform_do_upgrade() {
+	local tar_file="$1"
+
+	local board_dir=$(tar tf "$tar_file" | grep -m 1 '^sysupgrade-.*/$')
+	board_dir=${board_dir%/}
+	[ -n "$board_dir" ] || return 1
+
 	mtd erase kernel
-	tar xf "$1" "sysupgrade-$(board_name)/kernel" -O | nandwrite -o /dev/mtd0 -
-	nand_do_upgrade "$1"
+	tar xf "$tar_file" "$(board_dir)/kernel" -O | nandwrite -o /dev/mtd0 -
+
+	nand_do_upgrade "$tar_file"
 }
-- 
2.20.1




More information about the openwrt-devel mailing list