1
0

fwtool.sh 913 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. fwtool_pre_upgrade() {
  2. fwtool -q -i /dev/null "$1"
  3. }
  4. fwtool_check_image() {
  5. [ $# -gt 1 ] && return 1
  6. . /usr/share/libubox/jshn.sh
  7. if ! fwtool -q -i /tmp/sysupgrade.meta "$1"; then
  8. echo "Image metadata not found"
  9. [ "$REQUIRE_IMAGE_METADATA" = 1 -a "$FORCE" != 1 ] && {
  10. echo "Use sysupgrade -F to override this check when downgrading or flashing to vendor firmware"
  11. }
  12. [ "$REQUIRE_IMAGE_METADATA" = 1 ] && return 1
  13. return 0
  14. fi
  15. json_load "$(cat /tmp/sysupgrade.meta)" || {
  16. echo "Invalid image metadata"
  17. return 1
  18. }
  19. device="$(cat /tmp/sysinfo/board_name)"
  20. json_select supported_devices || return 1
  21. json_get_keys dev_keys
  22. for k in $dev_keys; do
  23. json_get_var dev "$k"
  24. [ "$dev" = "$device" ] && return 0
  25. done
  26. echo "Device $device not supported by this image"
  27. echo -n "Supported devices:"
  28. for k in $dev_keys; do
  29. json_get_var dev "$k"
  30. echo -n " $dev"
  31. done
  32. echo
  33. return 1
  34. }