kmod/.github/print-kdir.sh
Emil Velikov cb233f4357 scripts/print-kdir: error out on multiple kernels
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Link: https://github.com/kmod-project/kmod/pull/132
Signed-off-by: Lucas De Marchi <lucas.de.marchi@gmail.com>
2024-09-16 21:59:23 -05:00

18 lines
432 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
for moddir in /usr/lib/modules /lib/modules; do
if [[ -e "$moddir" ]]; then
kernel=$(find "$moddir" -maxdepth 1 -mindepth 1 -type d -exec basename {} \;)
break
fi
done
# There should be one entry - the kernel we installed
if (( $(echo "$kernel" | wc -l) != 1 )); then
echo >&2 "Error: exactly one kernel must be installed"
exit 1
fi
echo "KDIR=$moddir/$kernel/build"