From b6494bf7fd815f7e640028afa973109c22744b31 Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Sat, 4 Jul 2020 16:33:31 -0400 Subject: [PATCH 1/2] dkms: improvements to kernel post-install hook When force-reinstalling kernel packages, `dkms install` is not run in the kernel post-install hook because the modules are already installed. This prevents `dkms install` from running `depmod -a` as it normally does, but the forced reinstallation clobbers `modules.dep{,.bin}` with the packaged versions that do not include DKMS-installed modules. The post-install hook now tracks whether `depmod -a` should be run and does so when necessary. Other changes, courtesy of @ericonr, address issue #23124 wherein a DKMS failure will terminate the script, preventing building or installation of subsequent modules. The fix follows logic similar to that in the DKMS xbps-trigger. --- srcpkgs/dkms/files/kernel.d/dkms.postinst | 55 +++++++++++++++++------ srcpkgs/dkms/template | 2 +- 2 files changed, 43 insertions(+), 14 deletions(-) diff --git a/srcpkgs/dkms/files/kernel.d/dkms.postinst b/srcpkgs/dkms/files/kernel.d/dkms.postinst index bfeaf34fccf..c8a8deae0d4 100644 --- a/srcpkgs/dkms/files/kernel.d/dkms.postinst +++ b/srcpkgs/dkms/files/kernel.d/dkms.postinst @@ -40,49 +40,78 @@ for _mod_ in /var/lib/dkms/*; do done done +# This sections builds and install the available modules. +# +# If either building or installing a module fails, a warning is +# printed and it is skipped, but the script still tries to build +# the other modules. +# +# The list of available modules is in the form +# [module1, modulever1, module2, modulever2, ...] +# set -- ${DKMS_MODULES} 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. if [ ! -f usr/src/${module}-${modulever}/dkms.conf ]; then echo "Skipping unexistent DKMS module: ${module}-${modulever}." - shift 2 - continue + shift 2; continue fi # Build the module echo -n "Building DKMS module: ${module}-${modulever}... " dkms build -q -m ${module} -v ${modulever} -k ${VERSION} -a ${ARCH} rval=$? - if [ $rval -eq 9 ]; then - echo "skipped!" - shift; shift - continue - elif [ $rval -eq 0 ]; then + # If the module was skipped or failed, go to the next module. + if [ $rval -eq 0 ]; then echo "done." + elif [ $rval -eq 9 ]; then + echo "skipped!" + shift 2; continue else echo "FAILED!" - exit $? + shift 2; continue fi status=$(dkms status -m ${module} -v ${modulever} -k ${VERSION}) fi - #if the module is built (either pre-built or just now), install it + # If the module is built (either pre-built or just now), install it if [ $(echo "$status"|grep -c ": built") -eq 1 ] && [ $(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 + dkms install -q -m ${module} -v ${modulever} -k ${VERSION} -a ${ARCH} + rval=$? + # If the module failed installation, go to the next module. + if [ $rval -eq 0 ]; then + # dkms runs depmod as part of the installation + unset do_depmod echo "done." else echo "FAILED!" - exit $? + shift 2; continue fi fi - shift; shift + + # Go to the next module - all steps for this module were successful. + shift 2 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" From 5ab81caca0916759e941d8f3c5ca5d7259aaed71 Mon Sep 17 00:00:00 2001 From: "Andrew J. Hesford" Date: Fri, 10 Jul 2020 21:34:34 -0400 Subject: [PATCH 2/2] Rework dkms post-install provided by ericonr --- srcpkgs/dkms/files/kernel.d/dkms.postinst | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/srcpkgs/dkms/files/kernel.d/dkms.postinst b/srcpkgs/dkms/files/kernel.d/dkms.postinst index c8a8deae0d4..c5c28b59b27 100644 --- a/srcpkgs/dkms/files/kernel.d/dkms.postinst +++ b/srcpkgs/dkms/files/kernel.d/dkms.postinst @@ -50,9 +50,11 @@ done # [module1, modulever1, module2, modulever2, ...] # set -- ${DKMS_MODULES} -while [ $# -ne 0 ]; do +while [ $# -gt 1 ]; do module="$1" - modulever="$2" + shift + modulever="$1" + shift # If adding a module, depmod is necessary unless dkms runs it do_depmod="yes" @@ -62,7 +64,7 @@ while [ $# -ne 0 ]; do # Check if the module is still there. if [ ! -f usr/src/${module}-${modulever}/dkms.conf ]; then echo "Skipping unexistent DKMS module: ${module}-${modulever}." - shift 2; continue + continue fi # Build the module echo -n "Building DKMS module: ${module}-${modulever}... " @@ -73,10 +75,10 @@ while [ $# -ne 0 ]; do echo "done." elif [ $rval -eq 9 ]; then echo "skipped!" - shift 2; continue + continue else echo "FAILED!" - shift 2; continue + continue fi status=$(dkms status -m ${module} -v ${modulever} -k ${VERSION}) fi @@ -94,12 +96,9 @@ while [ $# -ne 0 ]; do echo "done." else echo "FAILED!" - shift 2; continue + continue fi fi - - # Go to the next module - all steps for this module were successful. - shift 2 done if [ -n "$do_depmod" ]; then