From c90a8cb7552cc7e843c328283268d67709d26a8c Mon Sep 17 00:00:00 2001 From: Mathias Kresin Date: Fri, 7 Apr 2017 08:39:59 +0200 Subject: [PATCH] procd: nand: dont rely on boardname in nand_upgrade_tar Kernel and rootfs in a subdirectory matching the userspace boardname, was intended to use a single sysupgrade-tar archive for multiple boards with different kernel/rootfs images. This feature was never used. Use the first found directory in the tar archive instead of relying on a directory named according to the userspace boardname. It allows to change the boardname without adding another compatibility layer - using the nand_board_name() function - for (sub)targets using the metadata based image validation in favour to nand_do_platform_check(). Signed-off-by: Mathias Kresin --- package/base-files/files/lib/upgrade/nand.sh | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/package/base-files/files/lib/upgrade/nand.sh b/package/base-files/files/lib/upgrade/nand.sh index 563db4c320..1c6b86bcaa 100644 --- a/package/base-files/files/lib/upgrade/nand.sh +++ b/package/base-files/files/lib/upgrade/nand.sh @@ -250,19 +250,21 @@ nand_board_name() { nand_upgrade_tar() { local tar_file="$1" - local board_name="$(nand_board_name)" local kernel_mtd="$(find_mtd_index $CI_KERNPART)" - local kernel_length=`(tar xf $tar_file sysupgrade-$board_name/kernel -O | wc -c) 2> /dev/null` - local rootfs_length=`(tar xf $tar_file sysupgrade-$board_name/root -O | wc -c) 2> /dev/null` + local board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$') + board_dir=${board_dir%/} - local rootfs_type="$(identify_tar "$tar_file" sysupgrade-$board_name/root)" + local kernel_length=`(tar xf $tar_file ${board_dir}/kernel -O | wc -c) 2> /dev/null` + local rootfs_length=`(tar xf $tar_file ${board_dir}/root -O | wc -c) 2> /dev/null` + + local rootfs_type="$(identify_tar "$tar_file" ${board_dir}/root)" local has_kernel=1 local has_env=0 [ "$kernel_length" != 0 -a -n "$kernel_mtd" ] && { - tar xf $tar_file sysupgrade-$board_name/kernel -O | mtd write - $CI_KERNPART + tar xf $tar_file ${board_dir}/kernel -O | mtd write - $CI_KERNPART } [ "$kernel_length" = 0 -o ! -z "$kernel_mtd" ] && has_kernel=0 @@ -271,12 +273,12 @@ nand_upgrade_tar() { local ubidev="$( nand_find_ubi "$CI_UBIPART" )" [ "$has_kernel" = "1" ] && { local kern_ubivol="$(nand_find_volume $ubidev $CI_KERNPART)" - tar xf $tar_file sysupgrade-$board_name/kernel -O | \ + tar xf $tar_file ${board_dir}/kernel -O | \ ubiupdatevol /dev/$kern_ubivol -s $kernel_length - } local root_ubivol="$(nand_find_volume $ubidev rootfs)" - tar xf $tar_file sysupgrade-$board_name/root -O | \ + tar xf $tar_file ${board_dir}/root -O | \ ubiupdatevol /dev/$root_ubivol -s $rootfs_length - nand_do_upgrade_success