export_modules revision fcfca16ae0b575f4a0a8baf45928c6684c265de2
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster#!/bin/sh
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster#
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster# Create a tar archive containing the sources of the vboxdrv kernel module
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster#
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster# Copyright (C) 2007-2012 Oracle Corporation
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster#
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster# This file is part of VirtualBox Open Source Edition (OSE), as
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster# available from http://www.virtualbox.org. This file is free software;
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster# you can redistribute it and/or modify it under the terms of the GNU
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster# General Public License (GPL) as published by the Free Software
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster# Foundation, in version 2 as it comes in the "COPYING" file of the
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster#
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterif [ -z "$1" ]; then
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster echo "Usage: $0 <filename.tar.gz> [--without-hardening]"
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster echo " Export VirtualBox kernel modules to <filename.tar.gz>"
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster exit 1
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterfi
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster
869a36e2649ae064c98063cf1e55198488d78d12Allan FosterVBOX_WITH_HARDENING=1
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterif [ "$2" = "--without-hardening" ]; then
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster VBOX_WITH_HARDENING=
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterfi
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster
869a36e2649ae064c98063cf1e55198488d78d12Allan FosterPATH_TMP="`cd \`dirname $1\`; pwd`/.vbox_modules"
869a36e2649ae064c98063cf1e55198488d78d12Allan FosterPATH_OUT=$PATH_TMP
869a36e2649ae064c98063cf1e55198488d78d12Allan FosterFILE_OUT="`cd \`dirname $1\`; pwd`/`basename $1`"
869a36e2649ae064c98063cf1e55198488d78d12Allan FosterPATH_ROOT="`cd \`dirname $0\`/../../../..; pwd`"
869a36e2649ae064c98063cf1e55198488d78d12Allan FosterPATH_LINUX="$PATH_ROOT/src/VBox/HostDrivers/linux"
869a36e2649ae064c98063cf1e55198488d78d12Allan FosterPATH_VBOXDRV="$PATH_ROOT/src/VBox/HostDrivers/Support"
869a36e2649ae064c98063cf1e55198488d78d12Allan FosterPATH_VBOXNET="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetFlt"
869a36e2649ae064c98063cf1e55198488d78d12Allan FosterPATH_VBOXADP="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetAdp"
869a36e2649ae064c98063cf1e55198488d78d12Allan FosterPATH_VBOXPCI="$PATH_ROOT/src/VBox/HostDrivers/VBoxPci"
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster
869a36e2649ae064c98063cf1e55198488d78d12Allan FosterVBOX_VERSION_MAJOR=`sed -e "s/^ *VBOX_VERSION_MAJOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
869a36e2649ae064c98063cf1e55198488d78d12Allan FosterVBOX_VERSION_MINOR=`sed -e "s/^ *VBOX_VERSION_MINOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
869a36e2649ae064c98063cf1e55198488d78d12Allan FosterVBOX_VERSION_BUILD=`sed -e "s/^ *VBOX_VERSION_BUILD *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
869a36e2649ae064c98063cf1e55198488d78d12Allan FosterVBOX_VERSION_STRING=$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD
869a36e2649ae064c98063cf1e55198488d78d12Allan FosterVBOX_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`
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster. $PATH_VBOXDRV/linux/files_vboxdrv
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster. $PATH_VBOXNET/linux/files_vboxnetflt
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster. $PATH_VBOXADP/linux/files_vboxnetadp
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster. $PATH_VBOXPCI/linux/files_vboxpci
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster# Temporary path for creating the modules, will be removed later
869a36e2649ae064c98063cf1e55198488d78d12Allan Fostermkdir $PATH_TMP || exit 1
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster# Create auto-generated version file, needed by all modules
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterecho "#ifndef ___version_generated_h___" > $PATH_TMP/version-generated.h
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterecho "#define ___version_generated_h___" >> $PATH_TMP/version-generated.h
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterecho "" >> $PATH_TMP/version-generated.h
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterecho "#define VBOX_VERSION_MAJOR $VBOX_VERSION_MAJOR" >> $PATH_TMP/version-generated.h
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterecho "#define VBOX_VERSION_MINOR $VBOX_VERSION_MINOR" >> $PATH_TMP/version-generated.h
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterecho "#define VBOX_VERSION_BUILD $VBOX_VERSION_BUILD" >> $PATH_TMP/version-generated.h
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterecho "#define VBOX_VERSION_STRING_RAW \"$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD\"" >> $PATH_TMP/version-generated.h
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterecho "#define VBOX_VERSION_STRING \"$VBOX_VERSION_STRING\"" >> $PATH_TMP/version-generated.h
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterecho "#define VBOX_API_VERSION_STRING \"${VBOX_VERSION_MAJOR}_${VBOX_VERSION_MINOR}\"" >> $PATH_TMP/version-generated.h
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterecho "" >> $PATH_TMP/version-generated.h
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterecho "#endif" >> $PATH_TMP/version-generated.h
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster# Create auto-generated revision file, needed by all modules
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterecho "#ifndef __revision_generated_h__" > $PATH_TMP/revision-generated.h
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterecho "#define __revision_generated_h__" >> $PATH_TMP/revision-generated.h
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterecho "" >> $PATH_TMP/revision-generated.h
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterecho "#define VBOX_SVN_REV $VBOX_SVN_REV" >> $PATH_TMP/revision-generated.h
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterecho "" >> $PATH_TMP/revision-generated.h
869a36e2649ae064c98063cf1e55198488d78d12Allan Fosterecho "#endif" >> $PATH_TMP/revision-generated.h
869a36e2649ae064c98063cf1e55198488d78d12Allan Foster
# Create auto-generated product file, needed by all modules
echo "#ifndef ___product_generated_h___" > $PATH_TMP/product-generated.h
echo "#define ___product_generated_h___" >> $PATH_TMP/product-generated.h
echo "" >> $PATH_TMP/product-generated.h
echo "#define VBOX_VENDOR \"$VBOX_VENDOR\"" >> $PATH_TMP/product-generated.h
echo "#define VBOX_VENDOR_SHORT \"$VBOX_VENDOR_SHORT\"" >> $PATH_TMP/product-generated.h
echo "" >> $PATH_TMP/product-generated.h
echo "#define VBOX_PRODUCT \"$VBOX_PRODUCT\"" >> $PATH_TMP/product-generated.h
echo "#define VBOX_C_YEAR \"$VBOX_C_YEAR\"" >> $PATH_TMP/product-generated.h
echo "" >> $PATH_TMP/product-generated.h
echo "#endif" >> $PATH_TMP/product-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
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
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
# vboxnetadp (VirtualBox network adapter kernel module)
mkdir $PATH_TMP/vboxnetadp || exit 1
for f in $VBOX_VBOXNETADP_SOURCES; do
install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxnetadp/`echo $f|cut -d'>' -f2`"
done
if [ -n "$VBOX_WITH_HARDENING" ]; then
cat $PATH_VBOXADP/linux/Makefile > $PATH_TMP/vboxnetadp/Makefile
else
sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXADP/linux/Makefile > $PATH_TMP/vboxnetadp/Makefile
fi
# vboxpci (VirtualBox host PCI access kernel module)
mkdir $PATH_TMP/vboxpci || exit 1
for f in $VBOX_VBOXPCI_SOURCES; do
install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxpci/`echo $f|cut -d'>' -f2`"
done
if [ -n "$VBOX_WITH_HARDENING" ]; then
cat $PATH_VBOXPCI/linux/Makefile > $PATH_TMP/vboxpci/Makefile
else
sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXPCI/linux/Makefile > $PATH_TMP/vboxpci/Makefile
fi
install -D -m 0644 $PATH_LINUX/Makefile $PATH_TMP/Makefile
install -D -m 0755 $PATH_LINUX/build_in_tmp $PATH_TMP/build_in_tmp
# Only temporary, omit from archive
rm $PATH_TMP/version-generated.h
rm $PATH_TMP/revision-generated.h
rm $PATH_TMP/product-generated.h
# Create the archive
tar -czf $FILE_OUT -C $PATH_TMP . || exit 1
# Remove the temporary directory
rm -r $PATH_TMP