dkms: kernel hooks support, finally.

This commit is contained in:
Juan RP 2011-07-10 10:58:30 +02:00
parent 5ad975cd03
commit 172193d6a1
3 changed files with 102 additions and 1 deletions

View File

@ -0,0 +1,75 @@
#!/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
# 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
# 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
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

View File

@ -0,0 +1,21 @@
#!/bin/bash
# We're passed the version of the kernel being installed
PKGNAME="$1"
VERSION="$2"
if [ -x /usr/sbin/dkms ]; then
while read line; do
name=`echo "$line" | awk '{print $1}' | sed 's/,$//'`
vers=`echo "$line" | awk '{print $2}' | sed 's/,$//'`
arch=`echo "$line" | awk '{print $4}' | sed 's/:$//'`
echo "dkms: removing: $name $vers (${PKGNAME}-${VERSION}) ($arch)" >&2
dkms remove -q -m $name -v $vers -k ${VERSION} -a $arch
done < <(dkms status -k ${VERSION} 2>/dev/null | grep ": installed")
fi
rmdir \
"/lib/modules/${VERSION}/updates/dkms" \
"/lib/modules/${VERSION}/updates" 2>/dev/null
exit 0

View File

@ -1,7 +1,7 @@
# Template file for 'dkms'
pkgname=dkms
version=2.2.0.0
revision=1
revision=2
homepage="http://linux.dell.com/dkms"
distfiles="${homepage}/permalink/dkms-$version.tar.gz"
build_style=custom-install
@ -31,4 +31,9 @@ do_install()
vinstall dkms_dbversion 644 var/lib/dkms
vinstall dkms.bash-completion etc/bash_completion.d dkms
vinstall dkms_framework.conf 644 etc/dkms framework.conf
# Kernel hooks.
vinstall ${FILESDIR}/kernel.d/dkms.postinst 750 \
etc/kernel.d/post-install 20-dkms
vinstall ${FILESDIR}/kernel.d/dkms.prerm 750 \
etc/kernel.d/pre-remove 20-dkms
}