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-2023 Oracle and/or its affiliates.
|
---|
9 | #
|
---|
10 | # This file is part of VirtualBox base platform packages, as
|
---|
11 | # available from https://www.virtualbox.org.
|
---|
12 | #
|
---|
13 | # This program is free software; you can redistribute it and/or
|
---|
14 | # modify it under the terms of the GNU General Public License
|
---|
15 | # as published by the Free Software Foundation, in version 3 of the
|
---|
16 | # License.
|
---|
17 | #
|
---|
18 | # This program is distributed in the hope that it will be useful, but
|
---|
19 | # WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
20 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
21 | # General Public License for more details.
|
---|
22 | #
|
---|
23 | # You should have received a copy of the GNU General Public License
|
---|
24 | # along with this program; if not, see <https://www.gnu.org/licenses>.
|
---|
25 | #
|
---|
26 | # SPDX-License-Identifier: GPL-3.0-only
|
---|
27 | #
|
---|
28 |
|
---|
29 | export LC_ALL=C
|
---|
30 |
|
---|
31 | # The below is GNU-specific. See VBox.sh for the longer Solaris/OS X version.
|
---|
32 | TARGET=`readlink -e -- "${0}"` || exit 1
|
---|
33 | MY_DIR="${TARGET%/[!/]*}"
|
---|
34 |
|
---|
35 | if [ -z "${1}" ] || { [ "x${1}" = x--folder ] && [ -z "${2}" ]; }; then
|
---|
36 | echo "Usage: $0 <filename.tar.gz>"
|
---|
37 | echo " Export VirtualBox kernel modules to <filename.tar.gz>."
|
---|
38 | echo "Usage: $0 --folder <folder>"
|
---|
39 | echo " Copy VirtualBox kernel module source to <folder>."
|
---|
40 | exit 1
|
---|
41 | fi
|
---|
42 |
|
---|
43 | if test "x${1}" = x--folder; then
|
---|
44 | PATH_OUT="${2}"
|
---|
45 | else
|
---|
46 | PATH_OUT="`cd \`dirname $1\`; pwd`/.vbox_modules"
|
---|
47 | FILE_OUT="`cd \`dirname $1\`; pwd`/`basename $1`"
|
---|
48 | fi
|
---|
49 | PATH_ROOT="`cd ${MY_DIR}/../../../..; pwd`"
|
---|
50 | PATH_LOG=/tmp/vbox-export-guest.log
|
---|
51 | PATH_LINUX="$PATH_ROOT/src/VBox/Additions/linux"
|
---|
52 | PATH_VBOXGUEST="$PATH_ROOT/src/VBox/Additions/common/VBoxGuest"
|
---|
53 | PATH_VBOXSF="$PATH_ROOT/src/VBox/Additions/linux/sharedfolders"
|
---|
54 | PATH_VBOXVIDEO="$PATH_ROOT/src/VBox/Additions/linux/drm"
|
---|
55 |
|
---|
56 | VBOX_VERSION_MAJOR=`sed -e "s/^ *VBOX_VERSION_MAJOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Version.kmk`
|
---|
57 | VBOX_VERSION_MINOR=`sed -e "s/^ *VBOX_VERSION_MINOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Version.kmk`
|
---|
58 | VBOX_VERSION_BUILD=`sed -e "s/^ *VBOX_VERSION_BUILD *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Version.kmk`
|
---|
59 | VBOX_SVN_CONFIG_REV=`sed -e 's/^ *VBOX_SVN_REV_CONFIG_FALLBACK *:= \+\$(patsubst *%:,, *\$Rev: *\([0-9]\+\) *\$ *) */\1/;t;d' $PATH_ROOT/Config.kmk`
|
---|
60 | VBOX_SVN_VERSION_REV=`sed -e 's/^ *VBOX_SVN_REV_VERSION_FALLBACK *:= \+\$(patsubst *%:,, *\$Rev: *\([0-9]\+\) *\$ *) */\1/;t;d' $PATH_ROOT/Version.kmk`
|
---|
61 | if [ "$VBOX_SVN_CONFIG_REV" -gt "$VBOX_SVN_VERSION_REV" ]; then
|
---|
62 | VBOX_SVN_REV=$VBOX_SVN_CONFIG_REV
|
---|
63 | else
|
---|
64 | VBOX_SVN_REV=$VBOX_SVN_VERSION_REV
|
---|
65 | fi
|
---|
66 | VBOX_VENDOR=`sed -e 's/^ *VBOX_VENDOR *= \+\(.\+\)/\1/;t;d' $PATH_ROOT/Config.kmk`
|
---|
67 | VBOX_VENDOR_SHORT=`sed -e 's/^ *VBOX_VENDOR_SHORT *= \+\(.\+\)/\1/;t;d' $PATH_ROOT/Config.kmk`
|
---|
68 | VBOX_PRODUCT=`sed -e 's/^ *VBOX_PRODUCT *= \+\(.\+\)/\1/;t;d' $PATH_ROOT/Config.kmk`
|
---|
69 | VBOX_C_YEAR=`date +%Y`
|
---|
70 |
|
---|
71 | . $PATH_VBOXGUEST/linux/files_vboxguest
|
---|
72 | . $PATH_VBOXSF/files_vboxsf
|
---|
73 | . $PATH_VBOXVIDEO/files_vboxvideo_drv
|
---|
74 |
|
---|
75 | # Temporary path for creating the modules, will be removed later
|
---|
76 | mkdir -p $PATH_OUT || exit 1
|
---|
77 |
|
---|
78 | # Create auto-generated version file, needed by all modules
|
---|
79 | echo "#ifndef ___version_generated_h___" > $PATH_OUT/version-generated.h
|
---|
80 | echo "#define ___version_generated_h___" >> $PATH_OUT/version-generated.h
|
---|
81 | echo "" >> $PATH_OUT/version-generated.h
|
---|
82 | echo "#define VBOX_VERSION_MAJOR $VBOX_VERSION_MAJOR" >> $PATH_OUT/version-generated.h
|
---|
83 | echo "#define VBOX_VERSION_MINOR $VBOX_VERSION_MINOR" >> $PATH_OUT/version-generated.h
|
---|
84 | echo "#define VBOX_VERSION_BUILD $VBOX_VERSION_BUILD" >> $PATH_OUT/version-generated.h
|
---|
85 | echo "#define VBOX_VERSION_STRING_RAW \"$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD\"" >> $PATH_OUT/version-generated.h
|
---|
86 | echo "#define VBOX_VERSION_STRING \"$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD\"" >> $PATH_OUT/version-generated.h
|
---|
87 | echo "#define VBOX_API_VERSION_STRING \"${VBOX_VERSION_MAJOR}_${VBOX_VERSION_MINOR}\"" >> $PATH_OUT/version-generated.h
|
---|
88 | echo "#define VBOX_PRIVATE_BUILD_DESC \"Private build with export_modules\"" >> $PATH_OUT/version-generated.h
|
---|
89 | echo "" >> $PATH_OUT/version-generated.h
|
---|
90 | echo "#endif" >> $PATH_OUT/version-generated.h
|
---|
91 |
|
---|
92 | # Create auto-generated revision file, needed by all modules
|
---|
93 | echo "#ifndef __revision_generated_h__" > $PATH_OUT/revision-generated.h
|
---|
94 | echo "#define __revision_generated_h__" >> $PATH_OUT/revision-generated.h
|
---|
95 | echo "" >> $PATH_OUT/revision-generated.h
|
---|
96 | echo "#define VBOX_SVN_REV $VBOX_SVN_REV" >> $PATH_OUT/revision-generated.h
|
---|
97 | echo "" >> $PATH_OUT/revision-generated.h
|
---|
98 | echo "#endif" >> $PATH_OUT/revision-generated.h
|
---|
99 |
|
---|
100 | # Create auto-generated product file, needed by all modules
|
---|
101 | echo "#ifndef ___product_generated_h___" > $PATH_OUT/product-generated.h
|
---|
102 | echo "#define ___product_generated_h___" >> $PATH_OUT/product-generated.h
|
---|
103 | echo "" >> $PATH_OUT/product-generated.h
|
---|
104 | echo "#define VBOX_VENDOR \"$VBOX_VENDOR\"" >> $PATH_OUT/product-generated.h
|
---|
105 | echo "#define VBOX_VENDOR_SHORT \"$VBOX_VENDOR_SHORT\"" >> $PATH_OUT/product-generated.h
|
---|
106 | echo "" >> $PATH_OUT/product-generated.h
|
---|
107 | echo "#define VBOX_PRODUCT \"$VBOX_PRODUCT\"" >> $PATH_OUT/product-generated.h
|
---|
108 | echo "#define VBOX_C_YEAR \"$VBOX_C_YEAR\"" >> $PATH_OUT/product-generated.h
|
---|
109 | echo "" >> $PATH_OUT/product-generated.h
|
---|
110 | echo "#endif" >> $PATH_OUT/product-generated.h
|
---|
111 |
|
---|
112 | # vboxguest (VirtualBox guest kernel module)
|
---|
113 | mkdir $PATH_OUT/vboxguest || exit 1
|
---|
114 | for f in $FILES_VBOXGUEST_NOBIN; do
|
---|
115 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_OUT/vboxguest/`echo $f|cut -d'>' -f2`"
|
---|
116 | done
|
---|
117 | for f in $FILES_VBOXGUEST_BIN; do
|
---|
118 | install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_OUT/vboxguest/`echo $f|cut -d'>' -f2`"
|
---|
119 | done
|
---|
120 |
|
---|
121 | # vboxsf (VirtualBox guest kernel module for shared folders)
|
---|
122 | mkdir $PATH_OUT/vboxsf || exit 1
|
---|
123 | for f in $FILES_VBOXSF_NOBIN; do
|
---|
124 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_OUT/vboxsf/`echo $f|cut -d'>' -f2`"
|
---|
125 | done
|
---|
126 | for f in $FILES_VBOXSF_BIN; do
|
---|
127 | install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_OUT/vboxsf/`echo $f|cut -d'>' -f2`"
|
---|
128 | done
|
---|
129 |
|
---|
130 | # vboxvideo (VirtualBox guest kernel module for drm support)
|
---|
131 | mkdir $PATH_OUT/vboxvideo || exit 1
|
---|
132 | for f in $FILES_VBOXVIDEO_DRM_NOBIN; do
|
---|
133 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_OUT/vboxvideo/`echo $f|cut -d'>' -f2`"
|
---|
134 | done
|
---|
135 | for f in $FILES_VBOXVIDEO_DRM_BIN; do
|
---|
136 | install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_OUT/vboxvideo/`echo $f|cut -d'>' -f2`"
|
---|
137 | done
|
---|
138 | sed -f $PATH_VBOXVIDEO/indent.sed -i $PATH_OUT/vboxvideo/*.[ch]
|
---|
139 |
|
---|
140 | # convenience Makefile
|
---|
141 | install -D -m 0644 $PATH_LINUX/Makefile "$PATH_OUT/Makefile"
|
---|
142 |
|
---|
143 | # Only temporary, omit from archive
|
---|
144 | rm $PATH_OUT/version-generated.h
|
---|
145 | rm $PATH_OUT/revision-generated.h
|
---|
146 | rm $PATH_OUT/product-generated.h
|
---|
147 |
|
---|
148 | # If we are exporting to a folder then stop now.
|
---|
149 | test "x${1}" = x--folder && exit 0
|
---|
150 |
|
---|
151 | # Do a test build
|
---|
152 | echo Doing a test build, this may take a while.
|
---|
153 | make -C $PATH_OUT > $PATH_LOG 2>&1 &&
|
---|
154 | make -C $PATH_OUT clean >> $PATH_LOG 2>&1 ||
|
---|
155 | echo "Warning: test build failed. Please check $PATH_LOG"
|
---|
156 |
|
---|
157 | # Create the archive
|
---|
158 | tar -czf $FILE_OUT -C $PATH_OUT . || exit 1
|
---|
159 |
|
---|
160 | # Remove the temporary directory
|
---|
161 | rm -r $PATH_OUT
|
---|
162 |
|
---|