brcm47xx: use separated function in upgrade to detect file type
[openwrt/svn-archive/archive.git] / target / linux / brcm47xx / base-files / lib / upgrade / platform.sh
1 PART_NAME=firmware
2
3 brcm47xx_identify() {
4 local magic
5
6 magic=$(get_magic_long "$1")
7 case "$magic" in
8 "48445230")
9 echo "trx"
10 return
11 ;;
12 "2a23245e")
13 echo "chk"
14 return
15 ;;
16 esac
17
18 echo "unknown"
19 }
20
21 platform_check_image() {
22 [ "$#" -gt 1 ] && return 1
23
24 local file_type=$(brcm47xx_identify "$1")
25
26 case "$file_type" in
27 "trx") return 0;;
28 *)
29 echo "Invalid image type. Please use only .trx files"
30 return 1
31 ;;
32 esac
33 }
34
35 # use default for platform_do_upgrade()