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