From 35578228f0cb95a5f8fe5c2b7c1bf886abb59969 Mon Sep 17 00:00:00 2001 From: Daniel Florescu Date: Sat, 27 Mar 2021 10:16:45 +0100 Subject: [PATCH] efibootmgr: Add new option to EFI hook - Add new option "USE_STRICT_EFI_SUFFIX" to post-install hook. - Update README.voidlinux to show info about the new hook. - Fix inconsistent use of spaces and tabs in post-install hook. - Bump revision number in template. --- srcpkgs/efibootmgr/files/README.voidlinux | 10 +++---- .../files/efibootmgr-kernel-hook.confd | 2 ++ .../files/kernel.d/efibootmgr.post-install | 29 ++++++++++++------- srcpkgs/efibootmgr/template | 2 +- 4 files changed, 26 insertions(+), 17 deletions(-) diff --git a/srcpkgs/efibootmgr/files/README.voidlinux b/srcpkgs/efibootmgr/files/README.voidlinux index 98844fd85a65..7dfb5c05c7ba 100644 --- a/srcpkgs/efibootmgr/files/README.voidlinux +++ b/srcpkgs/efibootmgr/files/README.voidlinux @@ -2,8 +2,8 @@ efibootmgr can automatically generate EFI boot entries to directly boot the kernel after every kernel update or installation. Enable this by editing /etc/default/efibootmgr-kernel-hook. -The EFI variables need to be accessible in order for this to work, so -add this line to your fstab and reboot or mount manually: +The EFI variables need to be accessible in order for this to work, either +boot into EFI mode or add this line to your fstab and reboot or mount: efivarfs /sys/firmware/efi/efivars efivarfs defaults 0 0 ----------------------------------------------------------------------- Kernel cmd options can be configured in /etc/default/efibootmgr-kernel-hook, @@ -14,6 +14,6 @@ but you always have to reconfigure the kernel: This is also required after the first installation of this package. ----------------------------------------------------------------------- -The bootorder itself is not changed, so your previous boot loader will -stay enabled until you can edit the order in your firmware interface or -using "efibootmgr -o " +Some EFI implementations require the stub to end with a .efi suffix. If +your implementation requires this, edit /etc/default/efibootmgr-kernel-hook +and enable "USE_STRICT_EFI_SUFFIX=1". diff --git a/srcpkgs/efibootmgr/files/efibootmgr-kernel-hook.confd b/srcpkgs/efibootmgr/files/efibootmgr-kernel-hook.confd index 42adfc0da400..a6acde6a0d23 100644 --- a/srcpkgs/efibootmgr/files/efibootmgr-kernel-hook.confd +++ b/srcpkgs/efibootmgr/files/efibootmgr-kernel-hook.confd @@ -2,6 +2,8 @@ MODIFY_EFI_ENTRIES=0 # To allow efibootmgr to modify boot entries, set # MODIFY_EFI_ENTRIES=1 +# Use strict EFI file name spec. Default is 0 +# USE_STRICT_EFI_SUFFIX=0 # Kernel command-line options. Example: # OPTIONS="root=/dev/sda3 loglevel=4" # Disk where EFI Partition is. Default is /dev/sda diff --git a/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install b/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install index adf523e7b1fa..6739f3ba17f8 100644 --- a/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install +++ b/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install @@ -28,18 +28,25 @@ 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 + /etc/kernel.d/post-remove/50-efibootmgr $PKGNAME 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 +# if using strict efi suffix +if [ "x${USE_STRICT_EFI_SUFFIX}" = x1 ]; then + # rename vmlinuz + if [ -f /boot/vmlinuz-${VERSION} ]; then + mv -f /boot/vmlinuz-${VERSION} /boot/vmlinuz-${VERSION}.efi + fi + # create the new entry + efibootmgr -qc $args -L "Void Linux with kernel ${major_version}" -l /vmlinuz-${VERSION}.efi -u "${OPTIONS}" +else + # remove efi + if [ -f /boot/vmlinuz-${VERSION}.efi ]; then + # vmlinuz is not generated on every reconfigure + mv -f /boot/vmlinuz-${VERSION}.efi /boot/vmlinuz-${VERSION} + fi + # create the new entry + efibootmgr -qc $args -L "Void Linux with kernel ${major_version}" -l /vmlinuz-${VERSION} -u "${OPTIONS}" +fi diff --git a/srcpkgs/efibootmgr/template b/srcpkgs/efibootmgr/template index bd2e88bbbeac..deeb8dffc583 100644 --- a/srcpkgs/efibootmgr/template +++ b/srcpkgs/efibootmgr/template @@ -1,7 +1,7 @@ # Template file for 'efibootmgr' pkgname=efibootmgr version=17 -revision=6 +revision=7 hostmakedepends="pkg-config" makedepends="libefivar-devel popt-devel" short_desc="Tool to modify UEFI Firmware Boot Manager Variables"