From 938735b97ce548b606c5cb6b641dd9fcf7cadcb2 Mon Sep 17 00:00:00 2001 From: Daniel Florescu Date: Sat, 27 Mar 2021 10:16:45 +0100 Subject: [PATCH 1/4] 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. --- srcpkgs/efibootmgr/files/README.voidlinux | 8 ++++++-- srcpkgs/efibootmgr/files/efibootmgr-kernel-hook.confd | 2 ++ .../efibootmgr/files/kernel.d/efibootmgr.post-install | 9 +++++++-- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/srcpkgs/efibootmgr/files/README.voidlinux b/srcpkgs/efibootmgr/files/README.voidlinux index 98844fd85a65..b7904be2be64 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, @@ -17,3 +17,7 @@ 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..cbbc318aa58d 100644 --- a/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install +++ b/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install @@ -35,11 +35,16 @@ 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 + +# if using strict efi suffix, rename vmlinuz +if [ "x${USE_STRICT_EFI_SUFFIX}" = x1 -a -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} -u "${OPTIONS}" +efibootmgr -qc $args -L "Void Linux with kernel ${major_version}" -l /vmlinuz-${VERSION}.efi -u "${OPTIONS}" # restore the boot order efibootmgr -qo $bootorder From cb1dd884526c04f3b3534d8ed03e0825ed6b4c1d Mon Sep 17 00:00:00 2001 From: Daniel Florescu Date: Sat, 27 Mar 2021 12:55:26 +0100 Subject: [PATCH 2/4] efibootmgr: Remove the half broken boot order restore logic. --- srcpkgs/efibootmgr/files/README.voidlinux | 4 ---- srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install | 7 ------- 2 files changed, 11 deletions(-) diff --git a/srcpkgs/efibootmgr/files/README.voidlinux b/srcpkgs/efibootmgr/files/README.voidlinux index b7904be2be64..7dfb5c05c7ba 100644 --- a/srcpkgs/efibootmgr/files/README.voidlinux +++ b/srcpkgs/efibootmgr/files/README.voidlinux @@ -14,10 +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/kernel.d/efibootmgr.post-install b/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install index cbbc318aa58d..7653d2db9ff3 100644 --- a/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install +++ b/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install @@ -28,11 +28,6 @@ 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 @@ -46,5 +41,3 @@ fi # create the new entry efibootmgr -qc $args -L "Void Linux with kernel ${major_version}" -l /vmlinuz-${VERSION}.efi -u "${OPTIONS}" -# restore the boot order -efibootmgr -qo $bootorder From d0ad886b2506837b9d4f9f1ed1d1917d6a5ee6f3 Mon Sep 17 00:00:00 2001 From: Daniel Florescu Date: Sat, 27 Mar 2021 14:47:17 +0100 Subject: [PATCH 3/4] efibootmgr: Fix logic in efibootmgr post install script There were some quite obvious bugs and issues that I should have seen, but they are now fixed. --- .../files/kernel.d/efibootmgr.post-install | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install b/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install index 7653d2db9ff3..6739f3ba17f8 100644 --- a/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install +++ b/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install @@ -33,11 +33,20 @@ if [ "$existing_entry" != "" ]; then /etc/kernel.d/post-remove/50-efibootmgr $PKGNAME fi -# if using strict efi suffix, rename vmlinuz -if [ "x${USE_STRICT_EFI_SUFFIX}" = x1 -a -f /boot/vmlinuz-${VERSION} ]; then - mv -f /boot/vmlinuz-${VERSION} /boot/vmlinuz-${VERSION}.efi +# 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 - -# create the new entry -efibootmgr -qc $args -L "Void Linux with kernel ${major_version}" -l /vmlinuz-${VERSION}.efi -u "${OPTIONS}" - From 17c069e80a8101b514188057ea562d192f462d16 Mon Sep 17 00:00:00 2001 From: Daniel Florescu Date: Tue, 27 Apr 2021 14:26:34 +0200 Subject: [PATCH 4/4] efibootmgr: Bump revision number in template. --- srcpkgs/efibootmgr/template | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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"