1 | #!/bin/sh
|
---|
2 | # $Id$
|
---|
3 | ## @file
|
---|
4 | # Create a tar archive containing the sources of the Linux guest kernel modules.
|
---|
5 | #
|
---|
6 |
|
---|
7 | #
|
---|
8 | # Copyright (C) 2006-2010 Oracle Corporation
|
---|
9 | #
|
---|
10 | # This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
11 | # available from http://www.virtualbox.org. This file is free software;
|
---|
12 | # you can redistribute it and/or modify it under the terms of the GNU
|
---|
13 | # General Public License (GPL) as published by the Free Software
|
---|
14 | # Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
15 | # VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
16 | # hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
17 | #
|
---|
18 |
|
---|
19 | # The below is GNU-specific. See VBox.sh for the longer Solaris/OS X version.
|
---|
20 | TARGET=`readlink -e -- "${0}"` || exit 1
|
---|
21 | MY_DIR="${TARGET%/[!/]*}"
|
---|
22 |
|
---|
23 | if [ -z "$1" ]; then
|
---|
24 | echo "Usage: $0 <filename.tar.gz>"
|
---|
25 | echo " Export VirtualBox kernel modules to <filename.tar.gz>"
|
---|
26 | exit 1
|
---|
27 | fi
|
---|
28 |
|
---|
29 | PATH_TMP="`cd \`dirname $1\`; pwd`/.vbox_modules"
|
---|
30 | PATH_OUT=$PATH_TMP
|
---|
31 | FILE_OUT="`cd \`dirname $1\`; pwd`/`basename $1`"
|
---|
32 | PATH_ROOT="`cd ${MY_DIR}/../../../..; pwd`"
|
---|
33 | PATH_LOG=/tmp/vbox-export-guest.log
|
---|
34 | PATH_LINUX="$PATH_ROOT/src/VBox/Additions/linux"
|
---|
35 | PATH_VBOXGUEST="$PATH_ROOT/src/VBox/Additions/common/VBoxGuest"
|
---|
36 | PATH_VBOXSF="$PATH_ROOT/src/VBox/Additions/linux/sharedfolders"
|
---|
37 | PATH_VBOXVIDEO="$PATH_ROOT/src/VBox/Additions/linux/drm"
|
---|
38 |
|
---|
39 | VBOX_VERSION_MAJOR=`sed -e "s/^ *VBOX_VERSION_MAJOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Version.kmk`
|
---|
40 | VBOX_VERSION_MINOR=`sed -e "s/^ *VBOX_VERSION_MINOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Version.kmk`
|
---|
41 | VBOX_VERSION_BUILD=`sed -e "s/^ *VBOX_VERSION_BUILD *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Version.kmk`
|
---|
42 | VBOX_SVN_REV=`sed -e 's/^ *VBOX_SVN_REV_FALLBACK *:= \+\$(patsubst *%:,, *\$Rev: *\([0-9]\+\) *\$ *) */\1/;t;d' $PATH_ROOT/Config.kmk`
|
---|
43 | VBOX_VENDOR=`sed -e 's/^ *VBOX_VENDOR *= \+\(.\+\)/\1/;t;d' $PATH_ROOT/Config.kmk`
|
---|
44 | VBOX_VENDOR_SHORT=`sed -e 's/^ *VBOX_VENDOR_SHORT *= \+\(.\+\)/\1/;t;d' $PATH_ROOT/Config.kmk`
|
---|
45 | VBOX_PRODUCT=`sed -e 's/^ *VBOX_PRODUCT *= \+\(.\+\)/\1/;t;d' $PATH_ROOT/Config.kmk`
|
---|
46 | VBOX_C_YEAR=`date +%Y`
|
---|
47 |
|
---|
48 | . $PATH_VBOXGUEST/linux/files_vboxguest
|
---|
49 | . $PATH_VBOXSF/files_vboxsf
|
---|
50 | . $PATH_VBOXVIDEO/files_vboxvideo_drv
|
---|
51 |
|
---|
52 | # Temporary path for creating the modules, will be removed later
|
---|
53 | mkdir $PATH_TMP || exit 1
|
---|
54 |
|
---|
55 | # Create auto-generated version file, needed by all modules
|
---|
56 | echo "#ifndef ___version_generated_h___" > $PATH_TMP/version-generated.h
|
---|
57 | echo "#define ___version_generated_h___" >> $PATH_TMP/version-generated.h
|
---|
58 | echo "" >> $PATH_TMP/version-generated.h
|
---|
59 | echo "#define VBOX_VERSION_MAJOR $VBOX_VERSION_MAJOR" >> $PATH_TMP/version-generated.h
|
---|
60 | echo "#define VBOX_VERSION_MINOR $VBOX_VERSION_MINOR" >> $PATH_TMP/version-generated.h
|
---|
61 | echo "#define VBOX_VERSION_BUILD $VBOX_VERSION_BUILD" >> $PATH_TMP/version-generated.h
|
---|
62 | echo "#define VBOX_VERSION_STRING_RAW \"$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD\"" >> $PATH_TMP/version-generated.h
|
---|
63 | echo "#define VBOX_VERSION_STRING \"$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD\"" >> $PATH_TMP/version-generated.h
|
---|
64 | echo "#define VBOX_API_VERSION_STRING \"${VBOX_VERSION_MAJOR}_${VBOX_VERSION_MINOR}\"" >> $PATH_TMP/version-generated.h
|
---|
65 | echo "#define VBOX_PRIVATE_BUILD_DESC \"Private build with export_modules\"" >> $PATH_TMP/version-generated.h
|
---|
66 | echo "" >> $PATH_TMP/version-generated.h
|
---|
67 | echo "#endif" >> $PATH_TMP/version-generated.h
|
---|
68 |
|
---|
69 | # Create auto-generated revision file, needed by all modules
|
---|
70 | echo "#ifndef __revision_generated_h__" > $PATH_TMP/revision-generated.h
|
---|
71 | echo "#define __revision_generated_h__" >> $PATH_TMP/revision-generated.h
|
---|
72 | echo "" >> $PATH_TMP/revision-generated.h
|
---|
73 | echo "#define VBOX_SVN_REV $VBOX_SVN_REV" >> $PATH_TMP/revision-generated.h
|
---|
74 | echo "" >> $PATH_TMP/revision-generated.h
|
---|
75 | echo "#endif" >> $PATH_TMP/revision-generated.h
|
---|
76 |
|
---|
77 | # Create auto-generated product file, needed by all modules
|
---|
78 | echo "#ifndef ___product_generated_h___" > $PATH_TMP/product-generated.h
|
---|
79 | echo "#define ___product_generated_h___" >> $PATH_TMP/product-generated.h
|
---|
80 | echo "" >> $PATH_TMP/product-generated.h
|
---|
81 | echo "#define VBOX_VENDOR \"$VBOX_VENDOR\"" >> $PATH_TMP/product-generated.h
|
---|
82 | echo "#define VBOX_VENDOR_SHORT \"$VBOX_VENDOR_SHORT\"" >> $PATH_TMP/product-generated.h
|
---|
83 | echo "" >> $PATH_TMP/product-generated.h
|
---|
84 | echo "#define VBOX_PRODUCT \"$VBOX_PRODUCT\"" >> $PATH_TMP/product-generated.h
|
---|
85 | echo "#define VBOX_C_YEAR \"$VBOX_C_YEAR\"" >> $PATH_TMP/product-generated.h
|
---|
86 | echo "" >> $PATH_TMP/product-generated.h
|
---|
87 | echo "#endif" >> $PATH_TMP/product-generated.h
|
---|
88 |
|
---|
89 | # vboxguest (VirtualBox guest kernel module)
|
---|
90 | mkdir $PATH_TMP/vboxguest || exit 1
|
---|
91 | for f in $FILES_VBOXGUEST_NOBIN; do
|
---|
92 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxguest/`echo $f|cut -d'>' -f2`"
|
---|
93 | done
|
---|
94 | for f in $FILES_VBOXGUEST_BIN; do
|
---|
95 | install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxguest/`echo $f|cut -d'>' -f2`"
|
---|
96 | done
|
---|
97 |
|
---|
98 | # vboxsf (VirtualBox guest kernel module for shared folders)
|
---|
99 | mkdir $PATH_TMP/vboxsf || exit 1
|
---|
100 | for f in $FILES_VBOXSF_NOBIN; do
|
---|
101 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxsf/`echo $f|cut -d'>' -f2`"
|
---|
102 | done
|
---|
103 | for f in $FILES_VBOXSF_BIN; do
|
---|
104 | install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxsf/`echo $f|cut -d'>' -f2`"
|
---|
105 | done
|
---|
106 |
|
---|
107 | # vboxvideo (VirtualBox guest kernel module for drm support)
|
---|
108 | mkdir $PATH_TMP/vboxvideo || exit 1
|
---|
109 | for f in $FILES_VBOXVIDEO_DRM_NOBIN; do
|
---|
110 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxvideo/`echo $f|cut -d'>' -f2`"
|
---|
111 | done
|
---|
112 | for f in $FILES_VBOXVIDEO_DRM_BIN; do
|
---|
113 | install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_TMP/vboxvideo/`echo $f|cut -d'>' -f2`"
|
---|
114 | done
|
---|
115 | sed -f $PATH_VBOXVIDEO/indent.sed -i $PATH_TMP/vboxvideo/*.[ch]
|
---|
116 |
|
---|
117 | # convenience Makefile
|
---|
118 | install -D -m 0644 $PATH_LINUX/Makefile "$PATH_TMP/Makefile"
|
---|
119 |
|
---|
120 | # Only temporary, omit from archive
|
---|
121 | rm $PATH_TMP/version-generated.h
|
---|
122 | rm $PATH_TMP/revision-generated.h
|
---|
123 | rm $PATH_TMP/product-generated.h
|
---|
124 |
|
---|
125 | # Do a test build
|
---|
126 | echo Doing a test build, this may take a while.
|
---|
127 | make -C $PATH_TMP > $PATH_LOG 2>&1 &&
|
---|
128 | make -C $PATH_TMP clean >> $PATH_LOG 2>&1 ||
|
---|
129 | echo "Warning: test build failed. Please check $PATH_LOG"
|
---|
130 |
|
---|
131 | # Create the archive
|
---|
132 | tar -czf $FILE_OUT -C $PATH_TMP . || exit 1
|
---|
133 |
|
---|
134 | # Remove the temporary directory
|
---|
135 | rm -r $PATH_TMP
|
---|
136 |
|
---|