#!/bin/sh
#
# Kernel hook for efibootmgr.
#
# Arguments passed to this script: $1 pkgname, $2 version.
#
PKGNAME="$1"

. "${ROOTDIR}/etc/default/efibootmgr-kernel-hook"
if [ "x${MODIFY_EFI_ENTRIES}" != x1 ]; then
	exit 0
fi

# get major version, e.g. "4.8" for "linux4.8"
major_version=$(echo $PKGNAME | cut -c 6-)

# get hex number of the matching entry
hexnum=$(efibootmgr | grep "Void Linux with kernel ${major_version}" | cut -c "5-8")

# delete it
[ "$hexnum" ] && efibootmgr -Bq -b $hexnum
