[source] procd: nand: dont rely on boardname in nand_upgrade_tar

LEDE Commits lede-commits at lists.infradead.org
Fri Dec 8 12:03:34 PST 2017


mkresin pushed a commit to source.git, branch master:
https://git.lede-project.org/c90a8cb7552cc7e843c328283268d67709d26a8c

commit c90a8cb7552cc7e843c328283268d67709d26a8c
Author: Mathias Kresin <dev at kresin.me>
AuthorDate: Fri Apr 7 08:39:59 2017 +0200

    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 <dev at kresin.me>
---
 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 563db4c..1c6b86b 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



More information about the lede-commits mailing list