flash_uboot() {
    echo "A new U-Boot version can be flashed onto your install drive. Please use lsblk to determine your drive, before proceeding."
    echo "You can do this by running:"
    echo "# dd if=/boot/idblock.bin of=/dev/mmcblkX seek=64 conv=notrunc,fsync"
    echo "# dd if=/boot/uboot.img of=/dev/mmcblkXp1 conv=notrunc,fsync"
}

post_install() {
  flash_uboot
  if [ -f /boot/extlinux/extlinux.conf.pacsave ]; then
  mv /boot/extlinux/extlinux.conf.pacsave /boot/extlinux/extlinux.conf
  fi
  if [ -f /boot/extlinux/extlinux.conf ]; then
  echo "Keeping old extlinux.conf file..."
  else
  mkdir -p /boot/extlinux/
  echo "LABEL Manjaro ARM
  LINUX /Image
  FDT /dtbs/rockchip/rk3566-roc-pc.dtb
  APPEND initrd=/initramfs-linux.img root=LABEL=ROOT_MNJRO rw earlycon=uart8250,mmio32,0xfe660000 console=tty1 console=ttyS2,1500000n8 quiet splash plymouth.ignore-serial-consoles" > /boot/extlinux/extlinux.conf
  fi
}

post_upgrade() {
  flash_uboot
  if [ -f /boot/extlinux/extlinux.conf.pacsave ]; then
  mv /boot/extlinux/extlinux.conf.pacsave /boot/extlinux/extlinux.conf
  fi
  if [ -f /boot/extlinux/extlinux.conf ]; then
  echo "Keeping old extlinux.conf file..."
  else
  mkdir -p /boot/extlinux/
  echo "LABEL Manjaro ARM
  LINUX /Image
  FDT /dtbs/rockchip/rk3566-roc-pc.dtb
  APPEND initrd=/initramfs-linux.img root=LABEL=ROOT_MNJRO rw earlycon=uart8250,mmio32,0xfe660000 console=tty1 console=ttyS2,1500000n8 quiet splash plymouth.ignore-serial-consoles" > /boot/extlinux/extlinux.conf
  fi
}
