mediatek: backport upstream mediatek patches
[openwrt/openwrt.git] / target / linux / mediatek / base-files / lib / upgrade / platform.sh
index be72114..646ce0d 100755 (executable)
@@ -1,41 +1,29 @@
-#
-# Copyright (C) 2016 OpenWrt.org
-#
+platform_do_upgrade() {                 
+       default_do_upgrade "$ARGV"                                               
+}                                                                                
 
-platform_do_upgrade() {
-       local tar_file="$1"
-       local board="$(cat /tmp/sysinfo/board_name)"
+PART_NAME=firmware
 
-       echo "flashing kernel"
-       tar xf $tar_file sysupgrade-$board/kernel -O | mtd write - kernel
+platform_check_image() {                                                         
+       local board=$(board_name)                                                
+       local magic="$(get_magic_long "$1")"                                     
 
-       echo "flashing rootfs"
-       tar xf $tar_file sysupgrade-$board/root -O | mtd write - rootfs
+       [ "$#" -gt 1 ] && return 1                                               
 
-       return 0
-}
+       case "$board" in                                                       
+       bananapi,bpi-r2)                                                       
+               [ "$magic" != "27051956" ] && {   
+                       echo "Invalid image type."
+                       return 1                                     
+               }                                                    
+               return 0                                             
+               ;;                                                   
 
-platform_check_image() {
-       local tar_file="$1"
-       local board=$(cat /tmp/sysinfo/board_name)
-
-       case "$board" in
-       NAND | \
-       eMMC)
-               local kernel_length=`(tar xf $tar_file sysupgrade-$board/kernel -O | wc -c) 2> /dev/null`
-               local rootfs_length=`(tar xf $tar_file sysupgrade-$board/root -O | wc -c) 2> /dev/null`
-               ;;
-
-       *)
+       *)                                                           
                echo "Sysupgrade is not supported on your board yet."
-               return 1
-               ;;
-       esac
-
-       [ "$kernel_length" = 0 -o "$rootfs_length" = 0 ] && {
-               echo "The upgarde image is corrupt."
-               return 1
-       }
+               return 1                                             
+               ;;                                
+       esac                                      
 
-       return 0
-}
+       return 0                                                                                         
+}