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-2022 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 | export LC_ALL=C
|
---|
20 |
|
---|
21 | # The below is GNU-specific. See VBox.sh for the longer Solaris/OS X version.
|
---|
22 | TARGET=`readlink -e -- "${0}"` || exit 1
|
---|
23 | MY_DIR="${TARGET%/[!/]*}"
|
---|
24 |
|
---|
25 | if [ -z "${1}" ] || { [ "x${1}" = x--folder ] && [ -z "${2}" ]; }; then
|
---|
26 | echo "Usage: $0 <filename.tar.gz>"
|
---|
27 | echo " Export VirtualBox kernel modules to <filename.tar.gz>."
|
---|
28 | echo "Usage: $0 --folder <folder>"
|
---|
29 | echo " Copy VirtualBox kernel module source to <folder>."
|
---|
30 | exit 1
|
---|
31 | fi
|
---|
32 |
|
---|
33 | if test "x${1}" = x--folder; then
|
---|
34 | PATH_OUT="${2}"
|
---|
35 | else
|
---|
36 | PATH_OUT="`cd \`dirname $1\`; pwd`/.vbox_modules"
|
---|
37 | FILE_OUT="`cd \`dirname $1\`; pwd`/`basename $1`"
|
---|
38 | fi
|
---|
39 | PATH_ROOT="`cd ${MY_DIR}/../../../..; pwd`"
|
---|
40 | PATH_LOG=/tmp/vbox-export-guest.log
|
---|
41 | PATH_LINUX="$PATH_ROOT/src/VBox/Additions/linux"
|
---|
42 | PATH_VBOXGUEST="$PATH_ROOT/src/VBox/Additions/common/VBoxGuest"
|
---|
43 | PATH_VBOXSF="$PATH_ROOT/src/VBox/Additions/linux/sharedfolders"
|
---|
44 | PATH_VBOXVIDEO="$PATH_ROOT/src/VBox/Additions/linux/drm"
|
---|
45 |
|
---|
46 | VBOX_VERSION_MAJOR=`sed -e "s/^ *VBOX_VERSION_MAJOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Version.kmk`
|
---|
47 | VBOX_VERSION_MINOR=`sed -e "s/^ *VBOX_VERSION_MINOR *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Version.kmk`
|
---|
48 | VBOX_VERSION_BUILD=`sed -e "s/^ *VBOX_VERSION_BUILD *= \+\([0-9]\+\)/\1/;t;d" $PATH_ROOT/Version.kmk`
|
---|
49 | VBOX_SVN_CONFIG_REV=`sed -e 's/^ *VBOX_SVN_REV_CONFIG_FALLBACK *:= \+\$(patsubst *%:,, *\$Rev: *\([0-9]\+\) *\$ *) */\1/;t;d' $PATH_ROOT/Config.kmk`
|
---|
50 | VBOX_SVN_VERSION_REV=`sed -e 's/^ *VBOX_SVN_REV_VERSION_FALLBACK *:= \+\$(patsubst *%:,, *\$Rev: *\([0-9]\+\) *\$ *) */\1/;t;d' $PATH_ROOT/Version.kmk`
|
---|
51 | if [ "$VBOX_SVN_CONFIG_REV" -gt "$VBOX_SVN_VERSION_REV" ]; then
|
---|
52 | VBOX_SVN_REV=$VBOX_SVN_CONFIG_REV
|
---|
53 | else
|
---|
54 | VBOX_SVN_REV=$VBOX_SVN_VERSION_REV
|
---|
55 | fi
|
---|
56 | VBOX_VENDOR=`sed -e 's/^ *VBOX_VENDOR *= \+\(.\+\)/\1/;t;d' $PATH_ROOT/Config.kmk`
|
---|
57 | VBOX_VENDOR_SHORT=`sed -e 's/^ *VBOX_VENDOR_SHORT *= \+\(.\+\)/\1/;t;d' $PATH_ROOT/Config.kmk`
|
---|
58 | VBOX_PRODUCT=`sed -e 's/^ *VBOX_PRODUCT *= \+\(.\+\)/\1/;t;d' $PATH_ROOT/Config.kmk`
|
---|
59 | VBOX_C_YEAR=`date +%Y`
|
---|
60 |
|
---|
61 | . $PATH_VBOXGUEST/linux/files_vboxguest
|
---|
62 | . $PATH_VBOXSF/files_vboxsf
|
---|
63 | . $PATH_VBOXVIDEO/files_vboxvideo_drv
|
---|
64 |
|
---|
65 | # Temporary path for creating the modules, will be removed later
|
---|
66 | mkdir -p $PATH_OUT || exit 1
|
---|
67 |
|
---|
68 | # Create auto-generated version file, needed by all modules
|
---|
69 | echo "#ifndef ___version_generated_h___" > $PATH_OUT/version-generated.h
|
---|
70 | echo "#define ___version_generated_h___" >> $PATH_OUT/version-generated.h
|
---|
71 | echo "" >> $PATH_OUT/version-generated.h
|
---|
72 | echo "#define VBOX_VERSION_MAJOR $VBOX_VERSION_MAJOR" >> $PATH_OUT/version-generated.h
|
---|
73 | echo "#define VBOX_VERSION_MINOR $VBOX_VERSION_MINOR" >> $PATH_OUT/version-generated.h
|
---|
74 | echo "#define VBOX_VERSION_BUILD $VBOX_VERSION_BUILD" >> $PATH_OUT/version-generated.h
|
---|
75 | echo "#define VBOX_VERSION_STRING_RAW \"$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD\"" >> $PATH_OUT/version-generated.h
|
---|
76 | echo "#define VBOX_VERSION_STRING \"$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD\"" >> $PATH_OUT/version-generated.h
|
---|
77 | echo "#define VBOX_API_VERSION_STRING \"${VBOX_VERSION_MAJOR}_${VBOX_VERSION_MINOR}\"" >> $PATH_OUT/version-generated.h
|
---|
78 | echo "#define VBOX_PRIVATE_BUILD_DESC \"Private build with export_modules\"" >> $PATH_OUT/version-generated.h
|
---|
79 | echo "" >> $PATH_OUT/version-generated.h
|
---|
80 | echo "#endif" >> $PATH_OUT/version-generated.h
|
---|
81 |
|
---|
82 | # Create auto-generated revision file, needed by all modules
|
---|
83 | echo "#ifndef __revision_generated_h__" > $PATH_OUT/revision-generated.h
|
---|
84 | echo "#define __revision_generated_h__" >> $PATH_OUT/revision-generated.h
|
---|
85 | echo "" >> $PATH_OUT/revision-generated.h
|
---|
86 | echo "#define VBOX_SVN_REV $VBOX_SVN_REV" >> $PATH_OUT/revision-generated.h
|
---|
87 | echo "" >> $PATH_OUT/revision-generated.h
|
---|
88 | echo "#endif" >> $PATH_OUT/revision-generated.h
|
---|
89 |
|
---|
90 | # Create auto-generated product file, needed by all modules
|
---|
91 | echo "#ifndef ___product_generated_h___" > $PATH_OUT/product-generated.h
|
---|
92 | echo "#define ___product_generated_h___" >> $PATH_OUT/product-generated.h
|
---|
93 | echo "" >> $PATH_OUT/product-generated.h
|
---|
94 | echo "#define VBOX_VENDOR \"$VBOX_VENDOR\"" >> $PATH_OUT/product-generated.h
|
---|
95 | echo "#define VBOX_VENDOR_SHORT \"$VBOX_VENDOR_SHORT\"" >> $PATH_OUT/product-generated.h
|
---|
96 | echo "" >> $PATH_OUT/product-generated.h
|
---|
97 | echo "#define VBOX_PRODUCT \"$VBOX_PRODUCT\"" >> $PATH_OUT/product-generated.h
|
---|
98 | echo "#define VBOX_C_YEAR \"$VBOX_C_YEAR\"" >> $PATH_OUT/product-generated.h
|
---|
99 | echo "" >> $PATH_OUT/product-generated.h
|
---|
100 | echo "#endif" >> $PATH_OUT/product-generated.h
|
---|
101 |
|
---|
102 | # vboxguest (VirtualBox guest kernel module)
|
---|
103 | mkdir $PATH_OUT/vboxguest || exit 1
|
---|
104 | for f in $FILES_VBOXGUEST_NOBIN; do
|
---|
105 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_OUT/vboxguest/`echo $f|cut -d'>' -f2`"
|
---|
106 | done
|
---|
107 | for f in $FILES_VBOXGUEST_BIN; do
|
---|
108 | install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_OUT/vboxguest/`echo $f|cut -d'>' -f2`"
|
---|
109 | done
|
---|
110 |
|
---|
111 | # vboxsf (VirtualBox guest kernel module for shared folders)
|
---|
112 | mkdir $PATH_OUT/vboxsf || exit 1
|
---|
113 | for f in $FILES_VBOXSF_NOBIN; do
|
---|
114 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_OUT/vboxsf/`echo $f|cut -d'>' -f2`"
|
---|
115 | done
|
---|
116 | for f in $FILES_VBOXSF_BIN; do
|
---|
117 | install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_OUT/vboxsf/`echo $f|cut -d'>' -f2`"
|
---|
118 | done
|
---|
119 |
|
---|
120 | # vboxvideo (VirtualBox guest kernel module for drm support)
|
---|
121 | mkdir $PATH_OUT/vboxvideo || exit 1
|
---|
122 | for f in $FILES_VBOXVIDEO_DRM_NOBIN; do
|
---|
123 | install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_OUT/vboxvideo/`echo $f|cut -d'>' -f2`"
|
---|
124 | done
|
---|
125 | for f in $FILES_VBOXVIDEO_DRM_BIN; do
|
---|
126 | install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_OUT/vboxvideo/`echo $f|cut -d'>' -f2`"
|
---|
127 | done
|
---|
128 | sed -f $PATH_VBOXVIDEO/indent.sed -i $PATH_OUT/vboxvideo/*.[ch]
|
---|
129 |
|
---|
130 | # convenience Makefile
|
---|
131 | install -D -m 0644 $PATH_LINUX/Makefile "$PATH_OUT/Makefile"
|
---|
132 |
|
---|
133 | # Only temporary, omit from archive
|
---|
134 | rm $PATH_OUT/version-generated.h
|
---|
135 | rm $PATH_OUT/revision-generated.h
|
---|
136 | rm $PATH_OUT/product-generated.h
|
---|
137 |
|
---|
138 | # If we are exporting to a folder then stop now.
|
---|
139 | test "x${1}" = x--folder && exit 0
|
---|
140 |
|
---|
141 | # Do a test build
|
---|
142 | echo Doing a test build, this may take a while.
|
---|
143 | make -C $PATH_OUT > $PATH_LOG 2>&1 &&
|
---|
144 | make -C $PATH_OUT clean >> $PATH_LOG 2>&1 ||
|
---|
145 | echo "Warning: test build failed. Please check $PATH_LOG"
|
---|
146 |
|
---|
147 | # Create the archive
|
---|
148 | tar -czf $FILE_OUT -C $PATH_OUT . || exit 1
|
---|
149 |
|
---|
150 | # Remove the temporary directory
|
---|
151 | rm -r $PATH_OUT
|
---|
152 |
|
---|