From 131d123f630424d6dff551195b55c0f88a228896 Mon Sep 17 00:00:00 2001 From: Subhaditya Nath Date: Sun, 31 Jul 2022 23:49:34 +0530 Subject: [PATCH] xbps-triggers: dkms trigger updated and bugfixed The output format of `dkms status` has changed in v2.8.6 old - zfs, 2.1.4, 5.15.39_1, x86_64: installed new - zfs/2.1.4, 5.15.39_1, x86_64: installed So, I've re-worked the _modver and _kver detection logic. NOTE: The detection logic should ideally be identical to the detection logic in srcpkgs/dkms/files/kernel.d/dkms.prerm Also, there was a bug. If a package tried to install a dkms module that failed to build for *all* of the installed kernels, then the output of dkms status for that module would be - old - module-name, x.y.z: added new - module-name/x.y.z: added Which would cause the dkms trigger to set _kver to "added", and then the following call to `dkms remove` would set the flag `-k $_kver`, and dkms would get confused trying to find a kernel of version "added". This commit fixes that bug. --- srcpkgs/dkms/template | 2 +- srcpkgs/xbps-triggers/files/dkms | 25 +++++++++++++++---------- srcpkgs/xbps-triggers/template | 2 +- 3 files changed, 17 insertions(+), 12 deletions(-) diff --git a/srcpkgs/dkms/template b/srcpkgs/dkms/template index ac1ccecffa5..ee16e8c3aeb 100644 --- a/srcpkgs/dkms/template +++ b/srcpkgs/dkms/template @@ -3,7 +3,7 @@ pkgname=dkms version=3.0.6 revision=1 conf_files="/etc/dkms/framework.conf" -depends="bash kmod gcc make coreutils" +depends="bash kmod gcc make coreutils xbps-triggers>=0.123_1" short_desc="Dynamic Kernel Module Support" maintainer="Orphaned " license="GPL-2.0-or-later" diff --git a/srcpkgs/xbps-triggers/files/dkms b/srcpkgs/xbps-triggers/files/dkms index fcd64efd030..6b285c576b5 100755 --- a/srcpkgs/xbps-triggers/files/dkms +++ b/srcpkgs/xbps-triggers/files/dkms @@ -2,7 +2,7 @@ # # DKMS trigger. Used to add/build/install or remove the specified modules # from all kernels. -# +# # Modules can be specified like: # dkms_modules=" ..." # @@ -21,19 +21,24 @@ UPDATE="$5" export PATH="usr/bin:usr/sbin:/usr/sbin:/usr/bin:/sbin:/bin" remove_modules() { - local _modver _kver - # Remove the specified modules from all kernels. set -- ${dkms_modules} while [ $# -gt 0 ]; do - $DKMS status -m "$1" | while read line; do - if $(echo "$line" | egrep -vq '(added|built|installed)'); then - shift 2; continue + $DKMS status -m "$1" | while read -r line; do + IFS=" ,:/" read -r modname modver kver arch status _ <<-EOF + $line + EOF + if [ "${line#*: }" = added ]; then + # The module wasn't built successfully for any kernel version + printf %s "Cleaning up DKMS module '$modname-$modver'... " + $DKMS remove -m "$modname" -v "$modver" >/dev/null 2>&1 + elif [ "$status" = installed ] || [ "$status" = built ]; then + printf %s "Removing DKMS module '$modname-$modver' for kernel-$kver... " + $DKMS remove -m "$modname" -v "$modver" -k "$kver" >/dev/null 2>&1 + else + # Invalid output + continue fi - _modver=$(echo "$line"|sed "s/$1,[[:blank:]]\([^,]*\)[,:].*/\1/;t;d") - _kver=$(echo "$line"|awk '{print $3}'|sed "s/\(.*\),$/\1/") - echo -n "Removing DKMS module '${1}-${_modver}' for kernel-${_kver}... " - $DKMS remove -m "$1" -v "${_modver}" -k "${_kver}" >/dev/null 2>&1 if [ $? -eq 0 ]; then echo "done." else diff --git a/srcpkgs/xbps-triggers/template b/srcpkgs/xbps-triggers/template index b1e4f34a4dd..f0249f6f996 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.122 +version=0.123 revision=1 bootstrap=yes short_desc="XBPS triggers for Void Linux"