VirtualBox

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

Last change on this file since 89088 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

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