#shellcheck shell=sh disable=SC2086,SC2154

######### BEGIN /usr/share/flash-kernel/preboot.d/00reform2_preboot ###########
# We need to set ${fdtfile} in uboot to select a default dtb for boot mediums
# that are supposed to boot on multiple devices like the Debian installer.
#
# But if ${fdtfile} is set, then bootscr.uboot-generic will use that instead of
# the dtb-${fk_kvers} symlink maintained by flash-kernel which will point to
# either the normal or the hdmi dtb for the reform.
#
# This preboot script overwrites ${fdtpath} such that even when ${fdtfile} is
# set to a reasonable default, u-boot will still use dtb-${fk_kvers} if it
# exists -- which it does after running flash-kernel.

if test -e ${devtype} ${devnum}:${partition} ${prefix}dtb-${fk_kvers}; then
  setenv fdtpath dtb-${fk_kvers}
fi
########## END /usr/share/flash-kernel/preboot.d/00reform2_preboot ############
