void-packages/srcpkgs/dkms/files/kernel.d/dkms.postinst
Piraty 3642efa70d dkms: fix make scripts for crosscompiled kernels in kernel.d hook
* make use of all cores
* don't prompt during `make scripts`.

It was found that when building dkms on rpi using crosscompiled kernels
(which is the default), .config misses 'GCC_PLUGINS' so `make scripts`
prompts for it during update.

The same was applied already to xbps-triggers/dkms in
6dc2654685 f609f7e76b
2020-06-14 21:56:55 +02:00

88 lines
2.2 KiB
Bash

#!/bin/sh
#
# DKMS post-install kernel hook.
#
# Arguments passed to this script: $1 pkgname, $2 version.
#
PKGNAME="$1"
VERSION="$2"
ARCH=$(uname -m)
if [ ! -x /usr/sbin/dkms ]; then
exit 0
fi
if [ ! -e /lib/modules/${VERSION}/build/include ] ; then
echo "WARNING: cannot build DKMS modules! missing kernel headers package for ${VERSION}."
exit 0
fi
export IGNORE_CC_MISMATCH=1
if [ ! -f /lib/modules/${VERSION}/build/scripts/basic/fixdep ] ; then
yes "" | make -j $(nproc) -C /lib/modules/${VERSION}/build scripts
fi
# Check available DKMS modules
for _mod_ in /var/lib/dkms/*; do
[ ! -d ${_mod_} ] && continue
module=$(basename ${_mod_})
for _modver_ in ${_mod_}/*; do
if [ -d ${_modver_} -a ! -h ${_modver_} ]; then
modulever=$(basename ${_modver_})
echo "Available DKMS module: ${module}-${modulever}."
if [ -z "${DKMS_MODULES}" ]; then
DKMS_MODULES="${module} ${modulever}"
else
DKMS_MODULES="${DKMS_MODULES} ${module} ${modulever}"
fi
fi
done
done
set -- ${DKMS_MODULES}
while [ $# -ne 0 ]; do
module="$1"
modulever="$2"
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
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
echo "done."
else
echo "FAILED!"
exit $?
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 [ $(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
echo "done."
else
echo "FAILED!"
exit $?
fi
fi
shift; shift
done
exit 0