#!/bin/bash -e

# Play nice when run under debconf.
exec </dev/null >&2

abi=$1
initrd_file=$2
target=/boot/

function is_boot_dev_vfat() {
if ! mountpoint -q /boot; then
return 1
fi
local boot_partition bootfstype
boot_partition=$(findmnt --nofsroot -n -o SOURCE /boot)
bootfstype=$(blkid -s TYPE -o value $boot_partition)
if [[ "$bootfstype" == "vfat" ]]; then
return 0
fi
return 1
}

if is_boot_dev_vfat; then
cp ${initrd_file} ${target}/Initrd
sync -f ${target}/Initrd || true
else
ln -sf ${initrd_file} ${target}/Initrd
fi

exit 0
