notice_uboot() {
  echo "New version of U-Boot firmware can be flashed to your microSD card (mmcblk1)"
  echo "or eMMC module (mmcblk2).  You can do that by running:"
    echo "dd if=/boot/bl1.bin.hardkernel of=/dev/mmcblkX conv=fsync bs=1 count=442"
    echo "dd if=/boot/bl1.bin.hardkernel of=/dev/mmcblkX conv=fsync bs=512 skip=1 seek=1"
    echo "dd if=/boot/u-boot.gxbb of=/dev/mmcblkX conv=fsync bs=512 seek=97"
}

create_config() {
  mkdir -p /boot/extlinux
  echo "LABEL Manjaro ARM
KERNEL /Image
FDT /dtbs/amlogic/meson-gxbb-odroidc2.dtb
APPEND initrd=/initramfs-linux.img console=ttyAML0,115200n8 root=LABEL=ROOT_MNJRO rw rootwait quiet splash plymouth.ignore-serial-consoles" > /boot/extlinux/extlinux.conf
}

post_install() {
  notice_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
}

post_upgrade() {
  notice_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
}

