summaryrefslogtreecommitdiffstats
path: root/target/linux/mediatek/base-files/lib/upgrade/platform.sh
blob: be72114adb4e43f92ad03106a28d415438738b27 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#
# Copyright (C) 2016 OpenWrt.org
#

platform_do_upgrade() {
	local tar_file="$1"
	local board="$(cat /tmp/sysinfo/board_name)"

	echo "flashing kernel"
	tar xf $tar_file sysupgrade-$board/kernel -O | mtd write - kernel

	echo "flashing rootfs"
	tar xf $tar_file sysupgrade-$board/root -O | mtd write - rootfs

	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 0
}