export_modules revision 80096fb54d147045204dcc7e3ff273158de03f81
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#!/bin/sh
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# Create a tar archive containing the sources of the Linux guest kernel
94a8cb0ee1d85569ad1a2acacd92d3ce22f8a1cbTimo Sirainen# modules
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainen# Copyright (C) 2006-2007 Oracle Corporation
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# This file is part of VirtualBox Open Source Edition (OSE), as
6a19e109ee8c5a6f688da83a86a7f6abeb71abddTimo Sirainen# available from http://www.virtualbox.org. This file is free software;
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# you can redistribute it and/or modify it under the terms of the GNU
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainen# General Public License (GPL) as published by the Free Software
d9fdacd5fb3e07997e5c389739d2054f0c8441d8Timo Sirainen# Foundation, in version 2 as it comes in the "COPYING" file of the
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen#
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
31ddc75584c5cde53d2e78a737587f2e7fdcb0d2Timo Sirainenif [ -z "$1" ]; then
8887bf3757d51d73887dd20b1db3334d867d3817Timo Sirainen echo "Usage: $0 <filename.tar.gz>"
8887bf3757d51d73887dd20b1db3334d867d3817Timo Sirainen echo " Export VirtualBox kernel modules to <filename.tar.gz>"
369a1084c500a9df7448ffa9409ce32e42060bc2Timo Sirainen exit 1
8887bf3757d51d73887dd20b1db3334d867d3817Timo Sirainenfi
a53cb86b4d733d9c48ee4d285bed477c80825804Timo Sirainen
a53cb86b4d733d9c48ee4d285bed477c80825804Timo SirainenPATH_TMP="`cd \`dirname $1\`; pwd`/.vbox_modules"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenPATH_OUT=$PATH_TMP
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenFILE_OUT="`cd \`dirname $1\`; pwd`/`basename $1`"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenPATH_ROOT="`cd \`dirname $0\`/../../../..; pwd`"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenPATH_VBOXGUEST="$PATH_ROOT/src/VBox/Additions/common/VBoxGuest"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo SirainenPATH_VBOXSF="$PATH_ROOT/src/VBox/Additions/linux/sharedfolders"
b7b81543899e306c71e6152516d8698416162bcbTimo Sirainen
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo SirainenVBOX_VERSION_MAJOR=`sed -e "s/^ *VBOX_VERSION_MAJOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
e12648867876aaec17e06ee4caef0bb60363449dTimo SirainenVBOX_VERSION_MINOR=`sed -e "s/^ *VBOX_VERSION_MINOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
e12648867876aaec17e06ee4caef0bb60363449dTimo SirainenVBOX_VERSION_BUILD=`sed -e "s/^ *VBOX_VERSION_BUILD *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
e12648867876aaec17e06ee4caef0bb60363449dTimo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen. $PATH_VBOXGUEST/linux/files_vboxguest
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen. $PATH_VBOXSF/files_vboxsf
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo Sirainen
fd3d711f219fd6813492acbe051e04327f0ca0f0Timo Sirainen# Temporary path for creating the modules, will be removed later
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenmkdir $PATH_TMP || exit 1
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# Create auto-generated version file, needed by all modules
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenecho "#ifndef __version_generated_h__" > $PATH_TMP/version-generated.h
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenecho "#define __version_generated_h__" >> $PATH_TMP/version-generated.h
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenecho "" >> $PATH_TMP/version-generated.h
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenecho "#define VBOX_VERSION_MAJOR $VBOX_VERSION_MAJOR" >> $PATH_TMP/version-generated.h
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenecho "#define VBOX_VERSION_MINOR $VBOX_VERSION_MINOR" >> $PATH_TMP/version-generated.h
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenecho "#define VBOX_VERSION_BUILD $VBOX_VERSION_BUILD" >> $PATH_TMP/version-generated.h
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenecho "#define VBOX_VERSION_STRING \"$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD\"" >> $PATH_TMP/version-generated.h
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenecho "" >> $PATH_TMP/version-generated.h
8e7da21696c9f8a6d5e601243fb6172ec85d47b2Timo Sirainenecho "#endif" >> $PATH_TMP/version-generated.h
024815ea2ffdda9ea79919f18e865663977f73eaTimo Sirainen
024815ea2ffdda9ea79919f18e865663977f73eaTimo Sirainen# vboxguest (VirtualBox guest kernel module)
16c89b1260c9d07c01c83a9219424d3727069b2eTimo Sirainenmkdir $PATH_TMP/vboxguest || exit 1
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenfor f in $FILES_VBOXGUEST_NOBIN; do
811f2e26d9782d9cb99fdf82e18ffa0a77564fe2Timo Sirainen install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxguest/`echo $f|cut -d'>' -f2`"
811f2e26d9782d9cb99fdf82e18ffa0a77564fe2Timo Sirainendone
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenfor f in $FILES_VBOXGUEST_BIN; do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxguest/`echo $f|cut -d'>' -f2`"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainendone
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# vboxsf (VirtualBox guest kernel module for shared folders)
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenmkdir $PATH_TMP/vboxsf || exit 1
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenfor f in $FILES_VBOXSF_NOBIN; do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxsf/`echo $f|cut -d'>' -f2`"
d482b35af87f5fd872bad007da0475813a401a49Timo Sirainendone
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenfor f in $FILES_VBOXSF_BIN; do
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxsf/`echo $f|cut -d'>' -f2`"
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainendone
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# Only temporary, omit from archive
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainenrm $PATH_TMP/version-generated.h
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# Create the archive
2a734f36105e33ab452d057df6bc7a2b7d9f96f0Timo Sirainentar -czf $FILE_OUT -C $PATH_TMP . || exit 1
2a734f36105e33ab452d057df6bc7a2b7d9f96f0Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen# Remove the temporary directory
2a734f36105e33ab452d057df6bc7a2b7d9f96f0Timo Sirainenrm -r $PATH_TMP
2a734f36105e33ab452d057df6bc7a2b7d9f96f0Timo Sirainen
0cb2e8eb55e70f8ebe1e8349bdf49e4cbe5d8834Timo Sirainen