Github messages for voidlinux
 help / color / mirror / Atom feed
From: ahesford <ahesford@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: [PR PATCH] dkms: run depmod if necessary in kernel post-install hook
Date: Sat, 04 Jul 2020 22:51:52 +0200	[thread overview]
Message-ID: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-23392@inbox.vuxu.org> (raw)

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

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

https://github.com/ahesford/void-packages dkms
https://github.com/void-linux/void-packages/pull/23392

dkms: run depmod if necessary in kernel post-install hook
Normally, `dkms install` will run depmod with each installed module to update module dependency lists. When force-reinstalling kernel packages, `dkms install` will not run because modules are already marked installed, but the kernel package will overwrite `modules.dep` and `modules.dep.bin` with packaged versions that do not include any modules installed by dkms. The kernel post-install hook now tracks whether depmod should be run and will do so if necessary.

To demonstrate the original problem:

1. Install `zfs` and enable the dracut zfs module with `add_dracutmodules+=" zfs "` in `dracut.conf` or a `.conf` file in `/etc/dracut.conf.d`.
2. Rerun `dracut`, e.g., with `xbps-reconfigure -f linuxX.Y` for an appropriate kernel package.
3. Confirm that `zfs.ko.gz` is in the newly generated initramfs.
4. Force-reinstall the kernel package: `xbps-install -f linuxX.Y`.
5. Confirm that `zfs.ko.gz` is *missing* from the newly generated initramfs.

With the changes in the hook, the force-installation of `linuxX.Y should display `Generating kernel module dependency lists... done.` after "building" all DKMS modules (note: the modules were already built for the reinstalled kernel, so the `dkms build` run by the hook is basically a no-op). The resulting initramfs will contain `zfs.ko.gz` as expected.

Also, I propagated some return codes from `dkms` through the hook, which I believe was the original intention. (Before the fix, `exit $?` after an `echo` would generally always exit 0 because `echo` is unlikely to fail.)

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

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

From ffb8b4fb170686dc5027498e48c21fe9ac57a769 Mon Sep 17 00:00:00 2001
From: "Andrew J. Hesford" <ajh@sideband.org>
Date: Sat, 4 Jul 2020 16:33:31 -0400
Subject: [PATCH] dkms: run depmod if necessary in kernel post-install hook

Normally, `dkms install` will run depmod with each installed module to
update module dependency lists. When force-reinstalling kernel packages,
`dkms install` will not run because modules are already marked
installed, but the kernel package will overwrite `modules.dep` and
`modules.dep.bin` with packaged versions that do not include any modules
installed by dkms. The kernel post-install hook now tracks whether
depmod should be run and will do so if necessary.
---
 srcpkgs/dkms/files/kernel.d/dkms.postinst | 24 ++++++++++++++++++++---
 srcpkgs/dkms/template                     |  2 +-
 2 files changed, 22 insertions(+), 4 deletions(-)

diff --git a/srcpkgs/dkms/files/kernel.d/dkms.postinst b/srcpkgs/dkms/files/kernel.d/dkms.postinst
index bfeaf34fccf..1d05ec88e08 100644
--- a/srcpkgs/dkms/files/kernel.d/dkms.postinst
+++ b/srcpkgs/dkms/files/kernel.d/dkms.postinst
@@ -45,6 +45,9 @@ while [ $# -ne 0 ]; do
 	module="$1"
 	modulever="$2"
 
+	# If adding a module, depmod is necessary unless dkms runs it
+	do_depmod="yes"
+
 	status=$(dkms status -m ${module} -v ${modulever} -k ${VERSION})
 	if [ $(echo "$status"|grep -c ": built") -eq 0 ]; then
 		# Check if the module is still there.
@@ -65,7 +68,7 @@ while [ $# -ne 0 ]; do
 			echo "done."
 		else
 			echo "FAILED!"
-			exit $?
+			exit $rval
 		fi
 		status=$(dkms status -m ${module} -v ${modulever} -k ${VERSION})
 	fi
@@ -75,14 +78,29 @@ while [ $# -ne 0 ]; do
 	   [ $(echo "$status"|grep -c ": installed") -eq 0 ]; then
 		echo -n "Installing DKMS module: ${module}-${modulever}... "
 	        dkms install -q -m ${module} -v ${modulever} -k ${VERSION} -a ${ARCH}
-		if [ $? -eq 0 ]; then
+		rval=$?
+		if [ $rval -eq 0 ]; then
 			echo "done."
+			# dkms runs depmod as part of the installation
+			unset do_depmod
 		else
 			echo "FAILED!"
-			exit $?
+			exit $rval
 		fi
 	fi
 	shift; shift
 done
 
+if [ -n "$do_depmod" ]; then
+	echo -n "Generating kernel module dependency lists... "
+	depmod -a ${VERSION}
+	rval=$?
+	if [ $rval -eq 0 ]; then
+		echo "done."
+	else
+		echo "FAILED!"
+		exit $rval
+	fi
+fi
+
 exit 0
diff --git a/srcpkgs/dkms/template b/srcpkgs/dkms/template
index 521dfde1114..32345b9b421 100644
--- a/srcpkgs/dkms/template
+++ b/srcpkgs/dkms/template
@@ -2,7 +2,7 @@
 pkgname=dkms
 reverts="2.8.2_1"
 version=2.8.1
-revision=3
+revision=4
 conf_files="/etc/dkms/framework.conf"
 depends="bash kmod gcc make coreutils linux-headers"
 short_desc="Dynamic Kernel Modules System"

             reply	other threads:[~2020-07-04 20:51 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-04 20:51 ahesford [this message]
2020-07-05  1:19 ` [PR PATCH] [Updated] " ahesford
2020-07-05  1:20 ` ahesford
2020-07-11  1:34 ` [PR PATCH] [Updated] dkms: improvements to post-install hook: run depmod if necessary and better handle DKMS build/install failures ahesford
2020-07-11  1:44 ` [PR REVIEW] " ericonr
2020-07-11  1:50 ` [PR PATCH] [Updated] " ahesford
2020-07-11  2:00 ` ahesford
2020-07-11  2:01 ` [PR REVIEW] " ahesford
2020-07-11  2:18 ` [PR PATCH] [Updated] " ahesford
2020-07-11  2:21 ` [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=gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-23392@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
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).