export_modules revision b2c3f5df103036986b56a7d5815b20d50399a372
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews#!/bin/sh
bec154197d3d640b0d5b416cd5218ea58dca5d3aTinderbox User
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews#
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Create a tar archive containing the sources of the vboxdrv kernel module
4a14ce5ba00ab7bc55c99ffdcf59c7a4ab902721Automatic Updater#
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Copyright (C) 2007 Oracle Corporation
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews#
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# This file is part of VirtualBox Open Source Edition (OSE), as
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# available from http://www.virtualbox.org. This file is free software;
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# you can redistribute it and/or modify it under the terms of the GNU
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# General Public License (GPL) as published by the Free Software
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Foundation, in version 2 as it comes in the "COPYING" file of the
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews#
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews
ea94d370123a5892f6c47a97f21d1b28d44bb168Tinderbox Userif [ -z "$1" ]; then
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews echo "Usage: $0 <filename.tar.gz> [--without-hardening]"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews echo " Export VirtualBox kernel modules to <filename.tar.gz>"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews exit 1
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsfi
e21a2904f02a03fa06b6db04d348f65fe9c67b2bMark Andrews
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark AndrewsVBOX_WITH_HARDENING=1
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsif [ "$2" = "--without-hardening" ]; then
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews VBOX_WITH_HARDENING=
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsfi
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark AndrewsPATH_ROOT="`cd \`dirname $0\`/../../../..; pwd`"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark AndrewsPATH_LINUX="$PATH_ROOT/src/VBox/HostDrivers/linux"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark AndrewsPATH_VBOXDRV="$PATH_ROOT/src/VBox/HostDrivers/Support"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark AndrewsPATH_VBOXNET="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetFlt"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark AndrewsPATH_VBOXADP="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetAdp"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark AndrewsPATH_VBOXPCI="$PATH_ROOT/src/VBox/HostDrivers/VBoxPci"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark AndrewsVBOX_VERSION_MAJOR=`sed -e "s/^ *VBOX_VERSION_MAJOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark AndrewsVBOX_VERSION_MINOR=`sed -e "s/^ *VBOX_VERSION_MINOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark AndrewsVBOX_VERSION_BUILD=`sed -e "s/^ *VBOX_VERSION_BUILD *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark AndrewsVBOX_VERSION_STRING=$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark AndrewsVBOX_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`
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews. $PATH_VBOXDRV/linux/files_vboxdrv
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews. $PATH_VBOXNET/linux/files_vboxnetflt
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews. $PATH_VBOXADP/linux/files_vboxnetadp
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews. $PATH_VBOXPCI/linux/files_vboxpci
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Temporary path for creating the modules, will be removed later
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsmkdir $PATH_TMP || exit 1
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Create auto-generated version file, needed by all modules
d8620c7234281056fdfd2ee40cf16636b8281092Tinderbox Userecho "#ifndef __version_generated_h__" > $PATH_TMP/version-generated.h
d8620c7234281056fdfd2ee40cf16636b8281092Tinderbox Userecho "#define __version_generated_h__" >> $PATH_TMP/version-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "" >> $PATH_TMP/version-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "#define VBOX_VERSION_MAJOR $VBOX_VERSION_MAJOR" >> $PATH_TMP/version-generated.h
43b94483957d3168796a816ed86cf097518817dcTinderbox Userecho "#define VBOX_VERSION_MINOR $VBOX_VERSION_MINOR" >> $PATH_TMP/version-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "#define VBOX_VERSION_BUILD $VBOX_VERSION_BUILD" >> $PATH_TMP/version-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "#define VBOX_VERSION_STRING \"$VBOX_VERSION_STRING\"" >> $PATH_TMP/version-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "" >> $PATH_TMP/version-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "#endif" >> $PATH_TMP/version-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Create auto-generated revision file, needed by all modules
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "#ifndef __revision_generated_h__" > $PATH_TMP/revision-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "#define __revision_generated_h__" >> $PATH_TMP/revision-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "" >> $PATH_TMP/revision-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "#define VBOX_SVN_REV $VBOX_SVN_REV" >> $PATH_TMP/revision-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "" >> $PATH_TMP/revision-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "#endif" >> $PATH_TMP/revision-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews
f6da30bb5447c23d880b09f601441e70c5313557Mark Andrews# Create auto-generated product file, needed by all modules
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "#ifndef __product_generated_h__" > $PATH_TMP/product-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "#define __product_generated_h__" >> $PATH_TMP/product-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "" >> $PATH_TMP/product-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "#define VBOX_VENDOR \"$VBOX_VENDOR\"" >> $PATH_TMP/product-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "#define VBOX_VENDOR_SHORT \"$VBOX_VENDOR_SHORT\"" >> $PATH_TMP/product-generated.h
43b94483957d3168796a816ed86cf097518817dcTinderbox Userecho "" >> $PATH_TMP/product-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "#define VBOX_PRODUCT \"$VBOX_PRODUCT\"" >> $PATH_TMP/product-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "#define VBOX_C_YEAR \"$VBOX_C_YEAR\"" >> $PATH_TMP/product-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "" >> $PATH_TMP/product-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsecho "#endif" >> $PATH_TMP/product-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews
f7b41fd9291b8f4dba27e2b57e1d93f0913a4f1dMark Andrews# vboxdrv (VirtualBox host kernel module)
f7b41fd9291b8f4dba27e2b57e1d93f0913a4f1dMark Andrewsmkdir $PATH_TMP/vboxdrv || exit 1
f7b41fd9291b8f4dba27e2b57e1d93f0913a4f1dMark Andrewsfor f in $FILES_VBOXDRV_NOBIN; do
f7b41fd9291b8f4dba27e2b57e1d93f0913a4f1dMark Andrews install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsdone
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsfor f in $FILES_VBOXDRV_BIN; do
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsdone
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewssed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXDRV/linux/dkms.conf > $PATH_TMP/vboxdrv/dkms.conf
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsif [ -n "$VBOX_WITH_HARDENING" ]; then
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews cat $PATH_VBOXDRV/linux/Makefile > $PATH_TMP/vboxdrv/Makefile
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewselse
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXDRV/linux/Makefile > $PATH_TMP/vboxdrv/Makefile
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsfi
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews
d8620c7234281056fdfd2ee40cf16636b8281092Tinderbox User# vboxnetflt (VirtualBox netfilter kernel module)
d8620c7234281056fdfd2ee40cf16636b8281092Tinderbox Usermkdir $PATH_TMP/vboxnetflt || exit 1
d8620c7234281056fdfd2ee40cf16636b8281092Tinderbox Userfor f in $VBOX_VBOXNETFLT_SOURCES; do
d8620c7234281056fdfd2ee40cf16636b8281092Tinderbox User install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxnetflt/`echo $f|cut -d'>' -f2`"
d8620c7234281056fdfd2ee40cf16636b8281092Tinderbox Userdone
d8620c7234281056fdfd2ee40cf16636b8281092Tinderbox Usersed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXNET/linux/dkms.conf > $PATH_TMP/vboxnetflt/dkms.conf
d8620c7234281056fdfd2ee40cf16636b8281092Tinderbox Userif [ -n "$VBOX_WITH_HARDENING" ]; then
d8620c7234281056fdfd2ee40cf16636b8281092Tinderbox User cat $PATH_VBOXNET/linux/Makefile > $PATH_TMP/vboxnetflt/Makefile
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewselse
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXNET/linux/Makefile > $PATH_TMP/vboxnetflt/Makefile
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsfi
9fbbfb5757a1e3e86d7dea62c4e63ffc2303ca2bAutomatic Updater
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# vboxnetadp (VirtualBox network adapter kernel module)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsmkdir $PATH_TMP/vboxnetadp || exit 1
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsfor f in $VBOX_VBOXNETADP_SOURCES; do
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxnetadp/`echo $f|cut -d'>' -f2`"
d71e2e0c61df16ff37c9934c371a4a60c08974f7Mark Andrewsdone
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewssed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXADP/linux/dkms.conf > $PATH_TMP/vboxnetadp/dkms.conf
a057e8e33baa5fa369be28a9680585200ce3ff73Mark Andrewsif [ -n "$VBOX_WITH_HARDENING" ]; then
a057e8e33baa5fa369be28a9680585200ce3ff73Mark Andrews cat $PATH_VBOXADP/linux/Makefile > $PATH_TMP/vboxnetadp/Makefile
a057e8e33baa5fa369be28a9680585200ce3ff73Mark Andrewselse
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXADP/linux/Makefile > $PATH_TMP/vboxnetadp/Makefile
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsfi
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# vboxpci (VirtualBox host PCI access kernel module)
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsmkdir $PATH_TMP/vboxpci || exit 1
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsfor f in $VBOX_VBOXPCI_SOURCES; do
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxpci/`echo $f|cut -d'>' -f2`"
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsdone
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewssed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXPCI/linux/dkms.conf > $PATH_TMP/vboxpci/dkms.conf
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsif [ -n "$VBOX_WITH_HARDENING" ]; then
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews cat $PATH_VBOXPCI/linux/Makefile > $PATH_TMP/vboxpci/Makefile
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewselse
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXPCI/linux/Makefile > $PATH_TMP/vboxpci/Makefile
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsfi
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsinstall -D -m 0644 $PATH_LINUX/Makefile $PATH_TMP/Makefile
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsinstall -D -m 0755 $PATH_LINUX/build_in_tmp $PATH_TMP/build_in_tmp
d71e2e0c61df16ff37c9934c371a4a60c08974f7Mark Andrews
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews# Only temporary, omit from archive
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsrm $PATH_TMP/version-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsrm $PATH_TMP/revision-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrewsrm $PATH_TMP/product-generated.h
5a4557e8de2951a2796676b5ec4b6a90caa5be14Mark Andrews
a057e8e33baa5fa369be28a9680585200ce3ff73Mark Andrews# Create the archive
a057e8e33baa5fa369be28a9680585200ce3ff73Mark Andrewstar -czf $FILE_OUT -C $PATH_TMP . || exit 1
a057e8e33baa5fa369be28a9680585200ce3ff73Mark Andrews
a057e8e33baa5fa369be28a9680585200ce3ff73Mark Andrews# Remove the temporary directory
a057e8e33baa5fa369be28a9680585200ce3ff73Mark Andrewsrm -r $PATH_TMP
a057e8e33baa5fa369be28a9680585200ce3ff73Mark Andrews