Hi,
Here's a new patch. I made a few small adjustments to make it less intrusive.
Btw, it'd be very nice to have this for fuse4bsd (RFP #631657), which
is intended to be DKMS-based. Do you plan an upload of DKMS soon?
--
Robert Millan
=== modified file 'dkms'
--- dkms 2011-07-09 21:42:05 +0000
+++ dkms 2011-07-09 22:00:57 +0000
@@ -19,6 +19,26 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
+uname_s=$(uname -s)
+
+function _get_kernel_dir() {
+ KVER=$1
+ case ${uname_s} in
+ Linux) DIR="/lib/modules/$KVER/build" ;;
+ GNU/kFreeBSD) DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;;
+ esac
+ echo $DIR
+}
+
+function _check_kernel_dir() {
+ case ${uname_s} in
+ Linux) test -e $1/include ;;
+ GNU/kFreeBSD) test -e $1/kern && test -e $1/conf/kmod.mk ;;
+ *) return 1 ;;
+ esac
+ return $?
+}
+
function invoke_command ()
{
local exitval=0
@@ -98,8 +118,8 @@
function set_kernel_source_dir ()
{
# $1 = the kernel to base the directory on
- if [ -z "$kernel_source_dir" ] && [ -d "$install_tree/$1/build" ]; then
- kernel_source_dir="$install_tree/$1/build"
+ if [ -z "$kernel_source_dir" ] && [ -d "$(_get_kernel_dir "$1")" ]; then
+ kernel_source_dir="$(_get_kernel_dir "$1")"
fi
}
@@ -196,7 +216,9 @@
function do_depmod()
{
# $1 = kernel version
- /sbin/depmod -au "$1" -F "/boot/System.map-$1"
+ if [ "${uname_s}" = "Linux" ] ; then
+ /sbin/depmod -au "$1" -F "/boot/System.map-$1"
+ fi
}
function remake_initrd()
@@ -412,6 +434,11 @@
local orig_location="$1"
[ -n "${addon_modules_dir}" ] && echo "/${addon_modules_dir}" && return
+ if [ "${uname_s}" = "GNU/kFreeBSD" ] ; then
+ # Does not support subdirs, regardless of distribution
+ echo "" && return
+ fi
+
case "$running_distribution" in
fc[12345]) ;;
el[1234]) ;;
@@ -1047,7 +1074,7 @@
set_kernel_source_dir "$1"
# Check that kernel-source exists
- if ! [ -e "$kernel_source_dir/include" ]; then
+ if ! _check_kernel_dir "$kernel_source_dir"; then
echo $"" >&2
echo $"Error! Your kernel headers for kernel $1 cannot be found at" >&2
echo $"/lib/modules/$1/build or /lib/modules/$1/source." >&2
=== modified file 'dkms_autoinstaller'
--- dkms_autoinstaller 2011-07-09 21:42:05 +0000
+++ dkms_autoinstaller 2011-07-09 21:56:58 +0000
@@ -17,6 +17,26 @@
test -f /usr/sbin/dkms || exit 0
+uname_s=$(uname -s)
+
+_get_kernel_dir() {
+ KVER=$1
+ case ${uname_s} in
+ Linux) DIR="/lib/modules/$KVER/build" ;;
+ GNU/kFreeBSD) DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;;
+ esac
+ echo $DIR
+}
+
+_check_kernel_dir() {
+ case ${uname_s} in
+ Linux) test -e $1/include ;;
+ GNU/kFreeBSD) test -e $1/kern && test -e $1/conf/kmod.mk ;;
+ *) return 1 ;;
+ esac
+ return $?
+}
+
#We only have these functions on debian/ubuntu
# so on other distros just stub them out
if [ -f /lib/lsb/init-functions ]; then
@@ -115,11 +135,11 @@
log_action_end_msg 1
else
logger -t dkms_autoinstaller "$module_in_tree ($version_in_tree): Installing module on kernel $kernel."
- if [ "$current_state" != "built" ] && ! [ -e /lib/modules/$kernel/build/include ]; then
+ if [ "$current_state" != "built" ] && ! _check_kernel_dir "$(_get_kernel_dir "$kernel")"; then
logger -t dkms_autoinstaller " Kernel headers for $kernel are not installed. Cannot install this module."
logger -t dkms_autoinstaller " Try installing linux-headers-$kernel or equivalent."
log_action_end_msg 1
- elif [ "$current_state" != "built" ] && [ -e /lib/modules/$kernel/build/include ]; then
+ elif [ "$current_state" != "built" ] && _check_kernel_dir "$(_get_kernel_dir "$kernel")"; then
return_status=""
if [ -z "$kernel_preparation_done" ]; then
invoke_command "dkms build -m $module_in_tree -v $version_in_tree -k $kernel -a $arch -q --no-clean-kernel" "." background
=== modified file 'dkms_common.postinst'
--- dkms_common.postinst 2011-07-09 21:42:05 +0000
+++ dkms_common.postinst 2011-07-09 21:57:49 +0000
@@ -6,6 +6,26 @@
set -e
+uname_s=$(uname -s)
+
+_get_kernel_dir() {
+ KVER=$1
+ case ${uname_s} in
+ Linux) DIR="/lib/modules/$KVER/build" ;;
+ GNU/kFreeBSD) DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;;
+ esac
+ echo $DIR
+}
+
+_check_kernel_dir() {
+ case ${uname_s} in
+ Linux) test -e $1/include ;;
+ GNU/kFreeBSD) test -e $1/kern && test -e $1/conf/kmod.mk ;;
+ *) return 1 ;;
+ esac
+ return $?
+}
+
# Check the existence of a kernel named as $1
_is_kernel_name_correct() {
CORRECT="no"
@@ -242,7 +262,7 @@
echo " since the package source was not provided"
continue
fi
- if [ -e /lib/modules/$KERNEL/build/include ]; then
+ if _check_kernel_dir "$(_get_kernel_dir "$KERNEL")"; then
echo "Building initial module for $KERNEL"
set +e
dkms build -m $NAME -v $VERSION -k $KERNEL $ARCH > /dev/null
=== modified file 'kernel_postinst.d_dkms'
--- kernel_postinst.d_dkms 2011-07-09 21:42:05 +0000
+++ kernel_postinst.d_dkms 2011-07-09 21:59:41 +0000
@@ -3,11 +3,42 @@
# We're passed the version of the kernel being installed
inst_kern=$1
+uname_s=$(uname -s)
+
+function _get_kernel_dir() {
+ KVER=$1
+ case ${uname_s} in
+ Linux) DIR="/lib/modules/$KVER/build" ;;
+ GNU/kFreeBSD) DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;;
+ esac
+ echo $DIR
+}
+
+function _check_kernel_dir() {
+ case ${uname_s} in
+ Linux) test -e $1/include ;;
+ GNU/kFreeBSD) test -e $1/kern && test -e $1/conf/kmod.mk ;;
+ *) return 1 ;;
+ esac
+ return $?
+}
+
+case "${uname_s}" in
+ Linux)
+ header_pkg="linux-headers-$inst_kern"
+ kernel="Linux"
+ ;;
+ GNU/kFreeBSD)
+ header_pkg="kfreebsd-headers-$inst_kern"
+ kernel="kFreeBSD"
+ ;;
+esac
+
if [ -x /usr/lib/dkms/dkms_autoinstaller ]; then
/usr/lib/dkms/dkms_autoinstaller start $inst_kern >&2
fi
-if [ ! -e /lib/modules/$inst_kern/build/include ] ; then
- echo "dkms: WARNING: linux headers are missing, which may explain the above failures." >&2
- echo " please install the linux-headers-$inst_kern package to fix this." >&2
+if ! _check_kernel_dir "$(_get_kernel_dir "$inst_kern")" ; then
+ echo "dkms: WARNING: $kernel headers are missing, which may explain the above failures." >&2
+ echo " please install the $header_pkg package to fix this." >&2
fi