mirror of https://github.com/hak5/openwrt-owl.git
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@kresin.me>owl
parent
668eb70157
commit
c90a8cb755
|
@ -250,19 +250,21 @@ nand_board_name() {
|
||||||
|
|
||||||
nand_upgrade_tar() {
|
nand_upgrade_tar() {
|
||||||
local tar_file="$1"
|
local tar_file="$1"
|
||||||
local board_name="$(nand_board_name)"
|
|
||||||
local kernel_mtd="$(find_mtd_index $CI_KERNPART)"
|
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 board_dir=$(tar tf $tar_file | grep -m 1 '^sysupgrade-.*/$')
|
||||||
local rootfs_length=`(tar xf $tar_file sysupgrade-$board_name/root -O | wc -c) 2> /dev/null`
|
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_kernel=1
|
||||||
local has_env=0
|
local has_env=0
|
||||||
|
|
||||||
[ "$kernel_length" != 0 -a -n "$kernel_mtd" ] && {
|
[ "$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
|
[ "$kernel_length" = 0 -o ! -z "$kernel_mtd" ] && has_kernel=0
|
||||||
|
|
||||||
|
@ -271,12 +273,12 @@ nand_upgrade_tar() {
|
||||||
local ubidev="$( nand_find_ubi "$CI_UBIPART" )"
|
local ubidev="$( nand_find_ubi "$CI_UBIPART" )"
|
||||||
[ "$has_kernel" = "1" ] && {
|
[ "$has_kernel" = "1" ] && {
|
||||||
local kern_ubivol="$(nand_find_volume $ubidev $CI_KERNPART)"
|
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 -
|
ubiupdatevol /dev/$kern_ubivol -s $kernel_length -
|
||||||
}
|
}
|
||||||
|
|
||||||
local root_ubivol="$(nand_find_volume $ubidev rootfs)"
|
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 -
|
ubiupdatevol /dev/$root_ubivol -s $rootfs_length -
|
||||||
|
|
||||||
nand_do_upgrade_success
|
nand_do_upgrade_success
|
||||||
|
|
Loading…
Reference in New Issue