Skip to content

Commit

Permalink
xbps-triggers: dkms trigger updated and bugfixed
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
subnut committed Jun 22, 2022
1 parent bdd941c commit cb0bc89
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 11 deletions.
25 changes: 15 additions & 10 deletions srcpkgs/xbps-triggers/files/dkms
Original file line number Diff line number Diff line change
Expand Up @@ -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> ..."
#
Expand All @@ -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 echo "$line" | grep -q ': 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
Expand Down
2 changes: 1 addition & 1 deletion srcpkgs/xbps-triggers/template
Original file line number Diff line number Diff line change
@@ -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"
Expand Down

0 comments on commit cb0bc89

Please sign in to comment.