VirtualBox

source: vbox/trunk/src/VBox/Additions/linux/export_modules.sh@ 106476

Last change on this file since 106476 was 106061, checked in by vboxsync, 3 months ago

Copyright year updates by scm.

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

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette