Github messages for voidlinux
 help / color / mirror / Atom feed
From: ahesford <ahesford@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: [PR PATCH] Add abstract initramfs-regenerate trigger to xbps-triggers
Date: Thu, 10 Jun 2021 18:07:32 +0200
Message-ID: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-31403@inbox.vuxu.org> (raw)

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

There is a new 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: 9994 bytes --]

From 0eaef4bdf4041f730ba2af7cd71c936db9162cc0 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.
---
 .../xbps-triggers/files/initramfs-regenerate  | 69 +++++++++++++++++++
 srcpkgs/xbps-triggers/template                |  2 +-
 2 files changed, 70 insertions(+), 1 deletion(-)
 create mode 100755 srcpkgs/xbps-triggers/files/initramfs-regenerate

diff --git a/srcpkgs/xbps-triggers/files/initramfs-regenerate b/srcpkgs/xbps-triggers/files/initramfs-regenerate
new file mode 100755
index 000000000000..fff08db5fa39
--- /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/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"
+			# Need to manually mimic dracut's --regenerate-all
+			for kdir in lib/modules/*; do
+				[ -f "${kdir}/modules.dep" ] || [ -f "${kdir}/modules/dep.bin" ] || 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 bd66da949cb34c08b718a6b3a72c2a39b685dfc4 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 f232aebf3bd6645c6756e5ba96b9338a1ecd5c2a 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 cc16c6da96a6d426c71554268cb3344865121bd1 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

             reply	other threads:[~2021-06-10 16:07 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-10 16:07 ahesford [this message]
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 ` [PR PATCH] [Updated] " ahesford
2021-06-11  2:14 ` 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=gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-31403@inbox.vuxu.org \
    --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 http://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/ http://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