Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] efibootmgr: have efibootmgr scripts behave more like grub with kernel…
@ 2024-11-11 20:25 ddmgh
  2024-11-21  0:12 ` [PR PATCH] [Updated] " ddmgh
  0 siblings, 1 reply; 2+ messages in thread
From: ddmgh @ 2024-11-11 20:25 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1391 bytes --]

There is a new pull request by ddmgh against master on the void-packages repository

https://github.com/ddmgh/void-packages efibootmgr-with-minor
https://github.com/void-linux/void-packages/pull/53001

efibootmgr: have efibootmgr scripts behave more like grub with kernel…
… minor version entries, and allow vkpurge to function properly here

#### Testing the changes
- I tested the changes in this PR: **YES**

#### Local build testing
- I built this PR locally for my native architecture, (x86_64-glibc)

efibootmgr.post-install only creates one boot entry for the latest kernel minor version of a major version; it removes the current boot entry and replaces it with the kernel that's been installed.  Additionally, efibootmgr.post-remove does nothing when called by vkpurge due to the "pkgname" that's passed to it.

This patch makes these scripts behave a little more like the related grub process in that you can easily boot from a previous kernel, as it simply adds a boot entry every time a kernel is installed.  In relation to this, efibootmgr.post-remove is also altered to allow vkpurge to do what one would expect, which is actually remove the related boot entry from EFI.

Please know this is my first commit on GitHub, so it's very possible something here is incorrect.

A patch file from https://github.com/void-linux/void-packages/pull/53001.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-efibootmgr-with-minor-53001.patch --]
[-- Type: text/x-diff, Size: 3393 bytes --]

From 36d936aa0a97f9b63cee1609654a7e32a2ebd236 Mon Sep 17 00:00:00 2001
From: ddmgh <26882569+ddmgh@users.noreply.github.com>
Date: Mon, 11 Nov 2024 13:03:45 -0700
Subject: [PATCH] efibootmgr: have efibootmgr scripts behave more like grub
 with kernel minor version entries, and allow vkpurge to function properly
 here

---
 .../files/kernel.d/efibootmgr.post-install    | 25 +++----------------
 .../files/kernel.d/efibootmgr.post-remove     |  8 +++---
 srcpkgs/efibootmgr/template                   |  2 +-
 3 files changed, 7 insertions(+), 28 deletions(-)

diff --git a/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install b/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install
index adf523e7b1fae3..00698b5016b8e8 100644
--- a/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install
+++ b/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install
@@ -4,7 +4,7 @@
 #
 # Arguments passed to this script: $1 pkgname, $2 version.
 #
-PKGNAME="$1"
+# PKGNAME="$1"
 VERSION="$2"
 
 . "${ROOTDIR}/etc/default/efibootmgr-kernel-hook"
@@ -22,24 +22,5 @@ if [ "x${PART}" != x ]; then
 	args="$args -p $PART"
 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
-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
+# create new entry (new bootnum will be added to the start of bootorder)
+efibootmgr -qc $args -L "Void Linux with kernel ${VERSION}" -l /vmlinuz-${VERSION} -u "${OPTIONS}"
diff --git a/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-remove b/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-remove
index 54557e5cb7920c..1da7c9b7aba2ed 100644
--- a/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-remove
+++ b/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-remove
@@ -4,18 +4,16 @@
 #
 # 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
 	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")
+hexnum=$(efibootmgr | grep "Void Linux with kernel ${VERSION}" | cut -c "5-8")
 
 # delete it
 [ "$hexnum" ] && efibootmgr -Bq -b $hexnum
diff --git a/srcpkgs/efibootmgr/template b/srcpkgs/efibootmgr/template
index 2f636914a56695..8db1f68fd3f633 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"

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PR PATCH] [Updated] efibootmgr: have efibootmgr scripts behave more like grub with kernel…
  2024-11-11 20:25 [PR PATCH] efibootmgr: have efibootmgr scripts behave more like grub with kernel… ddmgh
@ 2024-11-21  0:12 ` ddmgh
  0 siblings, 0 replies; 2+ messages in thread
From: ddmgh @ 2024-11-21  0:12 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1396 bytes --]

There is an updated pull request by ddmgh against master on the void-packages repository

https://github.com/ddmgh/void-packages efibootmgr-with-minor
https://github.com/void-linux/void-packages/pull/53001

efibootmgr: have efibootmgr scripts behave more like grub with kernel…
… minor version entries, and allow vkpurge to function properly here

#### Testing the changes
- I tested the changes in this PR: **YES**

#### Local build testing
- I built this PR locally for my native architecture, (x86_64-glibc)

efibootmgr.post-install only creates one boot entry for the latest kernel minor version of a major version; it removes the current boot entry and replaces it with the kernel that's been installed.  Additionally, efibootmgr.post-remove does nothing when called by vkpurge due to the "pkgname" that's passed to it.

This patch makes these scripts behave a little more like the related grub process in that you can easily boot from a previous kernel, as it simply adds a boot entry every time a kernel is installed.  In relation to this, efibootmgr.post-remove is also altered to allow vkpurge to do what one would expect, which is actually remove the related boot entry from EFI.

Please know this is my first commit on GitHub, so it's very possible something here is incorrect.

A patch file from https://github.com/void-linux/void-packages/pull/53001.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-efibootmgr-with-minor-53001.patch --]
[-- Type: text/x-diff, Size: 4047 bytes --]

From 918a329fbe8d38593584799c7e611bd76a69c91e Mon Sep 17 00:00:00 2001
From: ddmgh <26882569+ddmgh@users.noreply.github.com>
Date: Mon, 11 Nov 2024 13:03:45 -0700
Subject: [PATCH] efibootmgr: use kernel minor in entries and allow vkpurge to
 function properly

---
 srcpkgs/efibootmgr/files/README.voidlinux     |  4 ---
 .../files/kernel.d/efibootmgr.post-install    | 25 +++----------------
 .../files/kernel.d/efibootmgr.post-remove     |  8 +++---
 srcpkgs/efibootmgr/template                   |  2 +-
 4 files changed, 7 insertions(+), 32 deletions(-)

diff --git a/srcpkgs/efibootmgr/files/README.voidlinux b/srcpkgs/efibootmgr/files/README.voidlinux
index 98844fd85a6580..d98ed98e0b95d3 100644
--- a/srcpkgs/efibootmgr/files/README.voidlinux
+++ b/srcpkgs/efibootmgr/files/README.voidlinux
@@ -13,7 +13,3 @@ but you always have to reconfigure the kernel:
 	(or any other kernel version)
 
 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 <hexnum>"
diff --git a/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install b/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install
index adf523e7b1fae3..00698b5016b8e8 100644
--- a/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install
+++ b/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-install
@@ -4,7 +4,7 @@
 #
 # Arguments passed to this script: $1 pkgname, $2 version.
 #
-PKGNAME="$1"
+# PKGNAME="$1"
 VERSION="$2"
 
 . "${ROOTDIR}/etc/default/efibootmgr-kernel-hook"
@@ -22,24 +22,5 @@ if [ "x${PART}" != x ]; then
 	args="$args -p $PART"
 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
-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
+# create new entry (new bootnum will be added to the start of bootorder)
+efibootmgr -qc $args -L "Void Linux with kernel ${VERSION}" -l /vmlinuz-${VERSION} -u "${OPTIONS}"
diff --git a/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-remove b/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-remove
index 54557e5cb7920c..1da7c9b7aba2ed 100644
--- a/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-remove
+++ b/srcpkgs/efibootmgr/files/kernel.d/efibootmgr.post-remove
@@ -4,18 +4,16 @@
 #
 # 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
 	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")
+hexnum=$(efibootmgr | grep "Void Linux with kernel ${VERSION}" | cut -c "5-8")
 
 # delete it
 [ "$hexnum" ] && efibootmgr -Bq -b $hexnum
diff --git a/srcpkgs/efibootmgr/template b/srcpkgs/efibootmgr/template
index 2f636914a56695..8db1f68fd3f633 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"

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-11-21  0:12 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-11-11 20:25 [PR PATCH] efibootmgr: have efibootmgr scripts behave more like grub with kernel… ddmgh
2024-11-21  0:12 ` [PR PATCH] [Updated] " ddmgh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).