- both efibootmgr and grub enable page_poison by default. Let's enable it with refind, too - The old post-install hook was written (by me, myself) was originally written in ed, and converted to ugly-and-lengthy while-read-echo sh. Both base-minimal, base-system, and base-chroot provides some kind of awk, let's rewrite it in awk.
54 lines
1 KiB
Bash
Executable file
54 lines
1 KiB
Bash
Executable file
#!/bin/sh
|
|
#
|
|
# Kernel hook for refind.
|
|
#
|
|
# Arguments passed to this script: $1 pkgname, $2 version.
|
|
#
|
|
PKGNAME="$1"
|
|
VERSION="$2"
|
|
|
|
. "${ROOTDIR}/etc/default/refind-kernel-hook.conf"
|
|
if [ "z$UPDATE_REFIND_CONF" != "z1" ]; then
|
|
exit 0;
|
|
fi
|
|
|
|
# Default refind.conf
|
|
: "${REFIND_CONF:=/boot/EFI/refind/refind.conf}"
|
|
|
|
zrefind_dir="${REFIND_CONF%/*}"
|
|
mkdir -p "$zrefind_dir"
|
|
touch "$REFIND_CONF"
|
|
|
|
tmpfile=$(mktemp /tmp/refind.XXXXXXX)
|
|
|
|
zefi_mountpoint=$(df -P "$REFIND_CONF" | awk 'NR==2{print $6}')
|
|
zicon="${zrefind_dir#$zefi_mountpoint}/icons/os_void.png"
|
|
zversion=$(echo "$VERSION" | sed 's/[.]/[.]/g')
|
|
|
|
zentry=$(cat <<EOF
|
|
menuentry "Void Linux $VERSION" {
|
|
icon $zicon
|
|
volume "Void Linux"
|
|
loader /vmlinuz-$VERSION
|
|
initrd /initramfs-$VERSION.img
|
|
options "$OPTIONS"
|
|
}
|
|
EOF
|
|
)
|
|
|
|
<"$REFIND_CONF" \
|
|
sed "/^menuentry \"Void Linux $zversion\" [{]\$/,/[}]/d" |
|
|
awk -v "entry=$zentry" '
|
|
/^timeout / {t=1}
|
|
/^menuentry / && !x {print entry; x=1}
|
|
1
|
|
END {
|
|
if (!x) {print entry}
|
|
if (!t) {print "timeout 20"}
|
|
}
|
|
' \
|
|
>"$tmpfile"
|
|
|
|
mv "$tmpfile" "$REFIND_CONF"
|
|
|
|
exit 0
|