export_modules revision 8d974ced0dc3540dd1b3ec85f8663388e246461a
0N/A#!/bin/sh
594N/A
0N/A#
0N/A# Create a tar archive containing the sources of the vboxdrv kernel module
0N/A#
0N/A# Copyright (C) 2007 Oracle Corporation
0N/A#
0N/A# This file is part of VirtualBox Open Source Edition (OSE), as
0N/A# available from http://www.virtualbox.org. This file is free software;
0N/A# you can redistribute it and/or modify it under the terms of the GNU
0N/A# General Public License (GPL) as published by the Free Software
0N/A# Foundation, in version 2 as it comes in the "COPYING" file of the
0N/A# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
0N/A# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
0N/A#
0N/A
0N/Aif [ -z "$1" ]; then
0N/A echo "Usage: $0 <filename.tar.gz> [--without-hardening]"
0N/A echo " Export VirtualBox kernel modules to <filename.tar.gz>"
0N/A exit 1
0N/Afi
0N/A
0N/AVBOX_WITH_HARDENING=1
0N/Aif [ "$2" = "--without-hardening" ]; then
0N/A VBOX_WITH_HARDENING=
0N/Afi
0N/A
0N/APATH_TMP="`cd \`dirname $1\`; pwd`/.vbox_modules"
0N/APATH_OUT=$PATH_TMP
0N/AFILE_OUT="`cd \`dirname $1\`; pwd`/`basename $1`"
0N/APATH_ROOT="`cd \`dirname $0\`/../../../..; pwd`"
0N/APATH_LINUX="$PATH_ROOT/src/VBox/HostDrivers/linux"
0N/APATH_VBOXDRV="$PATH_ROOT/src/VBox/HostDrivers/Support"
0N/APATH_VBOXNET="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetFlt"
0N/APATH_VBOXADP="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetAdp"
0N/A
0N/AVBOX_VERSION_MAJOR=`sed -e "s/^ *VBOX_VERSION_MAJOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
0N/AVBOX_VERSION_MINOR=`sed -e "s/^ *VBOX_VERSION_MINOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
0N/AVBOX_VERSION_BUILD=`sed -e "s/^ *VBOX_VERSION_BUILD *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
0N/AVBOX_VERSION_STRING=$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD
0N/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`
0N/A
0N/A. $PATH_VBOXDRV/linux/files_vboxdrv
0N/A. $PATH_VBOXNET/linux/files_vboxnetflt
0N/A. $PATH_VBOXADP/linux/files_vboxnetadp
0N/A
0N/A# Temporary path for creating the modules, will be removed later
0N/Amkdir $PATH_TMP || exit 1
955N/A
955N/A# Create auto-generated version file, needed by all modules
0N/Aecho "#ifndef __version_generated_h__" > $PATH_TMP/version-generated.h
0N/Aecho "#define __version_generated_h__" >> $PATH_TMP/version-generated.h
0N/Aecho "" >> $PATH_TMP/version-generated.h
0N/Aecho "#define VBOX_VERSION_MAJOR $VBOX_VERSION_MAJOR" >> $PATH_TMP/version-generated.h
0N/Aecho "#define VBOX_VERSION_MINOR $VBOX_VERSION_MINOR" >> $PATH_TMP/version-generated.h
0N/Aecho "#define VBOX_VERSION_BUILD $VBOX_VERSION_BUILD" >> $PATH_TMP/version-generated.h
0N/Aecho "#define VBOX_VERSION_STRING \"$VBOX_VERSION_STRING\"" >> $PATH_TMP/version-generated.h
0N/Aecho "" >> $PATH_TMP/version-generated.h
0N/Aecho "#endif" >> $PATH_TMP/version-generated.h
0N/A
0N/A# Create auto-generated revision file, needed by all modules
0N/Aecho "#ifndef __revision_generated_h__" > $PATH_TMP/revision-generated.h
0N/Aecho "#define __revision_generated_h__" >> $PATH_TMP/revision-generated.h
0N/Aecho "" >> $PATH_TMP/revision-generated.h
0N/Aecho "#define VBOX_SVN_REV $VBOX_SVN_REV" >> $PATH_TMP/revision-generated.h
0N/Aecho "" >> $PATH_TMP/revision-generated.h
0N/Aecho "#endif" >> $PATH_TMP/revision-generated.h
0N/A
0N/A# Create auto-generated product file, needed by all modules
0N/Aecho "#ifndef __product_generated_h__" > $PATH_TMP/product-generated.h
0N/Aecho "#define __product_generated_h__" >> $PATH_TMP/product-generated.h
0N/Aecho "" >> $PATH_TMP/product-generated.h
0N/Aecho "#define VBOX_VENDOR \"$VBOX_VENDOR\"" >> $PATH_TMP/product-generated.h
0N/Aecho "#define VBOX_VENDOR_SHORT \"$VBOX_VENDOR_SHORT\"" >> $PATH_TMP/product-generated.h
0N/Aecho "" >> $PATH_TMP/product-generated.h
0N/Aecho "#define VBOX_PRODUCT \"$VBOX_PRODUCT\"" >> $PATH_TMP/product-generated.h
0N/Aecho "#define VBOX_C_YEAR \"$VBOX_C_YEAR\"" >> $PATH_TMP/product-generated.h
0N/Aecho "" >> $PATH_TMP/product-generated.h
0N/Aecho "#endif" >> $PATH_TMP/product-generated.h
0N/A
0N/A# vboxdrv (VirtualBox host kernel module)
0N/Amkdir $PATH_TMP/vboxdrv || exit 1
0N/Afor f in $FILES_VBOXDRV_NOBIN; do
0N/A install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`"
0N/Adone
0N/Afor f in $FILES_VBOXDRV_BIN; do
0N/A install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`"
0N/Adone
0N/Ased -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_LINUX/build_in_tmp > $PATH_TMP/vboxdrv/build_in_tmp
0N/Achmod 0755 $PATH_TMP/vboxdrv/build_in_tmp
0N/Ased -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXDRV/linux/dkms.conf > $PATH_TMP/vboxdrv/dkms.conf
0N/Aif [ -n "$VBOX_WITH_HARDENING" ]; then
0N/A cat $PATH_VBOXDRV/linux/Makefile > $PATH_TMP/vboxdrv/Makefile
0N/Aelse
0N/A sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXDRV/linux/Makefile > $PATH_TMP/vboxdrv/Makefile
0N/Afi
0N/A
459N/A# vboxnetflt (VirtualBox netfilter kernel module)
459N/Amkdir $PATH_TMP/vboxnetflt || exit 1
0N/Afor f in $VBOX_VBOXNETFLT_SOURCES; do
0N/A install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxnetflt/`echo $f|cut -d'>' -f2`"
0N/Adone
0N/Ased -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_LINUX/build_in_tmp > $PATH_TMP/vboxnetflt/build_in_tmp
0N/Achmod 0755 $PATH_TMP/vboxnetflt/build_in_tmp
0N/Ased -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXNET/linux/dkms.conf > $PATH_TMP/vboxnetflt/dkms.conf
0N/Aif [ -n "$VBOX_WITH_HARDENING" ]; then
0N/A cat $PATH_VBOXNET/linux/Makefile > $PATH_TMP/vboxnetflt/Makefile
0N/Aelse
0N/A sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXNET/linux/Makefile > $PATH_TMP/vboxnetflt/Makefile
0N/Afi
# 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
sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_LINUX/build_in_tmp > $PATH_TMP/vboxnetadp/build_in_tmp
chmod 0755 $PATH_TMP/vboxnetadp/build_in_tmp
sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXADP/linux/dkms.conf > $PATH_TMP/vboxnetadp/dkms.conf
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
install -D -m 0644 $PATH_LINUX/Makefile $PATH_TMP/Makefile
# 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