OpenWrt – Diff between revs 2 and 3
?pathlinks?
Rev 2 | Rev 3 | |||
---|---|---|---|---|
1 | fwtool_check_signature() { |
- | ||
2 | [ $# -gt 1 ] && return 1 |
- | ||
3 | |
- | ||
4 | [ ! -x /usr/bin/ucert ] && { |
- | ||
5 | if [ "$REQUIRE_IMAGE_SIGNATURE" = 1 ]; then |
- | ||
6 | return 1 |
- | ||
7 | else |
- | ||
8 | return 0 |
- | ||
9 | fi |
- | ||
10 | } |
- | ||
11 | |
- | ||
12 | if ! fwtool -q -s /tmp/sysupgrade.ucert "$1"; then |
- | ||
13 | echo "Image signature not found" |
- | ||
14 | [ "$REQUIRE_IMAGE_SIGNATURE" = 1 -a "$FORCE" != 1 ] && { |
- | ||
15 | echo "Use sysupgrade -F to override this check when downgrading or flashing to vendor firmware" |
- | ||
16 | } |
- | ||
17 | [ "$REQUIRE_IMAGE_SIGNATURE" = 1 ] && return 1 |
- | ||
18 | return 0 |
- | ||
19 | fi |
- | ||
20 | |
- | ||
21 | fwtool -q -T -s /dev/null "$1" | \ |
- | ||
22 | ucert -V -m - -c "/tmp/sysupgrade.ucert" -P /etc/opkg/keys |
- | ||
23 | |
- | ||
24 | return $? |
- | ||
25 | } |
- | ||
26 | |
- | ||
27 | fwtool_check_image() { |
1 | fwtool_check_image() { |
|
28 | [ $# -gt 1 ] && return 1 |
2 | [ $# -gt 1 ] && return 1 |
|
29 | |
3 | |
|
30 | . /usr/share/libubox/jshn.sh |
4 | . /usr/share/libubox/jshn.sh |
|
31 | |
5 | |
|
32 | if ! fwtool -q -i /tmp/sysupgrade.meta "$1"; then |
6 | if ! fwtool -q -i /tmp/sysupgrade.meta "$1"; then |
|
33 | echo "Image metadata not found" |
7 | echo "Image metadata not found" |
|
34 | [ "$REQUIRE_IMAGE_METADATA" = 1 -a "$FORCE" != 1 ] && { |
8 | [ "$REQUIRE_IMAGE_METADATA" = 1 -a "$FORCE" != 1 ] && { |
|
35 | echo "Use sysupgrade -F to override this check when downgrading or flashing to vendor firmware" |
9 | echo "Use sysupgrade -F to override this check when downgrading or flashing to vendor firmware" |
|
36 | } |
10 | } |
|
37 | [ "$REQUIRE_IMAGE_METADATA" = 1 ] && return 1 |
11 | [ "$REQUIRE_IMAGE_METADATA" = 1 ] && return 1 |
|
38 | return 0 |
12 | return 0 |
|
39 | fi |
13 | fi |
|
40 | |
14 | |
|
41 | json_load "$(cat /tmp/sysupgrade.meta)" || { |
15 | json_load "$(cat /tmp/sysupgrade.meta)" || { |
|
42 | echo "Invalid image metadata" |
16 | echo "Invalid image metadata" |
|
43 | return 1 |
17 | return 1 |
|
44 | } |
18 | } |
|
45 | |
19 | |
|
46 | device="$(cat /tmp/sysinfo/board_name)" |
20 | device="$(cat /tmp/sysinfo/board_name)" |
|
47 | |
21 | |
|
48 | json_select supported_devices || return 1 |
22 | json_select supported_devices || return 1 |
|
49 | |
23 | |
|
50 | json_get_keys dev_keys |
24 | json_get_keys dev_keys |
|
51 | for k in $dev_keys; do |
25 | for k in $dev_keys; do |
|
52 | json_get_var dev "$k" |
26 | json_get_var dev "$k" |
|
53 | [ "$dev" = "$device" ] && return 0 |
27 | [ "$dev" = "$device" ] && return 0 |
|
54 | done |
28 | done |
|
55 | |
29 | |
|
56 | echo "Device $device not supported by this image" |
30 | echo "Device $device not supported by this image" |
|
57 | echo -n "Supported devices:" |
31 | echo -n "Supported devices:" |
|
58 | for k in $dev_keys; do |
32 | for k in $dev_keys; do |
|
59 | json_get_var dev "$k" |
33 | json_get_var dev "$k" |
|
60 | echo -n " $dev" |
34 | echo -n " $dev" |
|
61 | done |
35 | done |
|
62 | echo |
36 | echo |
|
63 | |
37 | |
|
64 | return 1 |
38 | return 1 |
|
65 | } |
39 | } |
|
66 | |
40 | |