void-packages/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-remove
m3tav3rse c6c970e142 efibootmgr: fix post-remove kernel hook
Don't attempt to delete nonexistent UEFI entries from previous kernel versions.
Fixes #13133
2021-03-17 10:55:02 -03:00

21 lines
496 B
Bash

#!/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