flash_uboot() {
  if [[ -e /dev/mmcblk0boot1 ]]; then
    dev="/dev/mmcblk0"
  else
    dev="/dev/mmcblk1"
  fi

  echo "A new U-Boot version needs to be flashed onto ${dev}."
  echo "Do you want to do this now? [y|N]"
  read -r shouldwe
  if [[ $shouldwe =~ ^([yY][eE][sS]|[yY])$ ]]; then
    dd if=/boot/NON-HLOS.bin of=${dev}p1
    dd if=/boot/sbl1.mbn of=${dev}p2
    dd if=/boot/rpm.mbn of=${dev}p3
    dd if=/boot/tz.mbn of=${dev}p4
    dd if=/boot/hyp.mbn of=${dev}p5
    dd if=/boot/emmc_appsboot.mbn of=${dev}p7
    dd if=/boot/u-boot.img of=${dev}p8
  else
    echo "You can do this later by reinstalling the package."
  fi
}

post_install() {
  flash_uboot
}

post_upgrade() {
  flash_uboot
}