2010-12-23 13:29:59 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# DKMS trigger. Used to add/build/install or remove the specified modules
|
|
|
|
# from all kernels.
|
|
|
|
#
|
|
|
|
# Modules can be specified like:
|
|
|
|
# dkms_modules="<modulename> <version> ..."
|
|
|
|
#
|
|
|
|
# Arguments: $ACTION = [run/targets]
|
|
|
|
# $TARGET = [post-install/pre-remove]
|
|
|
|
# $PKGNAME
|
|
|
|
# $VERSION
|
|
|
|
# $UPDATE = [yes/no]
|
|
|
|
#
|
|
|
|
ACTION="$1"
|
|
|
|
TARGET="$2"
|
|
|
|
PKGNAME="$3"
|
|
|
|
VERSION="$4"
|
|
|
|
UPDATE="$5"
|
|
|
|
|
|
|
|
DKMS=usr/sbin/dkms
|
|
|
|
|
2011-07-01 13:22:10 +00:00
|
|
|
export PATH="$PATH:/usr/local/bin"
|
|
|
|
|
2010-12-23 13:29:59 +00:00
|
|
|
remove_modules()
|
|
|
|
{
|
2011-02-19 23:28:33 +00:00
|
|
|
local _modver _kver
|
2010-12-28 10:22:58 +00:00
|
|
|
|
2010-12-23 13:29:59 +00:00
|
|
|
# Remove the specified modules from all kernels.
|
|
|
|
set -- ${dkms_modules}
|
|
|
|
while [ $# -gt 0 ]; do
|
2011-02-19 23:28:33 +00:00
|
|
|
$DKMS status -m "$1" | while read line; do
|
|
|
|
if $(echo "$line" | egrep -vq '(added|built|installed)'); then
|
2010-12-28 10:22:58 +00:00
|
|
|
shift; shift; continue
|
|
|
|
fi
|
2011-02-19 23:28:33 +00:00
|
|
|
_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
|
2010-12-23 13:29:59 +00:00
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "done."
|
|
|
|
else
|
|
|
|
echo "FAILED!"
|
|
|
|
fi
|
2010-12-28 10:22:58 +00:00
|
|
|
done
|
2010-12-23 13:29:59 +00:00
|
|
|
shift; shift;
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
add_modules()
|
|
|
|
{
|
|
|
|
# Add/build and install the specified modules for all kernels.
|
|
|
|
set -- ${dkms_modules}
|
|
|
|
while [ $# -gt 0 ]; do
|
|
|
|
$DKMS add -m "$1" -v "$2" >/dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "Added DKMS module '$1-$2'."
|
|
|
|
else
|
|
|
|
echo "Failed to add DKMS module: '$1-$2'..."
|
|
|
|
err=1
|
|
|
|
fi
|
|
|
|
shift; shift;
|
|
|
|
done
|
|
|
|
[ -n "$err" ] && exit $err
|
|
|
|
|
|
|
|
for f in $(echo lib/modules/*); do
|
|
|
|
_kver=$(basename $f)
|
2011-02-19 23:28:33 +00:00
|
|
|
if [ ! -e "${f}/build/include" ]; then
|
|
|
|
echo "Skipping kernel-${_kver}. kernel-headers package not installed..."
|
|
|
|
continue
|
|
|
|
fi
|
2010-12-23 13:29:59 +00:00
|
|
|
set -- ${dkms_modules}
|
|
|
|
while [ $# -gt 0 ]; do
|
2011-02-19 23:28:33 +00:00
|
|
|
echo -n "Installing DKMS module '$1-$2' for kernel-${_kver}... "
|
2010-12-23 13:29:59 +00:00
|
|
|
$DKMS build -m "$1" -v "$2" -k "${_kver}" >/dev/null 2>&1 && \
|
|
|
|
$DKMS install -m "$1" -v "$2" -k "${_kver}" >/dev/null 2>&1
|
|
|
|
if [ $? -eq 0 ]; then
|
|
|
|
echo "done."
|
|
|
|
else
|
|
|
|
echo "FAILED!"
|
|
|
|
echo "DKMS module '$1-$2' failed to install, please do this manually"
|
|
|
|
echo "and check for errors in the log file."
|
|
|
|
fi
|
|
|
|
shift; shift;
|
|
|
|
done
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$ACTION" in
|
|
|
|
targets)
|
|
|
|
echo "post-install pre-remove"
|
|
|
|
;;
|
|
|
|
run)
|
|
|
|
[ ! -x $DKMS -o -z "$dkms_modules" ] && exit 0
|
|
|
|
|
|
|
|
case "$TARGET" in
|
|
|
|
post-install)
|
|
|
|
add_modules
|
|
|
|
;;
|
|
|
|
pre-remove)
|
|
|
|
remove_modules
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
exit 0
|