diff --git a/srcpkgs/efibootmgr/files/efibootmgr-kernel-hook.confd b/srcpkgs/efibootmgr/files/efibootmgr-kernel-hook.confd index 42adfc0da400ec..154f156a1a7249 100644 --- a/srcpkgs/efibootmgr/files/efibootmgr-kernel-hook.confd +++ b/srcpkgs/efibootmgr/files/efibootmgr-kernel-hook.confd @@ -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 diff --git a/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install b/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install index adf523e7b1fae3..b06482261258d2 100644 --- a/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install +++ b/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install @@ -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" diff --git a/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-remove b/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-remove deleted file mode 100644 index 54557e5cb7920c..00000000000000 --- a/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-remove +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/sh -# -# Kernel hook for efibootmgr. -# -# Arguments passed to this script: $1 pkgname, $2 version. -# -PKGNAME="$1" - -. "${ROOTDIR}/etc/default/efibootmgr-kernel-hook" -if [ "x${MODIFY_EFI_ENTRIES}" != x1 ]; then - exit 0 -fi - -# get major version, e.g. "4.8" for "linux4.8" -major_version=$(echo $PKGNAME | cut -c 6-) - -# get hex number of the matching entry -hexnum=$(efibootmgr | grep "Void Linux with kernel ${major_version}" | cut -c "5-8") - -# delete it -[ "$hexnum" ] && efibootmgr -Bq -b $hexnum diff --git a/srcpkgs/efibootmgr/template b/srcpkgs/efibootmgr/template index 676f4191d49947..6ae68eb36bfc79 100644 --- a/srcpkgs/efibootmgr/template +++ b/srcpkgs/efibootmgr/template @@ -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"