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] Add abstract initramfs-regenerate trigger to xbps-triggers
Date: Thu, 10 Jun 2021 19:47:48 +0200
Message-ID: <20210610174748.ReUb8EEZnMtXo-3YzSMLl-1zhCCH8mpEscjIRhwsm6g@z> (raw)
In-Reply-To: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-31403@inbox.vuxu.org>

[-- Attachment #1: Type: text/plain, Size: 659 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/31403

Add abstract initramfs-regenerate trigger to xbps-triggers
This abstracts away the `dracut -f -q --regenerate-all` that appears in nvidia and zfs packages, allowing users to disable global regeneration, use dracut (by default, to preserve existing behavior) or mkinitcpio. Eventually, this can be extended with initramfs-tools if we like.

cc: @Vaelatern @abenson 

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

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

From bd22cb3c13891c80ff30ff5a0c90c2e6335f3c7c Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 10 Jun 2021 11:31:19 -0400
Subject: [PATCH 1/4] xbps-triggers: add initramfs-regenerate trigger

This abstracts away the `dracut -f -q --regenerate-all` that appears in
nvidia and zfs packages, allowing users to disable global regeneration,
use dracut (by default, to preserve existing behavior) or mkinitcpio.
Eventually, this can be extended with initramfs-tools if we like.
---
 Manual.md                                     | 30 ++++++++
 .../xbps-triggers/files/initramfs-regenerate  | 69 +++++++++++++++++++
 srcpkgs/xbps-triggers/template                |  2 +-
 3 files changed, 100 insertions(+), 1 deletion(-)
 create mode 100755 srcpkgs/xbps-triggers/files/initramfs-regenerate

diff --git a/Manual.md b/Manual.md
index f6de68a471d1..238db04f04b3 100644
--- a/Manual.md
+++ b/Manual.md
@@ -57,6 +57,7 @@ packages for XBPS, the `Void Linux` native packaging system.
 		* [gtk3-immodules](#triggers_gtk3_immodules)
 		* [hwdb.d-dir](#triggers_hwdb.d_dir)
 		* [info-files](#triggers_info_files)
+		* [initramfs-regenerate](#triggers_initramfs_regenerate)
 		* [kernel-hooks](#triggers_kernel_hooks)
 		* [mimedb](#triggers_mimedb)
 		* [mkdirs](#triggers_mkdirs)
@@ -1881,6 +1882,35 @@ registry located at `usr/share/info`.
 If it is running under another architecture it tries to use the host's `install-info`
 utility.
 
+<a id="triggers_initramfs_regenerate"></a>
+### initramfs-regenerate
+
+The initramfs-regenerate trigger will trigger the regeneration of all kernel
+initramfs images after package installation or removal. The trigger must be
+manually requested.
+
+This hook is probably most useful for DKMS packages because it will provide a
+means to include newly compiled kernel modules in initramfs images for all
+currently available kernels. When used in a DKMS package, it is recommended to
+manually include the `dkms` trigger *before* the `initramfs-regenerate` trigger
+using, for example,
+
+    ```
+    triggers="dkms initramfs-regenerate"
+    ```
+
+Although `xbps-src` will automatically include the `dkms` trigger whenever
+`dkms_modules` is installed, the automatic addition will come *after*
+`initramfs-regenerate`, which will cause initramfs images to be recreated
+before the modules are compiled.
+
+By default, the trigger uses `dracut --regenerate-all` to recreate initramfs
+images. If `/etc/defalt/initramfs-regenerate` exists and defines
+`INITRAMFS_GENERATOR=mkinitcpio`, the trigger will instead use `mkinitcpio` and
+loop over all kernel versions for which modules appear to be installed.
+Alternatively, setting `INITRAMFS_GENERATOR=none` will disable image
+regeneration entirely.
+
 <a id="triggers_kernel_hooks"></a>
 #### kernel-hooks
 
diff --git a/srcpkgs/xbps-triggers/files/initramfs-regenerate b/srcpkgs/xbps-triggers/files/initramfs-regenerate
new file mode 100755
index 000000000000..5cbc88f5ea89
--- /dev/null
+++ b/srcpkgs/xbps-triggers/files/initramfs-regenerate
@@ -0,0 +1,69 @@
+#!/bin/sh
+#
+# Trigger to regenerate an initramfs for every kernel with a module directory
+# in lib/modules on package post-install.
+#
+# To change the initramfs generator, edit or create the file
+# etc/default/initramfs-regenerate and add or change the line
+#
+#     INITRAMFS_GENERATOR=<generator>
+#
+# where <generator> is one of "dracut", "mkinitcpio" or "none". By default, a
+# value of "dracut" is assumed.
+#
+# Arguments:	$ACTION = [run/targets]
+#		$TARGET = [post-install/post-remove]
+#		$PKGNAME
+#		$VERSION
+#		$UPDATE = [yes/no]
+
+ACTION="$1"
+TARGET="$2"
+PKGNAME="$3"
+VERSION="$4"
+UPDATE="$5"
+
+export PATH="usr/bin:/usr/sbin:/usr/bin:/sbin:/bin"
+
+case "$ACTION" in
+	targets)
+		echo "post-install post-remove"
+		exit 0
+		;;
+	run)
+		;;
+	*)
+		exit 1
+		;;
+esac
+
+# Read the configuration, if it exists
+[ -f etc/default/initramfs-regenerate ] && . etc/default/initramfs-regenerate
+
+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
+
+exit 0
diff --git a/srcpkgs/xbps-triggers/template b/srcpkgs/xbps-triggers/template
index 748942206ac5..5de97d53c210 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.120
+version=0.121
 revision=1
 bootstrap=yes
 short_desc="XBPS triggers for Void Linux"

From f8a27ec6001f3b2419dcb1db4d1a9c10b82be483 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 10 Jun 2021 11:35:33 -0400
Subject: [PATCH 2/4] zfs: use new initramfs-regenerate trigger

---
 srcpkgs/zfs/INSTALL  | 13 -------------
 srcpkgs/zfs/template |  9 +++++----
 2 files changed, 5 insertions(+), 17 deletions(-)
 delete mode 100644 srcpkgs/zfs/INSTALL

diff --git a/srcpkgs/zfs/INSTALL b/srcpkgs/zfs/INSTALL
deleted file mode 100644
index 2991003856b4..000000000000
--- a/srcpkgs/zfs/INSTALL
+++ /dev/null
@@ -1,13 +0,0 @@
-case "${ACTION}" in
-post)
-	if [ -x usr/bin/dracut ]; then
-		# Include new modules in all initramfs instances when possible,
-		# as simultaneous updates of linux and zfs may trigger creation
-		# of images without modules and unable to boot from ZFS pools. 
-		#
-		# See https://github.com/void-linux/void-packages/issues/22817
-		echo "Regenerating initramfs, please wait..."
-		usr/bin/dracut -f -q --regenerate-all
-	fi
-	;;
-esac
diff --git a/srcpkgs/zfs/template b/srcpkgs/zfs/template
index a94f5a1541ce..40d6bcd78509 100644
--- a/srcpkgs/zfs/template
+++ b/srcpkgs/zfs/template
@@ -1,14 +1,14 @@
 # Template file for 'zfs'
 pkgname=zfs
 version=2.0.4
-revision=2
+revision=3
 build_style=gnu-configure
 configure_args="--with-config=user --with-mounthelperdir=/usr/bin
  --with-udevdir=/usr/lib/udev --with-udevruledir=/usr/lib/udev/rules.d
  --with-dracutdir=/usr/lib/dracut --with-tirpc"
 hostmakedepends="dracut libtool pkg-config python3 automake"
 makedepends="pam-devel zlib-devel libuuid-devel libblkid-devel libtirpc-devel attr-devel"
-depends="dkms>=2.2.0.3_9 perl python3"
+depends="dkms>=2.2.0.3_9 perl python3 xbps-triggers>=0.121_1"
 conf_files="/etc/zfs/zed.d/zed.rc"
 short_desc="Z File System -- userland, pyzfs, and kernel modules (using DKMS)"
 maintainer="Toyam Cox <Vaelatern@voidlinux.org>"
@@ -16,11 +16,12 @@ license="CDDL-1.0"
 homepage="https://openzfs.github.io/openzfs-docs/"
 distfiles="https://github.com/openzfs/zfs/releases/download/zfs-${version}/zfs-${version}.tar.gz"
 checksum=7d1344c5433b91823f02c2e40b33d181fa6faf286bea5591f4b1965f23d45f6c
+# dkms must be before initramfs-regenerate to build modules before images
+triggers="dkms initramfs-regenerate"
+dkms_modules="zfs ${version}"
 
 replaces="spl<=0.7.13_1" # Because SPL was merged into zfs in 0.8.0
 
-dkms_modules="zfs ${version}"
-
 post_patch() {
 	# When collecting a "clean" tree for DKMS, don't leave patches in place
 	local _f

From 33a89ed8999a1e17c9fcbf4c5c66008c32d86b8c Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 10 Jun 2021 11:39:32 -0400
Subject: [PATCH 3/4] nvidia: use new initramfs-regenerate trigger

---
 srcpkgs/nvidia/nvidia-dkms.INSTALL | 13 -------------
 srcpkgs/nvidia/nvidia-dkms.REMOVE  |  9 ---------
 srcpkgs/nvidia/template            |  7 +++++--
 3 files changed, 5 insertions(+), 24 deletions(-)
 delete mode 100644 srcpkgs/nvidia/nvidia-dkms.INSTALL
 delete mode 100644 srcpkgs/nvidia/nvidia-dkms.REMOVE

diff --git a/srcpkgs/nvidia/nvidia-dkms.INSTALL b/srcpkgs/nvidia/nvidia-dkms.INSTALL
deleted file mode 100644
index 943fc6e77f0d..000000000000
--- a/srcpkgs/nvidia/nvidia-dkms.INSTALL
+++ /dev/null
@@ -1,13 +0,0 @@
-case "${ACTION}" in
-post)
-	if [ "${ARCH}" = "x86_64" ]; then
-		# Regenerate initramfs.
-		echo "Regenerating initramfs, please wait..."
-		dracut -f -q --regenerate-all
-	else
-		echo "Nvidia has dropped support for 32-bit kernels.\n"
-		echo "Please consider installing the nvidia390 package as an alternative.\n"
-		echo "This package is now only useful if you're using a x86_64 kernel.\n"
-	fi
-	;;
-esac
diff --git a/srcpkgs/nvidia/nvidia-dkms.REMOVE b/srcpkgs/nvidia/nvidia-dkms.REMOVE
deleted file mode 100644
index c10a4035d6ad..000000000000
--- a/srcpkgs/nvidia/nvidia-dkms.REMOVE
+++ /dev/null
@@ -1,9 +0,0 @@
-# Regenerate initramfs.
-case ${ACTION} in
-purge)
-	if [ "${ARCH}" = "x86_64" ]; then
-		echo "Regenerating initramfs, please wait..."
-		dracut -f -q --regenerate-all
-	fi
-	;;
-esac
diff --git a/srcpkgs/nvidia/template b/srcpkgs/nvidia/template
index ccbdb8e18892..c659027b1bda 100644
--- a/srcpkgs/nvidia/template
+++ b/srcpkgs/nvidia/template
@@ -4,7 +4,7 @@ _desc="NVIDIA drivers for linux"
 
 pkgname=nvidia
 version=460.84
-revision=1
+revision=2
 maintainer="Andrew Benson <abenson+void@gmail.com>"
 license="custom:NVIDIA Proprietary"
 homepage="https://www.nvidia.com"
@@ -278,8 +278,11 @@ nvidia-libs_package() {
 
 nvidia-dkms_package() {
 	short_desc="${_desc} - DKMS kernel module"
+	depends="dkms xbps-triggers>=0.121_1"
 	dkms_modules="nvidia ${version}"
-	depends="dkms"
+	# dkms must be before initramfs-regenerate to build modules before images
+	triggers="dkms initramfs-regenerate"
+
 	pkg_install() {
 		vmove usr/src
 		vmove usr/lib/modprobe.d

From 8e166a4bc82c22e052486c52eaf035be8de1bbd7 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Thu, 10 Jun 2021 11:40:16 -0400
Subject: [PATCH 4/4] nvidia390: use new initramfs-regenerate trigger

---
 srcpkgs/nvidia390/nvidia390-dkms.INSTALL | 7 -------
 srcpkgs/nvidia390/nvidia390-dkms.REMOVE  | 7 -------
 srcpkgs/nvidia390/template               | 6 ++++--
 3 files changed, 4 insertions(+), 16 deletions(-)
 delete mode 100644 srcpkgs/nvidia390/nvidia390-dkms.INSTALL
 delete mode 100644 srcpkgs/nvidia390/nvidia390-dkms.REMOVE

diff --git a/srcpkgs/nvidia390/nvidia390-dkms.INSTALL b/srcpkgs/nvidia390/nvidia390-dkms.INSTALL
deleted file mode 100644
index 6b065bedb4a0..000000000000
--- a/srcpkgs/nvidia390/nvidia390-dkms.INSTALL
+++ /dev/null
@@ -1,7 +0,0 @@
-# Regenerate initramfs.
-case ${ACTION} in
-post)
-	echo "Regenerating initramfs, please wait..."
-	dracut -f -q --regenerate-all
-	;;
-esac
diff --git a/srcpkgs/nvidia390/nvidia390-dkms.REMOVE b/srcpkgs/nvidia390/nvidia390-dkms.REMOVE
deleted file mode 100644
index e4d494ca015d..000000000000
--- a/srcpkgs/nvidia390/nvidia390-dkms.REMOVE
+++ /dev/null
@@ -1,7 +0,0 @@
-# Regenerate initramfs.
-case ${ACTION} in
-purge)
-	echo "Regenerating initramfs, please wait..."
-	dracut -f -q --regenerate-all
-	;;
-esac
diff --git a/srcpkgs/nvidia390/template b/srcpkgs/nvidia390/template
index 04ada0841189..4c1e27020947 100644
--- a/srcpkgs/nvidia390/template
+++ b/srcpkgs/nvidia390/template
@@ -4,7 +4,7 @@ _desc="NVIDIA drivers (GeForce 400, 500 series)"
 
 pkgname=nvidia390
 version=390.143
-revision=1
+revision=2
 maintainer="Andrew Benson <abenson+void@gmail.com>"
 license="custom:NVIDIA Proprietary"
 homepage="https://www.nvidia.com"
@@ -231,8 +231,10 @@ nvidia390-libs_package() {
 }
 nvidia390-dkms_package() {
 	short_desc="${_desc} - DKMS kernel module"
+	depends="dkms xbps-triggers>=0.121_1"
 	dkms_modules="nvidia ${version}"
-	depends="dkms"
+	# dkms must be before initramfs-regenerate to build modules before images
+	triggers="dkms initramfs-regenerate"
 	pkg_install() {
 		vmove usr/src
 		vmove usr/lib/modprobe.d

  parent reply	other threads:[~2021-06-10 17:47 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-10 16:07 [PR PATCH] " ahesford
2021-06-10 16:52 ` [PR REVIEW] " ericonr
2021-06-10 16:52 ` ericonr
2021-06-10 16:52 ` ericonr
2021-06-10 16:57 ` ahesford
2021-06-10 16:58 ` ahesford
2021-06-10 17:00 ` ahesford
2021-06-10 17:01 ` ericonr
2021-06-10 17:02 ` ericonr
2021-06-10 17:34 ` [PR PATCH] [Updated] " ahesford
2021-06-10 17:36 ` [PR REVIEW] " ahesford
2021-06-10 17:36 ` ahesford
2021-06-10 17:47 ` ahesford [this message]
2021-06-11  2:14 ` [PR PATCH] [Updated] " ahesford
2021-06-15  7:03 ` Vaelatern
2021-06-15 15:21 ` [PR PATCH] [Closed]: " 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=20210610174748.ReUb8EEZnMtXo-3YzSMLl-1zhCCH8mpEscjIRhwsm6g@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

Github messages for voidlinux

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.vuxu.org/voidlinux-github

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V1 voidlinux-github voidlinux-github/ https://inbox.vuxu.org/voidlinux-github \
		voidlinux-github@inbox.vuxu.org
	public-inbox-index voidlinux-github

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.github.voidlinux


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git