void-packages/srcpkgs/gummiboot/files/kernel.d/gummiboot.post-install

40 lines
846 B
Bash

#!/bin/sh
#
# Kernel hook for gummiboot.
#
# Arguments passed to this script: $1 pkgname, $2 version.
#
PKGNAME="$1"
VERSION="$2"
boot=$ROOTDIR/boot
entries=$boot/loader/entries
name=void-$VERSION
entry=$entries/$name.conf
options=$boot/loader/void-options.conf
loader=$boot/loader/loader.conf
[ -d $boot ] || exit 0
mkdir -p $entries
cat <<-EOF > $entry
title Void Linux
version $VERSION
linux /vmlinuz-$VERSION
initrd /initramfs-$VERSION.img
EOF
if [ -r $options ]; then
# Add user provided options from /boot/loader/void-options.conf:
printf 'options %s\n' "$(cat $options | sed '/^#/d;/^$/d')" >> $entry
fi
if grep -q ^default $loader 2>/dev/null; then
# Replace existing default entry with this entry:
sed -i "s/default.*/default $name/" $loader
else
# Add this entry as the default:
printf 'default %s\n' $name >>$loader
fi