Github messages for voidlinux
 help / color / mirror / Atom feed
From: ahesford <ahesford@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: Re: [PR PATCH] [Updated] [RFC] use alternatives to manage initramfs regeneration
Date: Sun, 18 Sep 2022 20:57:41 +0200	[thread overview]
Message-ID: <20220918185741.9Diz2lq0pNJHQKCVJ6kcJH0NyCRJgt-vITXfg1SWtdg@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-39284@inbox.vuxu.org>

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

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

https://github.com/ahesford/void-packages initramfs
https://github.com/void-linux/void-packages/pull/39284

[RFC] use alternatives to manage initramfs regeneration
Yes, I know that XBPS alternatives have some problems, but this seems to be the most sensible approach on balance. Rather than dealing with a bunch of potentially competing initramfs hooks, we can let all packages install custom hooks in `/usr/libexec` and use the alternatives system to symlink the preferred hooks in `/etc/kernel.d`. At that point, we can use the generic alternative script in the XBPS regenerator trigger and avoid the need for a conf file, although it falls back to legacy behavior if the alternative isn't set.

Another option I considered, but decided against, was creating a centralized `initramfs-kernel-hooks` package that installs a common hook and reads the `/etc/default/initramfs-regenerate` file used in the existing XBPS trigger to determine what to execute. All initramfs generators (currently only dracut and mkinitcpio) would have to depend on the common package. This has the drawback that all of the generation knowledge must be centralized instead of located in the package that adds the functionality.

This is not really tested at this point, but I want to get some early comments.

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-initramfs-39284.patch --]
[-- Type: text/x-diff, Size: 6825 bytes --]

From 1b8b02a6b7cbac29f73800653842be59ea3f14e2 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 14 Sep 2022 11:30:28 -0400
Subject: [PATCH 1/3] dracut: use alternatives for kernel hooks

---
 srcpkgs/dracut/template | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/srcpkgs/dracut/template b/srcpkgs/dracut/template
index 22ffa7a82c4e..5fb0bdd9a222 100644
--- a/srcpkgs/dracut/template
+++ b/srcpkgs/dracut/template
@@ -1,7 +1,7 @@
 # Template file for 'dracut'
 pkgname=dracut
 version=053
-revision=3
+revision=4
 build_style=configure
 configure_args="--prefix=/usr --sysconfdir=/etc"
 conf_files="/etc/dracut.conf"
@@ -14,6 +14,10 @@ license="GPL-2.0-or-later, LGPL-2.0-or-later"
 homepage="http://www.kernel.org/pub/linux/utils/boot/dracut/dracut.html"
 distfiles="${KERNEL_SITE}/utils/boot/dracut/dracut-${version}.tar.xz"
 checksum=d5a1b47cdb07919d8225d5b5f538e6ae604988f3df0afbde99a8dc775277b726
+alternatives="
+ initramfs:/etc/kernel.d/post-install/20-initramfs:/usr/libexec/dracut/kernel-hook-postinst
+ initramfs:/etc/kernel.d/post-remove/20-initramfs:/usr/libexec/dracut/kernel-hook-postrm
+"
 subpackages="dracut-network"
 # Checks require distfiles come from a git repository
 make_check=no
@@ -34,8 +38,8 @@ esac
 
 post_install() {
 	# kernel hooks.
-	vinstall ${FILESDIR}/kernel-hook-postinst 755 etc/kernel.d/post-install 20-dracut
-	vinstall ${FILESDIR}/kernel-hook-postrm 755 etc/kernel.d/post-remove 20-dracut
+	vinstall ${FILESDIR}/kernel-hook-postinst 755 usr/libexec/dracut
+	vinstall ${FILESDIR}/kernel-hook-postrm 755 usr/libexec/dracut
 
 	# We don't need the systemd stuff.
 	rm -rf ${DESTDIR}/usr/lib/dracut/modules.d/*systemd*

From fa7b16e460a5f538e292d3c3017131f9947d8e12 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 14 Sep 2022 11:33:39 -0400
Subject: [PATCH 2/3] mkinitcpio: use alternatives for kernel hooks

---
 srcpkgs/mkinitcpio/files/kernel-hook-postinst |  1 -
 srcpkgs/mkinitcpio/files/kernel-hook-postrm   |  1 -
 srcpkgs/mkinitcpio/template                   | 10 +++++++---
 3 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/srcpkgs/mkinitcpio/files/kernel-hook-postinst b/srcpkgs/mkinitcpio/files/kernel-hook-postinst
index 08bf4c0c9514..e051aefea703 100644
--- a/srcpkgs/mkinitcpio/files/kernel-hook-postinst
+++ b/srcpkgs/mkinitcpio/files/kernel-hook-postinst
@@ -13,4 +13,3 @@ fi
 
 umask 0077
 usr/bin/mkinitcpio -g boot/initramfs-${VERSION}.img -k ${VERSION}
-exit $?
diff --git a/srcpkgs/mkinitcpio/files/kernel-hook-postrm b/srcpkgs/mkinitcpio/files/kernel-hook-postrm
index 028fd097b87a..2db7c51954fa 100644
--- a/srcpkgs/mkinitcpio/files/kernel-hook-postrm
+++ b/srcpkgs/mkinitcpio/files/kernel-hook-postrm
@@ -8,4 +8,3 @@ PKGNAME="$1"
 VERSION="$2"
 
 rm -f boot/initramfs-${VERSION}.img
-exit $?
diff --git a/srcpkgs/mkinitcpio/template b/srcpkgs/mkinitcpio/template
index ab00be349a27..c9a6b62f26c6 100644
--- a/srcpkgs/mkinitcpio/template
+++ b/srcpkgs/mkinitcpio/template
@@ -1,7 +1,7 @@
 # Template file for 'mkinitcpio'
 pkgname=mkinitcpio
 version=31
-revision=2
+revision=3
 build_style=gnu-makefile
 hostmakedepends="asciidoc"
 depends="busybox-static bsdtar bash"
@@ -13,6 +13,10 @@ homepage="https://git.archlinux.org/mkinitcpio.git"
 distfiles="https://sources.archlinux.org/other/${pkgname}/${pkgname}-${version}.tar.gz"
 checksum=8f2811250b852ab78375bf90e1a7430daa132e57e128b0f6eaadddd9b27bbc63
 conf_files="/etc/mkinitcpio.conf"
+alternatives="
+ initramfs:/etc/kernel.d/post-install/20-initramfs:/usr/libexec/mkinitcpio/kernel-hook-postinst
+ initramfs:/etc/kernel.d/post-remove/20-initramfs:/usr/libexec/mkinitcpio/kernel-hook-postrm
+"
 replaces="mkinitcpio-udev>=0"
 
 pre_check() {
@@ -38,8 +42,8 @@ post_install() {
 
 	ln -s /usr/bin/busybox.static $DESTDIR/usr/lib/initcpio/busybox
 
-	vinstall ${FILESDIR}/kernel-hook-postinst 755 etc/kernel.d/post-install 20-mkinitcpio
-	vinstall ${FILESDIR}/kernel-hook-postrm 755 etc/kernel.d/post-remove 20-mkinitcpio
+	vinstall ${FILESDIR}/kernel-hook-postinst 755 usr/libexec/mkinitcpio
+	vinstall ${FILESDIR}/kernel-hook-postrm 755 usr/libexec/mkinitcpio
 }
 
 mkinitcpio-lvm2_package() {

From ac742e742d2dba03a02fbee1af6eb1798f5be219 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Wed, 14 Sep 2022 11:51:09 -0400
Subject: [PATCH 3/3] xbps-triggers: use alternatives for kernel hooks

---
 .../xbps-triggers/files/initramfs-regenerate  | 45 +++++++------------
 srcpkgs/xbps-triggers/template                |  2 +-
 2 files changed, 16 insertions(+), 31 deletions(-)

diff --git a/srcpkgs/xbps-triggers/files/initramfs-regenerate b/srcpkgs/xbps-triggers/files/initramfs-regenerate
index 780c3580829f..20fd9982d74f 100755
--- a/srcpkgs/xbps-triggers/files/initramfs-regenerate
+++ b/srcpkgs/xbps-triggers/files/initramfs-regenerate
@@ -37,36 +37,21 @@ case "$ACTION" in
 		;;
 esac
 
-# Read the configuration, if it exists
-[ -f etc/default/initramfs-regenerate ] && . etc/default/initramfs-regenerate
+# Prefer the new alternatives-based initramfs hooks
+HOOK="etc/kernel.d/post-install/20-initramfs"
+if [ ! -x "${HOOK}" ]; then
+	# Otherwise, use legacy trigger behavior to find a preferred hook
+	[ -f etc/default/initramfs-regenerate ] && . etc/default/initramfs-regenerate
+	HOOK="etc/kernel.d/post-install/20-${INITRAMFS_GENERATOR:-dracut}"
+	[ -x "${HOOK}" ] || exit 0
+fi
 
-# dracut explicitly sets umask 0077, other generators may not
-umask 0077
-
-case "${INITRAMFS_GENERATOR:-dracut}" in
-	dracut)
-		if command -v dracut >/dev/null 2>&1; then
-			echo "Regenerating initramfs with dracut"
-			dracut -f -q --regenerate-all
-		fi
-		;;
-	mkinitcpio)
-		if command -v mkinitcpio >dev/null 2>&1; then
-			echo "Regenerating initramfs with mkinitcpio"
-			# Regenerate images for every kernel version with modules
-			for kdir in usr/lib/modules/*; do
-				[ -d "${kdir}/kernel" ] || continue
-				kver="${kdir##*/}"
-				mkinitcpio -g "boot/initramfs-${kver}.img" -k "${kver}"
-			done
-		fi
-		;;
-	none)
-		;;
-	*)
-		echo "unrecognized INITRAMFS_GENERATOR for initramfs-regenerate hook"
-		exit 1
-		;;
-esac
+echo "Regenerating initramfs images using kernel hook ${HOOK##*/}"
 
+# Regenerate images for every kernel version with modules
+for kdir in usr/lib/modules/*; do
+	[ -d "${kdir}/kernel" ] || continue
+	kver="${kdir##*/}"
+	"${HOOK}" "${PKGNAME}" "${kver}"
+done
 exit 0
diff --git a/srcpkgs/xbps-triggers/template b/srcpkgs/xbps-triggers/template
index f0249f6f9964..aa62e0902528 100644
--- a/srcpkgs/xbps-triggers/template
+++ b/srcpkgs/xbps-triggers/template
@@ -1,6 +1,6 @@
 # Template file for 'xbps-triggers'
 pkgname=xbps-triggers
-version=0.123
+version=0.124
 revision=1
 bootstrap=yes
 short_desc="XBPS triggers for Void Linux"

  parent reply	other threads:[~2022-09-18 18:57 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-09-14 16:00 [PR PATCH] " ahesford
2022-09-14 16:25 ` CameronNemo
2022-09-14 16:38 ` [PR REVIEW] " CameronNemo
2022-09-14 17:05 ` ahesford
2022-09-14 17:07 ` ahesford
2022-09-14 19:15 ` [PR REVIEW] " dmarto
2022-09-15  1:29 ` [PR PATCH] [Updated] " ahesford
2022-09-15  1:29 ` [PR REVIEW] " ahesford
2022-09-15 10:26 ` classabbyamp
2022-09-18 17:55 ` [PR PATCH] [Updated] " ahesford
2022-09-18 18:39 ` ahesford
2022-09-18 18:49 ` ahesford
2022-09-18 18:57 ` ahesford [this message]
2022-09-18 18:58 ` ahesford
2022-09-19  8:19 ` thypon
2022-09-19  9:23 ` classabbyamp
2022-09-19 11:04 ` ahesford
2022-09-19 20:33 ` classabbyamp
2022-09-26 12:17 ` [PR PATCH] [Merged]: " ahesford

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220918185741.9Diz2lq0pNJHQKCVJ6kcJH0NyCRJgt-vITXfg1SWtdg@z \
    --to=ahesford@users.noreply.github.com \
    --cc=ml@inbox.vuxu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).