flash_uboot() {
  echo "A new U-Boot version needs to 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/u-boot.bin of=/dev/mmcblkX conv=fsync,notrunc bs=512 seek=1"
}

create_config() {
  mkdir -p /boot/extlinux/
  echo 'LABEL Manjaro ARM
KERNEL /Image
FDT /dtbs/amlogic/meson-sm1-odroid-c4.dtb
APPEND initrd=/initramfs-linux.img console=tty1 root=LABEL=ROOT_MNJRO rw rootwait quiet splash plymouth.ignore-serial-consoles '> /boot/extlinux/extlinux.conf
}

## arg 1:  the new package version
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
    create_config
  fi
}

## arg 1:  the new package version
## arg 2:  the old package version
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
    create_config
  fi
}
