1 | #!/bin/sh
|
---|
2 |
|
---|
3 | #
|
---|
4 | # Create a tar archive containing the sources of the vboxdrv kernel module
|
---|
5 | #
|
---|
6 | # Copyright (C) 2007 Oracle Corporation
|
---|
7 | #
|
---|
8 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | # available from http://www.virtualbox.org. This file is free software;
|
---|
10 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | # General Public License (GPL) as published by the Free Software
|
---|
12 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | #
|
---|
16 |
|
---|
17 | if [ -z "$1" ]; then
|
---|
18 | echo "Usage: $0 <filename.tar.gz> [--without-hardening]"
|
---|
19 | echo " Export VirtualBox kernel modules to <filename.tar.gz>"
|
---|
20 | exit 1
|
---|
21 | fi
|
---|
22 |
|
---|
23 | VBOX_WITH_HARDENING=1
|
---|
24 | if [ "$2" = "--without-hardening" ]; then
|
---|
25 | VBOX_WITH_HARDENING=
|
---|
26 | fi
|
---|
27 |
|
---|
28 | PATH_TMP="`cd \`dirname $1\`; pwd`/.vbox_modules"
|
---|
29 | PATH_OUT=$PATH_TMP
|
---|
30 | FILE_OUT="`cd \`dirname $1\`; pwd`/`basename $1`"
|
---|
31 | PATH_ROOT="`cd \`dirname $0\`/../../../..; pwd`"
|
---|
32 | PATH_FREEBSD="$PATH_ROOT/src/VBox/HostDrivers/freebsd"
|
---|
33 | PATH_VBOXDRV="$PATH_ROOT/src/VBox/HostDrivers/Support"
|
---|
34 | PATH_VBOXNET="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetFlt"
|
---|
35 | PATH_VBOXNETADP="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetAdp"
|
---|
36 |
|
---|
37 | VBOX_VERSION_MAJOR=`sed -e "s/^ *VBOX_VERSION_MAJOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
|
---|
38 | VBOX_VERSION_MINOR=`sed -e "s/^ *VBOX_VERSION_MINOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
|
---|
39 | VBOX_VERSION_BUILD=`sed -e "s/^ *VBOX_VERSION_BUILD *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
|
---|
40 | VBOX_VERSION_STRING=$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD
|
---|
41 |
|
---|
42 | . $PATH_VBOXDRV/freebsd/files_vboxdrv
|
---|
43 | . $PATH_VBOXNET/freebsd/files_vboxnetflt
|
---|
44 | . $PATH_VBOXNETADP/freebsd/files_vboxnetadp
|
---|
45 |
|
---|
46 | # Temporary path for creating the modules, will be removed later
|
---|
47 | mkdir $PATH_TMP || exit 1
|
---|
48 |
|
---|
49 | # Create auto-generated version file, needed by all modules
|
---|
50 | echo "#ifndef __version_generated_h__" > $PATH_TMP/version-generated.h
|
---|
51 | echo "#define __version_generated_h__" >> $PATH_TMP/version-generated.h
|
---|
52 | echo "" >> $PATH_TMP/version-generated.h
|
---|
53 | echo "#define VBOX_VERSION_MAJOR $VBOX_VERSION_MAJOR" >> $PATH_TMP/version-generated.h
|
---|
54 | echo "#define VBOX_VERSION_MINOR $VBOX_VERSION_MINOR" >> $PATH_TMP/version-generated.h
|
---|
55 | echo "#define VBOX_VERSION_BUILD $VBOX_VERSION_BUILD" >> $PATH_TMP/version-generated.h
|
---|
56 | echo "#define VBOX_VERSION_STRING \"$VBOX_VERSION_STRING\"" >> $PATH_TMP/version-generated.h
|
---|
57 | echo "" >> $PATH_TMP/version-generated.h
|
---|
58 | echo "#endif" >> $PATH_TMP/version-generated.h
|
---|
59 |
|
---|
60 | # vboxdrv (VirtualBox host kernel module)
|
---|
61 | mkdir $PATH_TMP/vboxdrv || exit 1
|
---|
62 | for f in $FILES_VBOXDRV_NOBIN; do
|
---|
63 | install -d -m 755 "$PATH_TMP/vboxdrv/`dirname $f|cut -d'>' -f2`"
|
---|
64 | install -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`"
|
---|
65 | done
|
---|
66 | for f in $FILES_VBOXDRV_BIN; do
|
---|
67 | install -m 0755 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`"
|
---|
68 | done
|
---|
69 | sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_FREEBSD/build_in_tmp > $PATH_TMP/vboxdrv/build_in_tmp
|
---|
70 | if [ -n "$VBOX_WITH_HARDENING" ]; then
|
---|
71 | cat $PATH_VBOXDRV/freebsd/Makefile > $PATH_TMP/vboxdrv/Makefile
|
---|
72 | else
|
---|
73 | sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXDRV/freebsd/Makefile > $PATH_TMP/vboxdrv/Makefile
|
---|
74 | fi
|
---|
75 |
|
---|
76 | # vboxnetflt (VirtualBox netfilter kernel module)
|
---|
77 | mkdir $PATH_TMP/vboxnetflt || exit 1
|
---|
78 | for f in $VBOX_VBOXNETFLT_SOURCES; do
|
---|
79 | install -d -m 755 "$PATH_TMP/vboxnetflt/`dirname $f|cut -d'>' -f2`"
|
---|
80 | install -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxnetflt/`echo $f|cut -d'>' -f2`"
|
---|
81 | done
|
---|
82 | sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_FREEBSD/build_in_tmp > $PATH_TMP/vboxnetflt/build_in_tmp
|
---|
83 | if [ -n "$VBOX_WITH_HARDENING" ]; then
|
---|
84 | cat $PATH_VBOXNET/freebsd/Makefile > $PATH_TMP/vboxnetflt/Makefile
|
---|
85 | else
|
---|
86 | sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXNET/freebsd/Makefile > $PATH_TMP/vboxnetflt/Makefile
|
---|
87 | fi
|
---|
88 |
|
---|
89 | # vboxnetadp (VirtualBox network adapter kernel module)
|
---|
90 | mkdir $PATH_TMP/vboxnetadp || exit 1
|
---|
91 | for f in $VBOX_VBOXNETADP_SOURCES; do
|
---|
92 | install -d -m 755 "$PATH_TMP/vboxnetadp/`dirname $f|cut -d'>' -f2`"
|
---|
93 | install -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxnetadp/`echo $f|cut -d'>' -f2`"
|
---|
94 | done
|
---|
95 | sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_FREEBSD/build_in_tmp > $PATH_TMP/vboxnetadp/build_in_tmp
|
---|
96 | if [ -n "$VBOX_WITH_HARDENING" ]; then
|
---|
97 | cat $PATH_VBOXNETADP/freebsd/Makefile > $PATH_TMP/vboxnetadp/Makefile
|
---|
98 | else
|
---|
99 | sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXNETADP/freebsd/Makefile > $PATH_TMP/vboxnetadp/Makefile
|
---|
100 | fi
|
---|
101 |
|
---|
102 | install -m 0644 $PATH_FREEBSD/Makefile $PATH_TMP/Makefile
|
---|
103 |
|
---|
104 | # Only temporary, omit from archive
|
---|
105 | rm $PATH_TMP/version-generated.h
|
---|
106 |
|
---|
107 | # Create the archive
|
---|
108 | tar -czf $FILE_OUT -C $PATH_TMP . || exit 1
|
---|
109 |
|
---|
110 | # Remove the temporary directory
|
---|
111 | rm -r $PATH_TMP
|
---|
112 |
|
---|