diff options
| author | Michael Meskes <meskes@debian.org> | 2009-02-09 17:42:08 +0100 |
|---|---|---|
| committer | Michael Meskes <meskes@debian.org> | 2009-02-09 17:42:08 +0100 |
| commit | 5b633c860b9ccb98910812f91c2474fda316b50b (patch) | |
| tree | db6656e828509048e53ad8aea69d2edb9f64f442 /src/VBox/HostDrivers/linux | |
| parent | ce414e6eec1583def0dc7be0926f1a07364cb5e3 (diff) | |
| download | virtualbox-5b633c860b9ccb98910812f91c2474fda316b50b.tar.gz | |
Imported 2.1.2-dfsgupstream/2.1.2-dfsg
Diffstat (limited to 'src/VBox/HostDrivers/linux')
| -rw-r--r-- | src/VBox/HostDrivers/linux/Makefile | 64 | ||||
| -rw-r--r-- | src/VBox/HostDrivers/linux/Makefile.kup | 0 | ||||
| -rwxr-xr-x | src/VBox/HostDrivers/linux/build_in_tmp | 112 | ||||
| -rwxr-xr-x | src/VBox/HostDrivers/linux/export_modules | 103 |
4 files changed, 279 insertions, 0 deletions
diff --git a/src/VBox/HostDrivers/linux/Makefile b/src/VBox/HostDrivers/linux/Makefile new file mode 100644 index 000000000..ea79be321 --- /dev/null +++ b/src/VBox/HostDrivers/linux/Makefile @@ -0,0 +1,64 @@ +# +# Makefile for the VirtualBox Linux Host Drivers. +# + +# +# +# Copyright (C) 2008-2009 Sun Microsystems, Inc. +# +# This file is part of VirtualBox Open Source Edition (OSE), as +# available from http://www.virtualbox.org. This file is free software; +# you can redistribute it and/or modify it under the terms of the GNU +# General Public License (GPL) as published by the Free Software +# Foundation, in version 2 as it comes in the "COPYING" file of the +# VirtualBox OSE distribution. VirtualBox OSE is distributed in the +# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. +# +# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa +# Clara, CA 95054 USA or visit http://www.sun.com if you need +# additional information or have any questions. +# + +KBUILD_VERBOSE = + +all: + @echo "*** Building 'vboxdrv' module ***" + @$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxdrv + @cp vboxdrv/vboxdrv.ko . + @echo + @if [ -d vboxnetflt ]; then \ + if [ -f vboxdrv/Module.symvers ]; then \ + cp vboxdrv/Module.symvers vboxnetflt; \ + fi; \ + echo "*** Building 'vboxnetflt' module ***"; \ + $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxnetflt; \ + cp vboxnetflt/vboxnetflt.ko .; \ + fi + + +install: + @$(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxdrv install + @if [ -d vboxnetflt ]; then \ + $(MAKE) KBUILD_VERBOSE=$(KBUILD_VERBOSE) -C vboxnetflt install; \ + fi + +clean: + @$(MAKE) -C vboxdrv clean + @if [ -d vboxnetflt ]; then \ + $(MAKE) -C vboxnetflt clean; \ + fi + rm -f vboxdrv.ko vboxnetflt.ko + +load: + @for module in vboxnetflt vboxdrv; do \ + if grep "^$$module " /proc/modules >/dev/null; then \ + echo "Removing previously installed $$module module"; \ + /sbin/rmmod $$module; \ + fi; \ + done + @for module in vboxdrv vboxnetflt; do \ + if test -f $$module.ko; then \ + echo "Installing $$module module"; \ + /sbin/insmod $$module.ko; \ + fi; \ + done diff --git a/src/VBox/HostDrivers/linux/Makefile.kup b/src/VBox/HostDrivers/linux/Makefile.kup new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/src/VBox/HostDrivers/linux/Makefile.kup diff --git a/src/VBox/HostDrivers/linux/build_in_tmp b/src/VBox/HostDrivers/linux/build_in_tmp new file mode 100755 index 000000000..0b1d17a5a --- /dev/null +++ b/src/VBox/HostDrivers/linux/build_in_tmp @@ -0,0 +1,112 @@ +#!/bin/sh + +# +# Script to build a kernel module in /tmp. Useful if the module sources +# are installed in read-only directory. +# +# Copyright (C) 2007 Sun Microsystems, Inc. +# +# This file is part of VirtualBox Open Source Edition (OSE), as +# available from http://www.virtualbox.org. This file is free software; +# you can redistribute it and/or modify it under the terms of the GNU +# General Public License (GPL) as published by the Free Software +# Foundation, in version 2 as it comes in the "COPYING" file of the +# VirtualBox OSE distribution. VirtualBox OSE is distributed in the +# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. +# +# The contents of this file may alternatively be used under the terms +# of the Common Development and Distribution License Version 1.0 +# (CDDL) only, as it comes in the "COPYING.CDDL" file of the +# VirtualBox OSE distribution, in which case the provisions of the +# CDDL are applicable instead of those of the GPL. +# +# You may elect to license modified versions of this file under the +# terms and conditions of either the GPL or the CDDL or both. +# +# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa +# Clara, CA 95054 USA or visit http://www.sun.com if you need +# additional information or have any questions. +# + +# Attempt to build using DKMS first +DKMS=`which dkms 2>/dev/null` +if [ -n "$DKMS" ] +then + echo "Attempting to install using DKMS" + $DKMS status -m _MODULE_ | while read line + # first, remove _any_ old module + do + if echo "$line" | grep -q added > /dev/null || + echo "$line" | grep -q built > /dev/null || + echo "$line" | grep -q installed > /dev/null; then + version=`echo "$line" | sed "s/_MODULE_,\([^,]*\),.*/\1/;t;d"` + echo " removing old DKMS module _MODULE_ version $version" + $DKMS remove -m _MODULE_ -v $version --all + fi + done + # there should not be any more matches + status=`$DKMS status -m _MODULE_ -v _VERSION_` + if echo $status | grep added > /dev/null || + echo $status | grep built > /dev/null || + echo $status | grep installed > /dev/null + then + $DKMS remove -m _MODULE_ -v _VERSION_ --all + fi + # finally install the module + if $DKMS add -m _MODULE_ -v _VERSION_ && + $DKMS build -m _MODULE_ -v _VERSION_ && + $DKMS install -m _MODULE_ -v _VERSION_ --force + then + exit 0 + fi + echo "Failed to install using DKMS, attempting to install without" +fi + +# find a unique temp directory +num=0 +while true; do + tmpdir="/tmp/vbox.$num" + if mkdir -m 0755 "$tmpdir" 2> /dev/null; then + break + fi + num=`expr $num + 1` + if [ $num -gt 200 ]; then + echo "Could not find a valid tmp directory" + exit 1 + fi +done + +if [ "$1" = "--save-module-symvers" ]; then + shift + SAVE_MOD_SYMVERS="$1" + shift +fi + +if [ "$1" = "--use-module-symvers" ]; then + shift + USE_MOD_SYMVERS="$1" + shift +fi + +# copy +cp -a ${0%/*}/* $tmpdir/ +if [ -n "$USE_MOD_SYMVERS" ]; then + cp $USE_MOD_SYMVERS $tmpdir/Module.symvers +fi + +# make, cleanup if success +cd "$tmpdir" +if make "$@"; then + if [ -n "$SAVE_MOD_SYMVERS" ]; then + if [ -f Module.symvers ]; then + cp -f Module.symvers $SAVE_MOD_SYMVERS + else + cat /dev/null > $SAVE_MOD_SYMVERS + fi + fi + rm -rf $tmpdir + exit 0 +fi + +# failure +exit 1 diff --git a/src/VBox/HostDrivers/linux/export_modules b/src/VBox/HostDrivers/linux/export_modules new file mode 100755 index 000000000..a0dca9902 --- /dev/null +++ b/src/VBox/HostDrivers/linux/export_modules @@ -0,0 +1,103 @@ +#!/bin/sh + +# +# Create a tar archive containing the sources of the vboxdrv kernel module +# +# Copyright (C) 2007 Sun Microsystems, Inc. +# +# This file is part of VirtualBox Open Source Edition (OSE), as +# available from http://www.virtualbox.org. This file is free software; +# you can redistribute it and/or modify it under the terms of the GNU +# General Public License (GPL) as published by the Free Software +# Foundation, in version 2 as it comes in the "COPYING" file of the +# VirtualBox OSE distribution. VirtualBox OSE is distributed in the +# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. +# +# Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa +# Clara, CA 95054 USA or visit http://www.sun.com if you need +# additional information or have any questions. +# + +if [ -z "$1" ]; then + echo "Usage: $0 <filename.tar.gz> [--without-hardening]" + echo " Export VirtualBox kernel modules to <filename.tar.gz>" + exit 1 +fi + +VBOX_WITH_HARDENING=1 +if [ "$2" = "--without-hardening" ]; then + VBOX_WITH_HARDENING= +fi + +PATH_TMP="`cd \`dirname $1\`; pwd`/.vbox_modules" +PATH_OUT=$PATH_TMP +FILE_OUT="`cd \`dirname $1\`; pwd`/`basename $1`" +PATH_ROOT="`cd \`dirname $0\`/../../../..; pwd`" +PATH_LINUX="$PATH_ROOT/src/VBox/HostDrivers/linux" +PATH_VBOXDRV="$PATH_ROOT/src/VBox/HostDrivers/Support" +PATH_VBOXNET="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetFlt" + +VBOX_VERSION_MAJOR=`sed -e "s/^ *VBOX_VERSION_MAJOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk` +VBOX_VERSION_MINOR=`sed -e "s/^ *VBOX_VERSION_MINOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk` +VBOX_VERSION_BUILD=`sed -e "s/^ *VBOX_VERSION_BUILD *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk` +VBOX_VERSION_STRING=$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD + +. $PATH_VBOXDRV/linux/files_vboxdrv +. $PATH_VBOXNET/linux/files_vboxnetflt + +# Temporary path for creating the modules, will be removed later +mkdir $PATH_TMP || exit 1 + +# Create auto-generated version file, needed by all modules +echo "#ifndef __version_generated_h__" > $PATH_TMP/version-generated.h +echo "#define __version_generated_h__" >> $PATH_TMP/version-generated.h +echo "" >> $PATH_TMP/version-generated.h +echo "#define VBOX_VERSION_MAJOR $VBOX_VERSION_MAJOR" >> $PATH_TMP/version-generated.h +echo "#define VBOX_VERSION_MINOR $VBOX_VERSION_MINOR" >> $PATH_TMP/version-generated.h +echo "#define VBOX_VERSION_BUILD $VBOX_VERSION_BUILD" >> $PATH_TMP/version-generated.h +echo "#define VBOX_VERSION_STRING \"$VBOX_VERSION_STRING\"" >> $PATH_TMP/version-generated.h +echo "" >> $PATH_TMP/version-generated.h +echo "#endif" >> $PATH_TMP/version-generated.h + +# vboxdrv (VirtualBox host kernel module) +mkdir $PATH_TMP/vboxdrv || exit 1 +for f in $FILES_VBOXDRV_NOBIN; do + install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`" +done +for f in $FILES_VBOXDRV_BIN; do + install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`" +done +sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_LINUX/build_in_tmp > $PATH_TMP/vboxdrv/build_in_tmp +chmod 0755 $PATH_TMP/vboxdrv/build_in_tmp +sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXDRV/linux/dkms.conf > $PATH_TMP/vboxdrv/dkms.conf +if [ -n "$VBOX_WITH_HARDENING" ]; then + cat $PATH_VBOXDRV/linux/Makefile > $PATH_TMP/vboxdrv/Makefile +else + sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXDRV/linux/Makefile > $PATH_TMP/vboxdrv/Makefile +fi + +# vboxnetflt (VirtualBox netfilter kernel module) +mkdir $PATH_TMP/vboxnetflt || exit 1 +for f in $VBOX_VBOXNETFLT_SOURCES; do + install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxnetflt/`echo $f|cut -d'>' -f2`" +done +sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_LINUX/build_in_tmp > $PATH_TMP/vboxnetflt/build_in_tmp +chmod 0755 $PATH_TMP/vboxnetflt/build_in_tmp +sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXNET/linux/dkms.conf > $PATH_TMP/vboxnetflt/dkms.conf +if [ -n "$VBOX_WITH_HARDENING" ]; then + cat $PATH_VBOXNET/linux/Makefile > $PATH_TMP/vboxnetflt/Makefile +else + sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXNET/linux/Makefile > $PATH_TMP/vboxnetflt/Makefile +fi + +install -D -m 0644 $PATH_LINUX/Makefile $PATH_TMP/Makefile + +# Only temporary, omit from archive +rm $PATH_TMP/version-generated.h + +# Create the archive +tar -czf $FILE_OUT -C $PATH_TMP . || exit 1 + +# Remove the temporary directory +rm -r $PATH_TMP + |
