VirtualBox

source: vbox/trunk/src/VBox/HostDrivers/linux/build_in_tmp@ 96811

Last change on this file since 96811 was 96407, checked in by vboxsync, 2 years ago

scm copyright and license note update

  • Property svn:eol-style set to LF
  • Property svn:executable set to *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.8 KB
Line 
1#!/bin/sh
2# $Id: build_in_tmp 96407 2022-08-22 17:43:14Z vboxsync $
3## @file
4# Script to build a kernel module in /tmp.
5#
6# Useful if the module sources are installed in read-only directory.
7#
8
9#
10# Copyright (C) 2007-2022 Oracle and/or its affiliates.
11#
12# This file is part of VirtualBox base platform packages, as
13# available from https://www.virtualbox.org.
14#
15# This program is free software; you can redistribute it and/or
16# modify it under the terms of the GNU General Public License
17# as published by the Free Software Foundation, in version 3 of the
18# License.
19#
20# This program is distributed in the hope that it will be useful, but
21# WITHOUT ANY WARRANTY; without even the implied warranty of
22# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
23# General Public License for more details.
24#
25# You should have received a copy of the GNU General Public License
26# along with this program; if not, see <https://www.gnu.org/licenses>.
27#
28# The contents of this file may alternatively be used under the terms
29# of the Common Development and Distribution License Version 1.0
30# (CDDL), a copy of it is provided in the "COPYING.CDDL" file included
31# in the VirtualBox distribution, in which case the provisions of the
32# CDDL are applicable instead of those of the GPL.
33#
34# You may elect to license modified versions of this file under the
35# terms and conditions of either the GPL or the CDDL or both.
36#
37# SPDX-License-Identifier: GPL-3.0-only OR CDDL-1.0
38#
39
40# find a unique temp directory
41num=0
42while true; do
43 tmpdir="/tmp/vbox.$num"
44 if mkdir -m 0755 "$tmpdir" 2> /dev/null; then
45 break
46 fi
47 num=`expr $num + 1`
48 if [ $num -gt 200 ]; then
49 echo "Could not find a valid tmp directory"
50 exit 1
51 fi
52done
53
54# Guest optimal number of make jobs.
55MAKE_JOBS=`grep vendor_id /proc/cpuinfo | wc -l`
56if [ "${MAKE_JOBS}" -le "0" ]; then MAKE_JOBS=1; fi
57
58# Parse our arguments, anything we don't grok is for make.
59while true; do
60 if [ "$1" = "--save-module-symvers" ]; then
61 shift
62 SAVE_MOD_SYMVERS="$1"
63 shift
64 elif [ "$1" = "--use-module-symvers" ]; then
65 shift
66 USE_MOD_SYMVERS="$1"
67 shift
68 elif [ "$1" = "--module-source" ]; then
69 shift
70 MODULE_SOURCE="$1"
71 shift
72 else
73 break
74 fi
75done
76
77# copy
78if [ -n "$MODULE_SOURCE" ]; then
79 cp -a "$MODULE_SOURCE"/* $tmpdir/
80else
81 cp -a ${0%/*}/* $tmpdir/
82fi
83if [ -n "$USE_MOD_SYMVERS" ]; then
84 cp $USE_MOD_SYMVERS $tmpdir/Module.symvers
85 MAKE_EXTRAOPTS="KBUILD_EXTRA_SYMBOLS=$tmpdir/Module.symvers"
86fi
87
88# make, cleanup if success
89cd "$tmpdir"
90if make "-j`echo ${MAKE_JOBS}`" "$@" ${MAKE_EXTRAOPTS}; then # strip leading space from "MAKE_JOBS"
91 if [ -n "$SAVE_MOD_SYMVERS" ]; then
92 if [ -f Module.symvers ]; then
93 cp -f Module.symvers $SAVE_MOD_SYMVERS
94 else
95 cat /dev/null > $SAVE_MOD_SYMVERS
96 fi
97 fi
98 rm -rf $tmpdir
99 exit 0
100fi
101
102# failure
103rm -rf $tmpdir
104exit 1
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