ramips: ethernet: Replace random_ether_addr with eth_hw_addr_random
[openwrt/openwrt.git] / target / linux / ath79 / base-files / lib / upgrade / platform.sh
index a7cb455b8e9a0c6f983934d74618d4dbb2c698ca..83c4e78d25c131fd92233339c0963180061b2150 100644 (file)
@@ -5,13 +5,31 @@
 PART_NAME=firmware
 REQUIRE_IMAGE_METADATA=1
 
-routerstation_do_upgrade() {
+redboot_fis_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 kern_part="$2"
+       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 "$UPGRADE_BACKUP" ] && append="-j $UPGRADE_BACKUP"
+               dd if="$sysup_file" bs=64k skip=1 2>/dev/null | \
+                       mtd -r $append -F$kern_part:$kern_length:0x80060000,rootfs write - $kern_part: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 "$UPGRADE_BACKUP" ] && append="-j $UPGRADE_BACKUP"
+               tar xf $sysup_file ${board_dir}kernel ${board_dir}root -O | \
+                       mtd -r $append -F$kern_part:$kern_length:0x80060000,rootfs write - $kern_part:rootfs
+
+       else
+               echo "Unknown image, aborting!"
+               return 1
+       fi
 }
 
 platform_check_image() {
@@ -22,12 +40,22 @@ platform_do_upgrade() {
        local board=$(board_name)
 
        case "$board" in
+       adtran,bsap1800-v2|\
+       adtran,bsap1840)
+               redboot_fis_do_upgrade "$1" vmlinux_2
+               ;;
+       jjplus,ja76pf2)
+               echo "Sysupgrade disabled due bug FS#2428"
+               ;;
        ubnt,routerstation|\
        ubnt,routerstation-pro)
-               routerstation_do_upgrade "$ARGV"
+               echo "Sysupgrade disabled due bug FS#2428"
+               ;;
+       zyxel,nbg6716)
+               nand_do_upgrade "$1"
                ;;
        *)
-               default_do_upgrade "$ARGV"
+               default_do_upgrade "$1"
                ;;
        esac
 }