export_modules revision 73e8df2e481cb3697372a3cf4acffd068a7f1296
2818N/A#!/bin/sh
2818N/A
2818N/A#
2818N/A# Create a tar archive containing the sources of the vboxdrv kernel module
2818N/A#
2818N/A# Copyright (C) 2007 Oracle Corporation
2818N/A#
2818N/A# available from http://www.virtualbox.org. This file is free software;
2818N/A# you can redistribute it and/or modify it under the terms of the GNU
2818N/A# General Public License (GPL) as published by the Free Software
2818N/A# Foundation, in version 2 as it comes in the "COPYING" file of the
2818N/A# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2818N/A# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2818N/A#
2818N/A
2818N/Aif [ -z "$1" ]; then
2818N/A echo "Usage: $0 <filename.tar.gz> [--without-hardening]"
2818N/A echo " Export VirtualBox kernel modules to <filename.tar.gz>"
2818N/A exit 1
2818N/Afi
2818N/A
2818N/AVBOX_WITH_HARDENING=1
3633N/Aif [ "$2" = "--without-hardening" ]; then
2818N/A VBOX_WITH_HARDENING=
2818N/Afi
2818N/A
2818N/APATH_ROOT="`cd \`dirname $0\`/../../../..; pwd`"
2818N/APATH_LINUX="$PATH_ROOT/src/VBox/HostDrivers/linux"
3869N/APATH_VBOXDRV="$PATH_ROOT/src/VBox/HostDrivers/Support"
2818N/APATH_VBOXNET="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetFlt"
2818N/APATH_VBOXADP="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetAdp"
2818N/APATH_VBOXPCI="$PATH_ROOT/src/VBox/HostDrivers/VBoxPci"
2818N/A
3869N/AVBOX_VERSION_MAJOR=`sed -e "s/^ *VBOX_VERSION_MAJOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
2818N/AVBOX_VERSION_MINOR=`sed -e "s/^ *VBOX_VERSION_MINOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
3869N/AVBOX_VERSION_BUILD=`sed -e "s/^ *VBOX_VERSION_BUILD *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
2818N/AVBOX_VERSION_STRING=$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD
2818N/AVBOX_SVN_REV=`sed -e 's/^ *VBOX_SVN_REV_FALLBACK *:= \+\$(patsubst *%:,, *\$Rev: *\([0-9]\+\) *\$ *) */\1/;t;d' $PATH_ROOT/Config.kmk` VBOX_VENDOR=`sed -e 's/^ *VBOX_VENDOR *= \+\(.\+\)/\1/;t;d' $PATH_ROOT/Config.kmk` VBOX_VENDOR_SHORT=`sed -e 's/^ *VBOX_VENDOR_SHORT *= \+\(.\+\)/\1/;t;d' $PATH_ROOT/Config.kmk` VBOX_PRODUCT=`sed -e 's/^ *VBOX_PRODUCT *= \+\(.\+\)/\1/;t;d' $PATH_ROOT/Config.kmk` VBOX_C_YEAR=`date +%Y`
3869N/A
2899N/A. $PATH_VBOXDRV/linux/files_vboxdrv
3817N/A. $PATH_VBOXNET/linux/files_vboxnetflt
3817N/A. $PATH_VBOXADP/linux/files_vboxnetadp
3817N/A. $PATH_VBOXPCI/linux/files_vboxpci
3817N/A
2818N/A# Temporary path for creating the modules, will be removed later
2818N/Amkdir $PATH_TMP || exit 1
2818N/A
2818N/A# Create auto-generated version file, needed by all modules
2818N/Aecho "#ifndef __version_generated_h__" > $PATH_TMP/version-generated.h
2818N/Aecho "#define __version_generated_h__" >> $PATH_TMP/version-generated.h
2818N/Aecho "" >> $PATH_TMP/version-generated.h
2818N/Aecho "#define VBOX_VERSION_MAJOR $VBOX_VERSION_MAJOR" >> $PATH_TMP/version-generated.h
2818N/Aecho "#define VBOX_VERSION_MINOR $VBOX_VERSION_MINOR" >> $PATH_TMP/version-generated.h
2818N/Aecho "#define VBOX_VERSION_BUILD $VBOX_VERSION_BUILD" >> $PATH_TMP/version-generated.h
2818N/Aecho "#define VBOX_VERSION_STRING \"$VBOX_VERSION_STRING\"" >> $PATH_TMP/version-generated.h
2818N/Aecho "" >> $PATH_TMP/version-generated.h
2818N/Aecho "#endif" >> $PATH_TMP/version-generated.h
2818N/A
2818N/A# Create auto-generated revision file, needed by all modules
2818N/Aecho "#ifndef __revision_generated_h__" > $PATH_TMP/revision-generated.h
2818N/Aecho "#define __revision_generated_h__" >> $PATH_TMP/revision-generated.h
2818N/Aecho "" >> $PATH_TMP/revision-generated.h
2818N/Aecho "#define VBOX_SVN_REV $VBOX_SVN_REV" >> $PATH_TMP/revision-generated.h
2818N/Aecho "" >> $PATH_TMP/revision-generated.h
2818N/Aecho "#endif" >> $PATH_TMP/revision-generated.h
2818N/A
2818N/A# Create auto-generated product file, needed by all modules
2818N/Aecho "#ifndef __product_generated_h__" > $PATH_TMP/product-generated.h
2818N/Aecho "#define __product_generated_h__" >> $PATH_TMP/product-generated.h
2818N/Aecho "" >> $PATH_TMP/product-generated.h
2818N/Aecho "#define VBOX_VENDOR \"$VBOX_VENDOR\"" >> $PATH_TMP/product-generated.h
2818N/Aecho "#define VBOX_VENDOR_SHORT \"$VBOX_VENDOR_SHORT\"" >> $PATH_TMP/product-generated.h
2818N/Aecho "" >> $PATH_TMP/product-generated.h
2818N/Aecho "#define VBOX_PRODUCT \"$VBOX_PRODUCT\"" >> $PATH_TMP/product-generated.h
2818N/Aecho "#define VBOX_C_YEAR \"$VBOX_C_YEAR\"" >> $PATH_TMP/product-generated.h
2818N/Aecho "" >> $PATH_TMP/product-generated.h
2818N/Aecho "#endif" >> $PATH_TMP/product-generated.h
2818N/A
2818N/A# vboxdrv (VirtualBox host kernel module)
3633N/Amkdir $PATH_TMP/vboxdrv || exit 1
3633N/Afor f in $FILES_VBOXDRV_NOBIN; do
3633N/A install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`"
2818N/Adone
2818N/Afor f in $FILES_VBOXDRV_BIN; do
2818N/A install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`"
2818N/Adone
2818N/Ased -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXDRV/linux/dkms.conf > $PATH_TMP/vboxdrv/dkms.conf
2818N/Aif [ -n "$VBOX_WITH_HARDENING" ]; then
2818N/A cat $PATH_VBOXDRV/linux/Makefile > $PATH_TMP/vboxdrv/Makefile
2818N/Aelse
2818N/A sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXDRV/linux/Makefile > $PATH_TMP/vboxdrv/Makefile
2818N/Afi
2818N/A
2818N/A# vboxnetflt (VirtualBox netfilter kernel module)
2818N/Amkdir $PATH_TMP/vboxnetflt || exit 1
2818N/Afor f in $VBOX_VBOXNETFLT_SOURCES; do
2818N/A install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxnetflt/`echo $f|cut -d'>' -f2`"
3693N/Adone
3693N/Ased -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXNET/linux/dkms.conf > $PATH_TMP/vboxnetflt/dkms.conf
3693N/Aif [ -n "$VBOX_WITH_HARDENING" ]; then
3693N/A cat $PATH_VBOXNET/linux/Makefile > $PATH_TMP/vboxnetflt/Makefile
3693N/Aelse
3693N/A sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXNET/linux/Makefile > $PATH_TMP/vboxnetflt/Makefile
3693N/Afi
2818N/A
2818N/A# vboxnetadp (VirtualBox network adapter kernel module)
2818N/Amkdir $PATH_TMP/vboxnetadp || exit 1
2818N/Afor f in $VBOX_VBOXNETADP_SOURCES; do
2818N/A install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxnetadp/`echo $f|cut -d'>' -f2`"
2818N/Adone
2818N/Ased -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXADP/linux/dkms.conf > $PATH_TMP/vboxnetadp/dkms.conf
2818N/Aif [ -n "$VBOX_WITH_HARDENING" ]; then
3251N/A cat $PATH_VBOXADP/linux/Makefile > $PATH_TMP/vboxnetadp/Makefile
2818N/Aelse
2818N/A sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXADP/linux/Makefile > $PATH_TMP/vboxnetadp/Makefile
2818N/Afi
2818N/A
2818N/A# vboxpci (VirtualBox host PCI access kernel module)
2818N/Amkdir $PATH_TMP/vboxpci || exit 1
2818N/Afor f in $VBOX_VBOXPCI_SOURCES; do
2818N/A install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxpci/`echo $f|cut -d'>' -f2`"
3693N/Adone
2818N/Ased -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXPCI/linux/dkms.conf > $PATH_TMP/vboxpci/dkms.conf
2818N/Aif [ -n "$VBOX_WITH_HARDENING" ]; then
2818N/A cat $PATH_VBOXPCI/linux/Makefile > $PATH_TMP/vboxpci/Makefile
2818N/Aelse
2818N/A sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXPCI/linux/Makefile > $PATH_TMP/vboxpci/Makefile
2818N/Afi
2818N/A
2818N/Ainstall -D -m 0644 $PATH_LINUX/Makefile $PATH_TMP/Makefile
2818N/Ainstall -D -m 0755 $PATH_LINUX/build_in_tmp $PATH_TMP/build_in_tmp
2818N/A
3497N/A# Only temporary, omit from archive
3497N/Arm $PATH_TMP/version-generated.h
3497N/Arm $PATH_TMP/revision-generated.h
3497N/Arm $PATH_TMP/product-generated.h
3497N/A
3497N/A# Create the archive
3497N/Atar -czf $FILE_OUT -C $PATH_TMP . || exit 1
3497N/A
3497N/A# Remove the temporary directory
3497N/Arm -r $PATH_TMP
3497N/A