diff --git a/iop/scripts/iopupgrade.sh b/iop/scripts/iopupgrade.sh index 7eb0d8eb3..eb8b7beda 100644 --- a/iop/scripts/iopupgrade.sh +++ b/iop/scripts/iopupgrade.sh @@ -242,30 +242,16 @@ function ssh_upgrade { esac done - if [ -n "$upd_fw" ]; then - upd_fw_base=$(basename $upd_fw) - else + if [ -z "$upd_fw" ]; then set_config_string CONFIG_TARGET_BOARD set_config_string CONFIG_TARGET_SUBTARGET - firmwares=$( - cd "bin/targets/$CONFIG_TARGET_BOARD/$CONFIG_TARGET_SUBTARGET/" - ls -t *[0-9].y[3] - ) - - # if target uses pkgtb - if [ -z "$firmwares"]; then - firmwares=$( - cd bin/targets/$CONFIG_TARGET_BOARD/$CONFIG_TARGET_SUBTARGET/ - ls -t last.pkgtb - ) + upd_fw="$(realpath -q --canonicalize-existing --relative-to=. "bin/targets/$CONFIG_TARGET_BOARD/$CONFIG_TARGET_SUBTARGET/"last.{pkgtb,itb})" + if [ -z "$upd_fw" ] && [ $do_dialog -eq 0 ]; then + echo "Could not find image. Check that last.{itb,pkgtb} exists or specify an image using -f or -i (interactive)." >&2 + return 1 fi - - for upd_fw_base in $firmwares; do - #echo "firmware $upd_fw" - break - done - upd_fw="bin/targets/$CONFIG_TARGET_BOARD/$CONFIG_TARGET_SUBTARGET/$upd_fw_base" fi + upd_fw_base="$(basename "$upd_fw")" [ $do_dialog -eq 1 ] && upd_select_start