diff options
author | Tomasz Maciej Nowak <tomek_n@o2.pl> | 2019-03-04 15:14:18 +0100 |
---|---|---|
committer | Christian Lamparter <chunkeey@gmail.com> | 2019-03-18 20:43:09 +0100 |
commit | 8f6f2603029726e62f0fae49c03684472fed2b3d (patch) | |
tree | 2f677c93b7fa4b02bbbf6e6ceaa4fa750d9b8f56 /target/linux/ath79/base-files/lib | |
parent | f3da2ebf90f74aee9b7840e34bff16292be8d712 (diff) | |
download | upstream-8f6f2603029726e62f0fae49c03684472fed2b3d.tar.gz upstream-8f6f2603029726e62f0fae49c03684472fed2b3d.tar.bz2 upstream-8f6f2603029726e62f0fae49c03684472fed2b3d.zip |
ath79: routerstation: prepare to use sysupgrade-tar format image
In PR [1] introducing initial support for Ubiquiti RouterStation boards,
Mathias Kresin suggested to replace the combined sysupgrade image with
tarball generated by sysupgrade-tar.sh. This would simplify deployment
of sysupgrade as the kernel size (needed to update FIS partition) could
be simply calculated on the fly instead of reading value from combined
image header. Unfortunately this would break sysupgrade compatibility
between ar71xx image and ath79 image. Therefore this commit creates
migration path to use new sysuprade image, it adds code to accept both
of them at this moment. The plan is to keep it until new stable version
is released. Then the image recipe should be changed to new format and
compatibility code for old image removed.
1. https://github.com/openwrt/openwrt/pull/1237
Signed-off-by: Tomasz Maciej Nowak <tomek_n@o2.pl>
Diffstat (limited to 'target/linux/ath79/base-files/lib')
-rw-r--r-- | target/linux/ath79/base-files/lib/upgrade/platform.sh | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/target/linux/ath79/base-files/lib/upgrade/platform.sh b/target/linux/ath79/base-files/lib/upgrade/platform.sh index a7cb455b8e..bc19149d5c 100644 --- a/target/linux/ath79/base-files/lib/upgrade/platform.sh +++ b/target/linux/ath79/base-files/lib/upgrade/platform.sh @@ -7,11 +7,28 @@ REQUIRE_IMAGE_METADATA=1 routerstation_do_upgrade() { local append - local kern_length=0x$(dd if="$1" bs=2 skip=1 count=4 2>/dev/null) + local sysup_file="$1" + local magic=$(get_magic_word "$sysup_file") - [ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && append="-j $CONF_TAR" - dd if="$1" bs=64k skip=1 2>/dev/null | \ - mtd -r $append -Fkernel:$kern_length:0x80060000,rootfs write - kernel:rootfs + if [ "$magic" = "4349" ]; then + local kern_length=0x$(dd if="$sysup_file" bs=2 skip=1 count=4 2>/dev/null) + + [ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && append="-j $CONF_TAR" + dd if="$sysup_file" bs=64k skip=1 2>/dev/null | \ + mtd -r $append -Fkernel:$kern_length:0x80060000,rootfs write - kernel:rootfs + + elif [ "$magic" = "7379" ]; then + local board_dir=$(tar tf $sysup_file | grep -m 1 '^sysupgrade-.*/$') + local kern_length=$(tar xf $sysup_file ${board_dir}kernel -O | wc -c) + + [ -f "$CONF_TAR" -a "$SAVE_CONFIG" -eq 1 ] && append="-j $CONF_TAR" + tar xf $sysup_file ${board_dir}kernel ${board_dir}root -O | \ + mtd -r $append -Fkernel:$kern_length:0x80060000,rootfs write - kernel:rootfs + + else + echo "Unknown image, aborting!" + return 1 + fi } platform_check_image() { |