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_ROOT="`cd \`dirname $0\`/../../../..; pwd`"
|
---|
29 | PATH_LINUX="$PATH_ROOT/src/VBox/HostDrivers/linux"
|
---|
30 | PATH_VBOXDRV="$PATH_ROOT/src/VBox/HostDrivers/Support"
|
---|
31 | PATH_VBOXNET="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetFlt"
|
---|
32 | PATH_VBOXADP="$PATH_ROOT/src/VBox/HostDrivers/VBoxNetAdp"
|
---|
33 | PATH_VBOXPCI="$PATH_ROOT/src/VBox/HostDrivers/VBoxPci"
|
---|
34 |
|
---|
35 | VBOX_VERSION_MAJOR=`sed -e "s/^ *VBOX_VERSION_MAJOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
|
---|
36 | VBOX_VERSION_MINOR=`sed -e "s/^ *VBOX_VERSION_MINOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
|
---|
37 | VBOX_VERSION_BUILD=`sed -e "s/^ *VBOX_VERSION_BUILD *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Config.kmk`
|
---|
38 | VBOX_VERSION_STRING=$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD
|
---|
39 | 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`
|
---|
40 |
|
---|
41 | . $PATH_VBOXDRV/linux/files_vboxdrv
|
---|
42 | . $PATH_VBOXNET/linux/files_vboxnetflt
|
---|
43 | . $PATH_VBOXADP/linux/files_vboxnetadp
|
---|
44 | . $PATH_VBOXPCI/linux/files_vboxpci
|
---|
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 | # Create auto-generated revision file, needed by all modules
|
---|
61 | echo "#ifndef __revision_generated_h__" > $PATH_TMP/revision-generated.h
|
---|
62 | echo "#define __revision_generated_h__" >> $PATH_TMP/revision-generated.h
|
---|
63 | echo "" >> $PATH_TMP/revision-generated.h
|
---|
64 | echo "#define VBOX_SVN_REV $VBOX_SVN_REV" >> $PATH_TMP/revision-generated.h
|
---|
65 | echo "" >> $PATH_TMP/revision-generated.h
|
---|
66 | echo "#endif" >> $PATH_TMP/revision-generated.h
|
---|
67 |
|
---|
68 | # Create auto-generated product file, needed by all modules
|
---|
69 | echo "#ifndef __product_generated_h__" > $PATH_TMP/product-generated.h
|
---|
70 | echo "#define __product_generated_h__" >> $PATH_TMP/product-generated.h
|
---|
71 | echo "" >> $PATH_TMP/product-generated.h
|
---|
72 | echo "#define VBOX_VENDOR \"$VBOX_VENDOR\"" >> $PATH_TMP/product-generated.h
|
---|
73 | echo "#define VBOX_VENDOR_SHORT \"$VBOX_VENDOR_SHORT\"" >> $PATH_TMP/product-generated.h
|
---|
74 | echo "" >> $PATH_TMP/product-generated.h
|
---|
75 | echo "#define VBOX_PRODUCT \"$VBOX_PRODUCT\"" >> $PATH_TMP/product-generated.h
|
---|
76 | echo "#define VBOX_C_YEAR \"$VBOX_C_YEAR\"" >> $PATH_TMP/product-generated.h
|
---|
77 | echo "" >> $PATH_TMP/product-generated.h
|
---|
78 | echo "#endif" >> $PATH_TMP/product-generated.h
|
---|
79 |
|
---|
80 | # vboxdrv (VirtualBox host kernel module)
|
---|
81 | mkdir $PATH_TMP/vboxdrv || exit 1
|
---|
82 | for f in $FILES_VBOXDRV_NOBIN; do
|
---|
83 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`"
|
---|
84 | done
|
---|
85 | for f in $FILES_VBOXDRV_BIN; do
|
---|
86 | install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxdrv/`echo $f|cut -d'>' -f2`"
|
---|
87 | done
|
---|
88 | sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXDRV/linux/dkms.conf > $PATH_TMP/vboxdrv/dkms.conf
|
---|
89 | if [ -n "$VBOX_WITH_HARDENING" ]; then
|
---|
90 | cat $PATH_VBOXDRV/linux/Makefile > $PATH_TMP/vboxdrv/Makefile
|
---|
91 | else
|
---|
92 | sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXDRV/linux/Makefile > $PATH_TMP/vboxdrv/Makefile
|
---|
93 | fi
|
---|
94 |
|
---|
95 | # vboxnetflt (VirtualBox netfilter kernel module)
|
---|
96 | mkdir $PATH_TMP/vboxnetflt || exit 1
|
---|
97 | for f in $VBOX_VBOXNETFLT_SOURCES; do
|
---|
98 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxnetflt/`echo $f|cut -d'>' -f2`"
|
---|
99 | done
|
---|
100 | sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXNET/linux/dkms.conf > $PATH_TMP/vboxnetflt/dkms.conf
|
---|
101 | if [ -n "$VBOX_WITH_HARDENING" ]; then
|
---|
102 | cat $PATH_VBOXNET/linux/Makefile > $PATH_TMP/vboxnetflt/Makefile
|
---|
103 | else
|
---|
104 | sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXNET/linux/Makefile > $PATH_TMP/vboxnetflt/Makefile
|
---|
105 | fi
|
---|
106 |
|
---|
107 | # vboxnetadp (VirtualBox network adapter kernel module)
|
---|
108 | mkdir $PATH_TMP/vboxnetadp || exit 1
|
---|
109 | for f in $VBOX_VBOXNETADP_SOURCES; do
|
---|
110 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxnetadp/`echo $f|cut -d'>' -f2`"
|
---|
111 | done
|
---|
112 | sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXADP/linux/dkms.conf > $PATH_TMP/vboxnetadp/dkms.conf
|
---|
113 | if [ -n "$VBOX_WITH_HARDENING" ]; then
|
---|
114 | cat $PATH_VBOXADP/linux/Makefile > $PATH_TMP/vboxnetadp/Makefile
|
---|
115 | else
|
---|
116 | sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXADP/linux/Makefile > $PATH_TMP/vboxnetadp/Makefile
|
---|
117 | fi
|
---|
118 |
|
---|
119 | # vboxpci (VirtualBox host PCI access kernel module)
|
---|
120 | mkdir $PATH_TMP/vboxpci || exit 1
|
---|
121 | for f in $VBOX_VBOXPCI_SOURCES; do
|
---|
122 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxpci/`echo $f|cut -d'>' -f2`"
|
---|
123 | done
|
---|
124 | sed -e "s;_VERSION_;$VBOX_VERSION_STRING;g" < $PATH_VBOXPCI/linux/dkms.conf > $PATH_TMP/vboxpci/dkms.conf
|
---|
125 | if [ -n "$VBOX_WITH_HARDENING" ]; then
|
---|
126 | cat $PATH_VBOXPCI/linux/Makefile > $PATH_TMP/vboxpci/Makefile
|
---|
127 | else
|
---|
128 | sed -e "s;-DVBOX_WITH_HARDENING;;g" < $PATH_VBOXPCI/linux/Makefile > $PATH_TMP/vboxpci/Makefile
|
---|
129 | fi
|
---|
130 |
|
---|
131 | install -D -m 0644 $PATH_LINUX/Makefile $PATH_TMP/Makefile
|
---|
132 | install -D -m 0755 $PATH_LINUX/build_in_tmp $PATH_TMP/build_in_tmp
|
---|
133 |
|
---|
134 | # Only temporary, omit from archive
|
---|
135 | rm $PATH_TMP/version-generated.h
|
---|
136 | rm $PATH_TMP/revision-generated.h
|
---|
137 | rm $PATH_TMP/product-generated.h
|
---|
138 |
|
---|
139 | # Create the archive
|
---|
140 | tar -czf $FILE_OUT -C $PATH_TMP . || exit 1
|
---|
141 |
|
---|
142 | # Remove the temporary directory
|
---|
143 | rm -r $PATH_TMP
|
---|