export_modules revision e64031e20c39650a7bc902a3e1aba613b9415dee
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync#!/bin/sh
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync#
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync# Create a tar archive containing the sources of the vboxdrv kernel module
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync#
e64031e20c39650a7bc902a3e1aba613b9415deevboxsync# Copyright (C) 2007 Oracle Corporation
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync#
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync# available from http://www.virtualbox.org. This file is free software;
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync# you can redistribute it and/or modify it under the terms of the GNU
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync# General Public License (GPL) as published by the Free Software
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync#
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncif [ -z "$1" ]; then
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync echo "Usage: $0 <filename.tar.gz> [--without-hardening]"
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync echo " Export VirtualBox kernel modules to <filename.tar.gz>"
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync exit 1
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncfi
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncVBOX_WITH_HARDENING=1
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncif [ "$2" = "--without-hardening" ]; then
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync VBOX_WITH_HARDENING=
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncfi
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncPATH_TMP="`cd \`dirname $1\`; pwd`/.vbox_modules"
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncPATH_OUT=$PATH_TMP
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncFILE_OUT="`cd \`dirname $1\`; pwd`/`basename $1`"
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncPATH_ROOT="`cd \`dirname $0\`/../../../..; pwd`"
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncPATH_LINUX="$PATH_ROOT/src/VBox/HostDrivers/linux"
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncPATH_VBOXDRV="$PATH_ROOT/src/VBox/HostDrivers/Support"
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncPATH_VBOXNET="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetFlt"
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncVBOX_VERSION_MAJOR=`sed -e "s/^ *VBOX_VERSION_MAJOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncVBOX_VERSION_MINOR=`sed -e "s/^ *VBOX_VERSION_MINOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncVBOX_VERSION_BUILD=`sed -e "s/^ *VBOX_VERSION_BUILD *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncVBOX_VERSION_STRING=$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync. $PATH_VBOXDRV/linux/files_vboxdrv
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync. $PATH_VBOXNET/linux/files_vboxnetflt
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync# Temporary path for creating the modules, will be removed later
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncmkdir $PATH_TMP || exit 1
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync# Create auto-generated version file, needed by all modules
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncecho "#ifndef __version_generated_h__" > $PATH_TMP/version-generated.h
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncecho "#define __version_generated_h__" >> $PATH_TMP/version-generated.h
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncecho "" >> $PATH_TMP/version-generated.h
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncecho "#define VBOX_VERSION_MAJOR $VBOX_VERSION_MAJOR" >> $PATH_TMP/version-generated.h
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncecho "#define VBOX_VERSION_MINOR $VBOX_VERSION_MINOR" >> $PATH_TMP/version-generated.h
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncecho "#define VBOX_VERSION_BUILD $VBOX_VERSION_BUILD" >> $PATH_TMP/version-generated.h
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncecho "#define VBOX_VERSION_STRING \"$VBOX_VERSION_STRING\"" >> $PATH_TMP/version-generated.h
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncecho "" >> $PATH_TMP/version-generated.h
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncecho "#endif" >> $PATH_TMP/version-generated.h
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync# vboxdrv (VirtualBox host kernel module)
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncmkdir $PATH_TMP/vboxdrv || exit 1
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncfor f in $FILES_VBOXDRV_NOBIN; do
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`"
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncdone
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncfor f in $FILES_VBOXDRV_BIN; do
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`"
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncdone
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncsed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_LINUX/build_in_tmp > $PATH_TMP/vboxdrv/build_in_tmp
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncchmod 0755 $PATH_TMP/vboxdrv/build_in_tmp
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncsed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXDRV/linux/dkms.conf > $PATH_TMP/vboxdrv/dkms.conf
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncif [ -n "$VBOX_WITH_HARDENING" ]; then
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync cat $PATH_VBOXDRV/linux/Makefile > $PATH_TMP/vboxdrv/Makefile
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncelse
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXDRV/linux/Makefile > $PATH_TMP/vboxdrv/Makefile
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncfi
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync# vboxnetflt (VirtualBox netfilter kernel module)
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncmkdir $PATH_TMP/vboxnetflt || exit 1
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncfor f in $VBOX_VBOXNETFLT_SOURCES; do
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxnetflt/`echo $f|cut -d'>' -f2`"
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncdone
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncsed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_LINUX/build_in_tmp > $PATH_TMP/vboxnetflt/build_in_tmp
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncchmod 0755 $PATH_TMP/vboxnetflt/build_in_tmp
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncsed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXNET/linux/dkms.conf > $PATH_TMP/vboxnetflt/dkms.conf
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncif [ -n "$VBOX_WITH_HARDENING" ]; then
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync cat $PATH_VBOXNET/linux/Makefile > $PATH_TMP/vboxnetflt/Makefile
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncelse
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXNET/linux/Makefile > $PATH_TMP/vboxnetflt/Makefile
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncfi
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncinstall -D -m 0644 $PATH_LINUX/Makefile $PATH_TMP/Makefile
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync# Only temporary, omit from archive
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncrm $PATH_TMP/version-generated.h
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync# Create the archive
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsynctar -czf $FILE_OUT -C $PATH_TMP . || exit 1
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync# Remove the temporary directory
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsyncrm -r $PATH_TMP
037f4c44a9ef4e458f46b264aebd12df049b0f0cvboxsync