VirtualBox

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

Last change on this file since 78326 was 76553, checked in by vboxsync, 6 years ago

scm --update-copyright-year

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
File size: 6.3 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-2019 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_REV=`sed -e 's/^ *VBOX_SVN_REV_FALLBACK *:= \+\$(patsubst *%:,, *\$Rev: *\([0-9]\+\) *\$ *) */\1/;t;d' $PATH_ROOT/Config.kmk`
50VBOX_VENDOR=`sed -e 's/^ *VBOX_VENDOR *= \+\(.\+\)/\1/;t;d' $PATH_ROOT/Config.kmk`
51VBOX_VENDOR_SHORT=`sed -e 's/^ *VBOX_VENDOR_SHORT *= \+\(.\+\)/\1/;t;d' $PATH_ROOT/Config.kmk`
52VBOX_PRODUCT=`sed -e 's/^ *VBOX_PRODUCT *= \+\(.\+\)/\1/;t;d' $PATH_ROOT/Config.kmk`
53VBOX_C_YEAR=`date +%Y`
54
55. $PATH_VBOXGUEST/linux/files_vboxguest
56. $PATH_VBOXSF/files_vboxsf
57. $PATH_VBOXVIDEO/files_vboxvideo_drv
58
59# Temporary path for creating the modules, will be removed later
60mkdir -p $PATH_OUT || exit 1
61
62# Create auto-generated version file, needed by all modules
63echo "#ifndef ___version_generated_h___" > $PATH_OUT/version-generated.h
64echo "#define ___version_generated_h___" >> $PATH_OUT/version-generated.h
65echo "" >> $PATH_OUT/version-generated.h
66echo "#define VBOX_VERSION_MAJOR $VBOX_VERSION_MAJOR" >> $PATH_OUT/version-generated.h
67echo "#define VBOX_VERSION_MINOR $VBOX_VERSION_MINOR" >> $PATH_OUT/version-generated.h
68echo "#define VBOX_VERSION_BUILD $VBOX_VERSION_BUILD" >> $PATH_OUT/version-generated.h
69echo "#define VBOX_VERSION_STRING_RAW \"$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD\"" >> $PATH_OUT/version-generated.h
70echo "#define VBOX_VERSION_STRING \"$VBOX_VERSION_MAJOR.$VBOX_VERSION_MINOR.$VBOX_VERSION_BUILD\"" >> $PATH_OUT/version-generated.h
71echo "#define VBOX_API_VERSION_STRING \"${VBOX_VERSION_MAJOR}_${VBOX_VERSION_MINOR}\"" >> $PATH_OUT/version-generated.h
72echo "#define VBOX_PRIVATE_BUILD_DESC \"Private build with export_modules\"" >> $PATH_OUT/version-generated.h
73echo "" >> $PATH_OUT/version-generated.h
74echo "#endif" >> $PATH_OUT/version-generated.h
75
76# Create auto-generated revision file, needed by all modules
77echo "#ifndef __revision_generated_h__" > $PATH_OUT/revision-generated.h
78echo "#define __revision_generated_h__" >> $PATH_OUT/revision-generated.h
79echo "" >> $PATH_OUT/revision-generated.h
80echo "#define VBOX_SVN_REV $VBOX_SVN_REV" >> $PATH_OUT/revision-generated.h
81echo "" >> $PATH_OUT/revision-generated.h
82echo "#endif" >> $PATH_OUT/revision-generated.h
83
84# Create auto-generated product file, needed by all modules
85echo "#ifndef ___product_generated_h___" > $PATH_OUT/product-generated.h
86echo "#define ___product_generated_h___" >> $PATH_OUT/product-generated.h
87echo "" >> $PATH_OUT/product-generated.h
88echo "#define VBOX_VENDOR \"$VBOX_VENDOR\"" >> $PATH_OUT/product-generated.h
89echo "#define VBOX_VENDOR_SHORT \"$VBOX_VENDOR_SHORT\"" >> $PATH_OUT/product-generated.h
90echo "" >> $PATH_OUT/product-generated.h
91echo "#define VBOX_PRODUCT \"$VBOX_PRODUCT\"" >> $PATH_OUT/product-generated.h
92echo "#define VBOX_C_YEAR \"$VBOX_C_YEAR\"" >> $PATH_OUT/product-generated.h
93echo "" >> $PATH_OUT/product-generated.h
94echo "#endif" >> $PATH_OUT/product-generated.h
95
96# vboxguest (VirtualBox guest kernel module)
97mkdir $PATH_OUT/vboxguest || exit 1
98for f in $FILES_VBOXGUEST_NOBIN; do
99 install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_OUT/vboxguest/`echo $f|cut -d'>' -f2`"
100done
101for f in $FILES_VBOXGUEST_BIN; do
102 install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_OUT/vboxguest/`echo $f|cut -d'>' -f2`"
103done
104
105# vboxsf (VirtualBox guest kernel module for shared folders)
106mkdir $PATH_OUT/vboxsf || exit 1
107for f in $FILES_VBOXSF_NOBIN; do
108 install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_OUT/vboxsf/`echo $f|cut -d'>' -f2`"
109done
110for f in $FILES_VBOXSF_BIN; do
111 install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_OUT/vboxsf/`echo $f|cut -d'>' -f2`"
112done
113
114# vboxvideo (VirtualBox guest kernel module for drm support)
115mkdir $PATH_OUT/vboxvideo || exit 1
116for f in $FILES_VBOXVIDEO_DRM_NOBIN; do
117 install -D -m 0644 `echo $f|cut -d'=' -f1` "$PATH_OUT/vboxvideo/`echo $f|cut -d'>' -f2`"
118done
119for f in $FILES_VBOXVIDEO_DRM_BIN; do
120 install -D -m 0755 `echo $f|cut -d'=' -f1` "$PATH_OUT/vboxvideo/`echo $f|cut -d'>' -f2`"
121done
122sed -f $PATH_VBOXVIDEO/indent.sed -i $PATH_OUT/vboxvideo/*.[ch]
123
124# convenience Makefile
125install -D -m 0644 $PATH_LINUX/Makefile "$PATH_OUT/Makefile"
126
127# Only temporary, omit from archive
128rm $PATH_OUT/version-generated.h
129rm $PATH_OUT/revision-generated.h
130rm $PATH_OUT/product-generated.h
131
132# If we are exporting to a folder then stop now.
133test "x${1}" = x--folder && exit 0
134
135# Do a test build
136echo Doing a test build, this may take a while.
137make -C $PATH_OUT > $PATH_LOG 2>&1 &&
138 make -C $PATH_OUT clean >> $PATH_LOG 2>&1 ||
139 echo "Warning: test build failed. Please check $PATH_LOG"
140
141# Create the archive
142tar -czf $FILE_OUT -C $PATH_OUT . || exit 1
143
144# Remove the temporary directory
145rm -r $PATH_OUT
146
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