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.
This commit is contained in:
Subhaditya Nath 2022-07-31 23:49:34 +05:30 committed by Andrew J. Hesford
parent efe694ed36
commit 131d123f63
3 changed files with 17 additions and 12 deletions

View File

@ -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 <orphan@voidlinux.org>"
license="GPL-2.0-or-later"

View File

@ -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="<modulename> <version> ..."
#
@ -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

View File

@ -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"