[Pkg-dkms-maint] Bug#631657: GNU/kFreeBSD support

Robert Millan rmh at debian.org
Sat Jun 25 20:08:54 UTC 2011


Package: dkms
Version: 2.1.1.2-7
Severity: wishlist
Tags: patch
User: debian-bsd at lists.debian.org
Usertags: kfreebsd

This patch adds GNU/kFreeBSD support to DKMS.  It can be tested with [1],
though it also needs fixes in glibc-bsd SVN which haven't been uploaded
to the archive yet.

[1] http://people.debian.org/~rmh/fuse/fuse-dkms_0.3.9~pre1.20080208-1_all.deb

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: kfreebsd-amd64 (x86_64)

Kernel: kFreeBSD 8.2-1-amd64
Locale: LANG=ca_AD.UTF-8, LC_CTYPE=ca_AD.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages dkms depends on:
ii  build-essential               11.5       Informational list of build-essent
ii  coreutils                     8.5-1      GNU core utilities
ii  dpkg-dev                      1.16.0.3   Debian package development tools
ii  gcc                           4:4.6.0-6  GNU C compiler
ii  kldutils [module-init-tools]  8.2+ds1-1  tools for managing kFreeBSD module
ii  make                          3.81-8.1   An utility for Directing compilati
ii  patch                         2.6.1-2    Apply a diff file to an original

Versions of packages dkms recommends:
ii  fakeroot                      1.16-1     tool for simulating superuser priv
pn  linux-headers-2.6-686 | linux <none>     (no description available)
pn  linux-image                   <none>     (no description available)
ii  sudo                          1.7.4p6-1  Provide limited super user privile

dkms suggests no packages.

-- no debconf information
-------------- next part --------------
--- a/dkms
+++ b/dkms
@@ -19,6 +19,27 @@
 #    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" ;;
+       GNU/kFreeBSD)   DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;;
+    esac
+    echo $DIR
+}
+
+function _check_kernel_dir() {
+    DIR=$(_get_kernel_dir $1)
+    case ${uname_s} in
+       Linux)          test -e $DIR/build/include ;;
+       GNU/kFreeBSD)   test -e $DIR/kern && test -e $DIR/conf/kmod.mk ;;
+       *)              return 1 ;;
+    esac
+    return $?
+}
+
 function invoke_command ()
 {
     local exitval=0
@@ -98,8 +119,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" ]; then
+        kernel_source_dir="$(_get_kernel_dir "$1")"
     fi
 }
 
@@ -416,6 +437,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]) ;;
@@ -1051,7 +1077,7 @@
     set_kernel_source_dir "$1"
 
     # Check that kernel-source exists
-    if ! [ -e "$kernel_source_dir/include" ]; then
+    if ! _check_kernel_dir "$1"; 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
--- a/dkms_autoinstaller
+++ b/dkms_autoinstaller
@@ -17,6 +17,27 @@
 
 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" ;;
+       GNU/kFreeBSD)   DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;;
+    esac
+    echo $DIR
+}
+
+_check_kernel_dir() {
+    DIR=$(_get_kernel_dir $1)
+    case ${uname_s} in
+       Linux)          test -e $DIR/build/include ;;
+       GNU/kFreeBSD)   test -e $DIR/kern && test -e $DIR/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 +136,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 $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 $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
--- a/dkms_common.postinst
+++ b/dkms_common.postinst
@@ -6,6 +6,27 @@
 
 set -e
 
+uname_s=$(uname -s)
+
+_get_kernel_dir() {
+    KVER=$1
+    case ${uname_s} in
+	Linux)		DIR="/lib/modules/$KVER" ;;
+	GNU/kFreeBSD)	DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;;
+    esac
+    echo $DIR
+}
+
+_check_kernel_dir() {
+    DIR=$(_get_kernel_dir $1)
+    case ${uname_s} in
+	Linux)		test -e $DIR/build/include ;;
+	GNU/kFreeBSD)	test -e $DIR/kern && test -e $DIR/conf/kmod.mk ;;
+	*)		return 1 ;;
+    esac
+    return $?
+}
+
 # Check the existence of a kernel named as $1
 _is_kernel_name_correct() {
     CORRECT="no"
@@ -242,7 +263,7 @@
             echo " since the package source was not provided"
             continue
         fi
-        if [ -e /lib/modules/$KERNEL/build/include ]; then
+        if _check_kernel_dir $KERNEL; then
             echo "Building initial module for $KERNEL"
             set +e
             dkms build -m $NAME -v $VERSION -k $KERNEL $ARCH > /dev/null
--- a/kernel_postinst.d_dkms
+++ b/kernel_postinst.d_dkms
@@ -3,11 +3,43 @@
 # We're passed the version of the kernel being installed
 inst_kern=$1
 
+uname_s=$(uname -s)
+
+_get_kernel_dir() {
+    KVER=$1
+    case ${uname_s} in
+       Linux)          DIR="/lib/modules/$KVER" ;;
+       GNU/kFreeBSD)   DIR="/usr/src/kfreebsd-headers-$KVER/sys" ;;
+    esac
+    echo $DIR
+}
+
+_check_kernel_dir() {
+    DIR=$(_get_kernel_dir $1)
+    case ${uname_s} in
+       Linux)          test -e $DIR/build/include ;;
+       GNU/kFreeBSD)   test -e $DIR/kern && test -e $DIR/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 $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


More information about the Pkg-dkms-maint mailing list