octeon: add sysupgrade support for the erlite
[openwrt.git] / target / linux / octeon / base-files / lib / upgrade / platform.sh
1 #
2 # Copyright (C) 2010 OpenWrt.org
3 #
4
5 . /lib/functions/octeon.sh
6
7 platform_do_upgrade() {
8         local board=$(octeon_board_name)
9
10         case "$board" in
11         erlite)
12                 local tar_file="$1"
13                 local kernel_length=`(tar xf $tar_file sysupgrade-erlite/kernel -O | wc -c) 2> /dev/null`
14                 local rootfs_length=`(tar xf $tar_file sysupgrade-erlite/root -O | wc -c) 2> /dev/null`
15
16                 [ -f /boot/vmlinux.64 -a ! -L /boot/vmlinux.64 ] && {
17                         mv /boot/vmlinux.64 /boot/vmlinux.64.previous
18                         mv /boot/vmlinux.64.md5 /boot/vmlinux.64.md5.previous
19                 }
20
21                 mkdir -p /boot
22                 mount -t vfat /dev/sda1 /boot
23                 tar xf $tar_file sysupgrade-erlite/kernel -O > /boot/vmlinux.64
24                 md5sum /boot/vmlinux.64 | cut -f1 -d " " > /boot/vmlinux.64.md5
25                 tar xf $tar_file sysupgrade-erlite/root -O | dd of=/dev/sda2 bs=4096
26                 sync
27                 umount /mnt
28                 return 0
29                 ;;
30         esac
31
32         return 1
33         
34 }
35
36 platform_check_image() {
37         local board=$(octeon_board_name)
38
39         case "$board" in
40         erlite)
41                 local tar_file="$1"
42                 local kernel_length=`(tar xf $tar_file sysupgrade-erlite/kernel -O | wc -c) 2> /dev/null`
43                 local rootfs_length=`(tar xf $tar_file sysupgrade-erlite/root -O | wc -c) 2> /dev/null`
44                 [ "$kernel_length" = 0 -o "$rootfs_length" = 0 ] && {
45                         echo "The upgarde image is corrupt."
46                         return 1
47                 }
48                 return 0
49                 ;;
50         esac
51
52         echo "Sysupgrade is not yet supported on $board."
53         return 1
54 }