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 | # available from http://www.virtualbox.org. This file is free software;
|
---|
9 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
10 | # General Public License (GPL) as published by the Free Software
|
---|
11 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
12 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
13 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
14 | #
|
---|
15 |
|
---|
16 | if [ -z "$1" ]; then
|
---|
17 | echo "Usage: $0 <filename.tar.gz> [--without-hardening]"
|
---|
18 | echo " Export VirtualBox kernel modules to <filename.tar.gz>"
|
---|
19 | exit 1
|
---|
20 | fi
|
---|
21 |
|
---|
22 | VBOX_WITH_HARDENING=1
|
---|
23 | if [ "$2" = "--without-hardening" ]; then
|
---|
24 | VBOX_WITH_HARDENING=
|
---|
25 | fi
|
---|
26 |
|
---|
27 | PATH_ROOT="`cd \`dirname $0\`/../../../..; pwd`"
|
---|
28 | PATH_LINUX="$PATH_ROOT/src/VBox/HostDrivers/linux"
|
---|
29 | PATH_VBOXDRV="$PATH_ROOT/src/VBox/HostDrivers/Support"
|
---|
30 | PATH_VBOXNET="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetFlt"
|
---|
31 | PATH_VBOXADP="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetAdp"
|
---|
32 | PATH_VBOXPCI="$PATH_ROOT/src/VBox/HostDrivers/VBoxPci"
|
---|
33 |
|
---|
34 | VBOX_VERSION_MAJOR=`sed -e "s/^ *VBOX_VERSION_MAJOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
|
---|
35 | VBOX_VERSION_MINOR=`sed -e "s/^ *VBOX_VERSION_MINOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
|
---|
36 | VBOX_VERSION_BUILD=`sed -e "s/^ *VBOX_VERSION_BUILD *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
|
---|
37 | VBOX_VERSION_STRING=$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD
|
---|
38 | 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`
|
---|
39 |
|
---|
40 | . $PATH_VBOXDRV/linux/files_vboxdrv
|
---|
41 | . $PATH_VBOXNET/linux/files_vboxnetflt
|
---|
42 | . $PATH_VBOXADP/linux/files_vboxnetadp
|
---|
43 | . $PATH_VBOXPCI/linux/files_vboxpci
|
---|
44 |
|
---|
45 | # Temporary path for creating the modules, will be removed later
|
---|
46 | mkdir $PATH_TMP || exit 1
|
---|
47 |
|
---|
48 | # Create auto-generated version file, needed by all modules
|
---|
49 | echo "#ifndef __version_generated_h__" > $PATH_TMP/version-generated.h
|
---|
50 | echo "#define __version_generated_h__" >> $PATH_TMP/version-generated.h
|
---|
51 | echo "" >> $PATH_TMP/version-generated.h
|
---|
52 | echo "#define VBOX_VERSION_MAJOR $VBOX_VERSION_MAJOR" >> $PATH_TMP/version-generated.h
|
---|
53 | echo "#define VBOX_VERSION_MINOR $VBOX_VERSION_MINOR" >> $PATH_TMP/version-generated.h
|
---|
54 | echo "#define VBOX_VERSION_BUILD $VBOX_VERSION_BUILD" >> $PATH_TMP/version-generated.h
|
---|
55 | echo "#define VBOX_VERSION_STRING \"$VBOX_VERSION_STRING\"" >> $PATH_TMP/version-generated.h
|
---|
56 | echo "" >> $PATH_TMP/version-generated.h
|
---|
57 | echo "#endif" >> $PATH_TMP/version-generated.h
|
---|
58 |
|
---|
59 | # Create auto-generated revision file, needed by all modules
|
---|
60 | echo "#ifndef __revision_generated_h__" > $PATH_TMP/revision-generated.h
|
---|
61 | echo "#define __revision_generated_h__" >> $PATH_TMP/revision-generated.h
|
---|
62 | echo "" >> $PATH_TMP/revision-generated.h
|
---|
63 | echo "#define VBOX_SVN_REV $VBOX_SVN_REV" >> $PATH_TMP/revision-generated.h
|
---|
64 | echo "" >> $PATH_TMP/revision-generated.h
|
---|
65 | echo "#endif" >> $PATH_TMP/revision-generated.h
|
---|
66 |
|
---|
67 | # Create auto-generated product file, needed by all modules
|
---|
68 | echo "#ifndef __product_generated_h__" > $PATH_TMP/product-generated.h
|
---|
69 | echo "#define __product_generated_h__" >> $PATH_TMP/product-generated.h
|
---|
70 | echo "" >> $PATH_TMP/product-generated.h
|
---|
71 | echo "#define VBOX_VENDOR \"$VBOX_VENDOR\"" >> $PATH_TMP/product-generated.h
|
---|
72 | echo "#define VBOX_VENDOR_SHORT \"$VBOX_VENDOR_SHORT\"" >> $PATH_TMP/product-generated.h
|
---|
73 | echo "" >> $PATH_TMP/product-generated.h
|
---|
74 | echo "#define VBOX_PRODUCT \"$VBOX_PRODUCT\"" >> $PATH_TMP/product-generated.h
|
---|
75 | echo "#define VBOX_C_YEAR \"$VBOX_C_YEAR\"" >> $PATH_TMP/product-generated.h
|
---|
76 | echo "" >> $PATH_TMP/product-generated.h
|
---|
77 | echo "#endif" >> $PATH_TMP/product-generated.h
|
---|
78 |
|
---|
79 | # vboxdrv (VirtualBox host kernel module)
|
---|
80 | mkdir $PATH_TMP/vboxdrv || exit 1
|
---|
81 | for f in $FILES_VBOXDRV_NOBIN; do
|
---|
82 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`"
|
---|
83 | done
|
---|
84 | for f in $FILES_VBOXDRV_BIN; do
|
---|
85 | install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`"
|
---|
86 | done
|
---|
87 | sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXDRV/linux/dkms.conf > $PATH_TMP/vboxdrv/dkms.conf
|
---|
88 | if [ -n "$VBOX_WITH_HARDENING" ]; then
|
---|
89 | cat $PATH_VBOXDRV/linux/Makefile > $PATH_TMP/vboxdrv/Makefile
|
---|
90 | else
|
---|
91 | sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXDRV/linux/Makefile > $PATH_TMP/vboxdrv/Makefile
|
---|
92 | fi
|
---|
93 |
|
---|
94 | # vboxnetflt (VirtualBox netfilter kernel module)
|
---|
95 | mkdir $PATH_TMP/vboxnetflt || exit 1
|
---|
96 | for f in $VBOX_VBOXNETFLT_SOURCES; do
|
---|
97 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxnetflt/`echo $f|cut -d'>' -f2`"
|
---|
98 | done
|
---|
99 | sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXNET/linux/dkms.conf > $PATH_TMP/vboxnetflt/dkms.conf
|
---|
100 | if [ -n "$VBOX_WITH_HARDENING" ]; then
|
---|
101 | cat $PATH_VBOXNET/linux/Makefile > $PATH_TMP/vboxnetflt/Makefile
|
---|
102 | else
|
---|
103 | sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXNET/linux/Makefile > $PATH_TMP/vboxnetflt/Makefile
|
---|
104 | fi
|
---|
105 |
|
---|
106 | # vboxnetadp (VirtualBox network adapter kernel module)
|
---|
107 | mkdir $PATH_TMP/vboxnetadp || exit 1
|
---|
108 | for f in $VBOX_VBOXNETADP_SOURCES; do
|
---|
109 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxnetadp/`echo $f|cut -d'>' -f2`"
|
---|
110 | done
|
---|
111 | sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXADP/linux/dkms.conf > $PATH_TMP/vboxnetadp/dkms.conf
|
---|
112 | if [ -n "$VBOX_WITH_HARDENING" ]; then
|
---|
113 | cat $PATH_VBOXADP/linux/Makefile > $PATH_TMP/vboxnetadp/Makefile
|
---|
114 | else
|
---|
115 | sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXADP/linux/Makefile > $PATH_TMP/vboxnetadp/Makefile
|
---|
116 | fi
|
---|
117 |
|
---|
118 | # vboxpci (VirtualBox host PCI access kernel module)
|
---|
119 | mkdir $PATH_TMP/vboxpci || exit 1
|
---|
120 | for f in $VBOX_VBOXPCI_SOURCES; do
|
---|
121 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxpci/`echo $f|cut -d'>' -f2`"
|
---|
122 | done
|
---|
123 | sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXPCI/linux/dkms.conf > $PATH_TMP/vboxpci/dkms.conf
|
---|
124 | if [ -n "$VBOX_WITH_HARDENING" ]; then
|
---|
125 | cat $PATH_VBOXPCI/linux/Makefile > $PATH_TMP/vboxpci/Makefile
|
---|
126 | else
|
---|
127 | sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXPCI/linux/Makefile > $PATH_TMP/vboxpci/Makefile
|
---|
128 | fi
|
---|
129 |
|
---|
130 | install -D -m 0644 $PATH_LINUX/Makefile $PATH_TMP/Makefile
|
---|
131 | install -D -m 0755 $PATH_LINUX/build_in_tmp $PATH_TMP/build_in_tmp
|
---|
132 |
|
---|
133 | # Only temporary, omit from archive
|
---|
134 | rm $PATH_TMP/version-generated.h
|
---|
135 | rm $PATH_TMP/revision-generated.h
|
---|
136 | rm $PATH_TMP/product-generated.h
|
---|
137 |
|
---|
138 | # Create the archive
|
---|
139 | tar -czf $FILE_OUT -C $PATH_TMP . || exit 1
|
---|
140 |
|
---|
141 | # Remove the temporary directory
|
---|
142 | rm -r $PATH_TMP
|
---|