1 | #!/bin/sh
|
---|
2 |
|
---|
3 | #
|
---|
4 | # Create a tar archive containing the sources of the vboxdrv kernel module
|
---|
5 | #
|
---|
6 | # Copyright (C) 2007-2012 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_LINUX="$PATH_ROOT/src/VBox/HostDrivers/linux"
|
---|
33 | PATH_VBOXDRV="$PATH_ROOT/src/VBox/HostDrivers/Support"
|
---|
34 | PATH_VBOXNET="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetFlt"
|
---|
35 | PATH_VBOXADP="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetAdp"
|
---|
36 | PATH_VBOXPCI="$PATH_ROOT/src/VBox/HostDrivers/VBoxPci"
|
---|
37 |
|
---|
38 | VBOX_VERSION_MAJOR=`sed -e "s/^ *VBOX_VERSION_MAJOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
|
---|
39 | VBOX_VERSION_MINOR=`sed -e "s/^ *VBOX_VERSION_MINOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
|
---|
40 | VBOX_VERSION_BUILD=`sed -e "s/^ *VBOX_VERSION_BUILD *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
|
---|
41 | VBOX_VERSION_STRING=$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD
|
---|
42 | VBOX_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`
|
---|
43 |
|
---|
44 | . $PATH_VBOXDRV/linux/files_vboxdrv
|
---|
45 | . $PATH_VBOXNET/linux/files_vboxnetflt
|
---|
46 | . $PATH_VBOXADP/linux/files_vboxnetadp
|
---|
47 | . $PATH_VBOXPCI/linux/files_vboxpci
|
---|
48 |
|
---|
49 | # Temporary path for creating the modules, will be removed later
|
---|
50 | mkdir $PATH_TMP || exit 1
|
---|
51 |
|
---|
52 | # Create auto-generated version file, needed by all modules
|
---|
53 | echo "#ifndef ___version_generated_h___" > $PATH_TMP/version-generated.h
|
---|
54 | echo "#define ___version_generated_h___" >> $PATH_TMP/version-generated.h
|
---|
55 | echo "" >> $PATH_TMP/version-generated.h
|
---|
56 | echo "#define VBOX_VERSION_MAJOR $VBOX_VERSION_MAJOR" >> $PATH_TMP/version-generated.h
|
---|
57 | echo "#define VBOX_VERSION_MINOR $VBOX_VERSION_MINOR" >> $PATH_TMP/version-generated.h
|
---|
58 | echo "#define VBOX_VERSION_BUILD $VBOX_VERSION_BUILD" >> $PATH_TMP/version-generated.h
|
---|
59 | echo "#define VBOX_VERSION_STRING_RAW \"$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD\"" >> $PATH_TMP/version-generated.h
|
---|
60 | echo "#define VBOX_VERSION_STRING \"$VBOX_VERSION_STRING\"" >> $PATH_TMP/version-generated.h
|
---|
61 | echo "#define VBOX_API_VERSION_STRING \"${VBOX_VERSION_MAJOR}_${VBOX_VERSION_MINOR}\"" >> $PATH_TMP/version-generated.h
|
---|
62 | echo "" >> $PATH_TMP/version-generated.h
|
---|
63 | echo "#endif" >> $PATH_TMP/version-generated.h
|
---|
64 |
|
---|
65 | # Create auto-generated revision file, needed by all modules
|
---|
66 | echo "#ifndef __revision_generated_h__" > $PATH_TMP/revision-generated.h
|
---|
67 | echo "#define __revision_generated_h__" >> $PATH_TMP/revision-generated.h
|
---|
68 | echo "" >> $PATH_TMP/revision-generated.h
|
---|
69 | echo "#define VBOX_SVN_REV $VBOX_SVN_REV" >> $PATH_TMP/revision-generated.h
|
---|
70 | echo "" >> $PATH_TMP/revision-generated.h
|
---|
71 | echo "#endif" >> $PATH_TMP/revision-generated.h
|
---|
72 |
|
---|
73 | # Create auto-generated product file, needed by all modules
|
---|
74 | echo "#ifndef ___product_generated_h___" > $PATH_TMP/product-generated.h
|
---|
75 | echo "#define ___product_generated_h___" >> $PATH_TMP/product-generated.h
|
---|
76 | echo "" >> $PATH_TMP/product-generated.h
|
---|
77 | echo "#define VBOX_VENDOR \"$VBOX_VENDOR\"" >> $PATH_TMP/product-generated.h
|
---|
78 | echo "#define VBOX_VENDOR_SHORT \"$VBOX_VENDOR_SHORT\"" >> $PATH_TMP/product-generated.h
|
---|
79 | echo "" >> $PATH_TMP/product-generated.h
|
---|
80 | echo "#define VBOX_PRODUCT \"$VBOX_PRODUCT\"" >> $PATH_TMP/product-generated.h
|
---|
81 | echo "#define VBOX_C_YEAR \"$VBOX_C_YEAR\"" >> $PATH_TMP/product-generated.h
|
---|
82 | echo "" >> $PATH_TMP/product-generated.h
|
---|
83 | echo "#endif" >> $PATH_TMP/product-generated.h
|
---|
84 |
|
---|
85 | # vboxdrv (VirtualBox host kernel module)
|
---|
86 | mkdir $PATH_TMP/vboxdrv || exit 1
|
---|
87 | for f in $FILES_VBOXDRV_NOBIN; do
|
---|
88 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`"
|
---|
89 | done
|
---|
90 | for f in $FILES_VBOXDRV_BIN; do
|
---|
91 | install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`"
|
---|
92 | done
|
---|
93 | if [ -n "$VBOX_WITH_HARDENING" ]; then
|
---|
94 | cat $PATH_VBOXDRV/linux/Makefile > $PATH_TMP/vboxdrv/Makefile
|
---|
95 | else
|
---|
96 | sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXDRV/linux/Makefile > $PATH_TMP/vboxdrv/Makefile
|
---|
97 | fi
|
---|
98 |
|
---|
99 | # vboxnetflt (VirtualBox netfilter kernel module)
|
---|
100 | mkdir $PATH_TMP/vboxnetflt || exit 1
|
---|
101 | for f in $VBOX_VBOXNETFLT_SOURCES; do
|
---|
102 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxnetflt/`echo $f|cut -d'>' -f2`"
|
---|
103 | done
|
---|
104 | if [ -n "$VBOX_WITH_HARDENING" ]; then
|
---|
105 | cat $PATH_VBOXNET/linux/Makefile > $PATH_TMP/vboxnetflt/Makefile
|
---|
106 | else
|
---|
107 | sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXNET/linux/Makefile > $PATH_TMP/vboxnetflt/Makefile
|
---|
108 | fi
|
---|
109 |
|
---|
110 | # vboxnetadp (VirtualBox network adapter kernel module)
|
---|
111 | mkdir $PATH_TMP/vboxnetadp || exit 1
|
---|
112 | for f in $VBOX_VBOXNETADP_SOURCES; do
|
---|
113 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxnetadp/`echo $f|cut -d'>' -f2`"
|
---|
114 | done
|
---|
115 | if [ -n "$VBOX_WITH_HARDENING" ]; then
|
---|
116 | cat $PATH_VBOXADP/linux/Makefile > $PATH_TMP/vboxnetadp/Makefile
|
---|
117 | else
|
---|
118 | sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXADP/linux/Makefile > $PATH_TMP/vboxnetadp/Makefile
|
---|
119 | fi
|
---|
120 |
|
---|
121 | # vboxpci (VirtualBox host PCI access kernel module)
|
---|
122 | mkdir $PATH_TMP/vboxpci || exit 1
|
---|
123 | for f in $VBOX_VBOXPCI_SOURCES; do
|
---|
124 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxpci/`echo $f|cut -d'>' -f2`"
|
---|
125 | done
|
---|
126 | if [ -n "$VBOX_WITH_HARDENING" ]; then
|
---|
127 | cat $PATH_VBOXPCI/linux/Makefile > $PATH_TMP/vboxpci/Makefile
|
---|
128 | else
|
---|
129 | sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXPCI/linux/Makefile > $PATH_TMP/vboxpci/Makefile
|
---|
130 | fi
|
---|
131 |
|
---|
132 | install -D -m 0644 $PATH_LINUX/Makefile $PATH_TMP/Makefile
|
---|
133 | install -D -m 0755 $PATH_LINUX/build_in_tmp $PATH_TMP/build_in_tmp
|
---|
134 |
|
---|
135 | # Only temporary, omit from archive
|
---|
136 | rm $PATH_TMP/version-generated.h
|
---|
137 | rm $PATH_TMP/revision-generated.h
|
---|
138 | rm $PATH_TMP/product-generated.h
|
---|
139 |
|
---|
140 | # Create the archive
|
---|
141 | tar -czf $FILE_OUT -C $PATH_TMP . || exit 1
|
---|
142 |
|
---|
143 | # Remove the temporary directory
|
---|
144 | rm -r $PATH_TMP
|
---|