Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 8 additions & 9 deletions srcpkgs/efibootmgr/files/efibootmgr-kernel-hook.confd
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
# Options for the kernel hook script installed by the efibootmgr package.
MODIFY_EFI_ENTRIES=0
# To allow efibootmgr to modify boot entries, set
# MODIFY_EFI_ENTRIES=1
# Kernel command-line options. Example:
# OPTIONS="root=/dev/sda3 loglevel=4"
# Disk where EFI Partition is. Default is /dev/sda
# DISK="/dev/sda"
# Partition number of EFI Partition. Default is 1
# PART=1
#
# Allow efibootmgr to update kernels and initramfs in the EFI partition.
# This will keep two kernels and initramfs, the most recently configured
# version will be vmlinuz-A.efi and initramfs-A.img while your previously
# configured kernel and initramfs will be vmlinuz-B.efi and initramfs-B.img.
# This does NOT modify efi entries, you must add one for kernel A and B with
# efibootmgr(1).
# UPDATE_KERNELS=yes
43 changes: 15 additions & 28 deletions srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,29 @@
#
# Arguments passed to this script: $1 pkgname, $2 version.
#
PKGNAME="$1"
#PKGNAME="$1"
VERSION="$2"

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

if [ ! "${UPDATE_KERNELS}" ]; then
exit 0
fi

OPTIONS="${OPTIONS} initrd=/initramfs-${VERSION}.img"
#TODO: need a way to detect where the user has there EFI Boot partition
EFI=/boot/efi

args=""
if [ "x${DISK}" != x ]; then
args="-d $DISK"
fi
if [ "x${PART}" != x ]; then
args="$args -p $PART"
# move previous kernel to vmlinuz-B.efi and initramfs-B.img
if [ -e "$EFI/vmlinuz-A.efi" ]
then
mv "$EFI/vmlinuz-A.efi" "$EFI/vmlinuz-B.efi"
fi

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

# look for previous entry for this major kernel version
existing_entry=$(efibootmgr | grep "Void Linux with kernel ${major_version}")

# get the boot order
# this is required because when in the next step the existing entry is removed,
# it is also removed from the order so it needs to be restored later
bootorder=$(efibootmgr |grep "BootOrder: " |cut -c 12-)

# if existing, remove it
if [ "$existing_entry" != "" ]; then
/etc/kernel.d/post-remove/50-efibootmgr $PKGNAME
if [ -e "$EFI/initramfs-A.img" ]
then
mv "$EFI/initramfs-A.img" "$EFI/initramfs-B.img"
fi

# create the new entry
efibootmgr -qc $args -L "Void Linux with kernel ${major_version}" -l /vmlinuz-${VERSION} -u "${OPTIONS}"

# restore the boot order
efibootmgr -qo $bootorder
# copy new kernel and initramfs to vmlinuz-A.efi and initramfs-A.img
cp -f "${ROOTDIR}/boot/vmlinuz-$VERSION" "$EFI/vmlinuz-A.efi"
cp -f "${ROOTDIR}/boot/initramfs-$VERSION.img" "$EFI/initramfs-A.img"
21 changes: 0 additions & 21 deletions srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-remove

This file was deleted.

2 changes: 1 addition & 1 deletion srcpkgs/efibootmgr/template
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Template file for 'efibootmgr'
pkgname=efibootmgr
version=18
revision=1
revision=2
hostmakedepends="pkg-config"
makedepends="libefivar-devel popt-devel"
short_desc="Tool to modify UEFI Firmware Boot Manager Variables"
Expand Down