VirtualBox

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

Last change on this file since 78374 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 *
  • Property svn:keywords set to Author Date Id Revision
File size: 2.4 KB
Line 
1#!/bin/sh
2# $Id: build_in_tmp 76553 2019-01-01 01:45:53Z 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-2019 Oracle Corporation
11#
12# This file is part of VirtualBox Open Source Edition (OSE), as
13# available from http://www.virtualbox.org. This file is free software;
14# you can redistribute it and/or modify it under the terms of the GNU
15# General Public License (GPL) as published by the Free Software
16# Foundation, in version 2 as it comes in the "COPYING" file of the
17# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
18# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
19#
20# The contents of this file may alternatively be used under the terms
21# of the Common Development and Distribution License Version 1.0
22# (CDDL) only, as it comes in the "COPYING.CDDL" file of the
23# VirtualBox OSE distribution, in which case the provisions of the
24# CDDL are applicable instead of those of the GPL.
25#
26# You may elect to license modified versions of this file under the
27# terms and conditions of either the GPL or the CDDL or both.
28#
29
30# find a unique temp directory
31num=0
32while true; do
33 tmpdir="/tmp/vbox.$num"
34 if mkdir -m 0755 "$tmpdir" 2> /dev/null; then
35 break
36 fi
37 num=`expr $num + 1`
38 if [ $num -gt 200 ]; then
39 echo "Could not find a valid tmp directory"
40 exit 1
41 fi
42done
43
44# Guest optimal number of make jobs.
45MAKE_JOBS=`grep vendor_id /proc/cpuinfo | wc -l`
46if [ "${MAKE_JOBS}" -le "0" ]; then MAKE_JOBS=1; fi
47
48# Parse our arguments, anything we don't grok is for make.
49while true; do
50 if [ "$1" = "--save-module-symvers" ]; then
51 shift
52 SAVE_MOD_SYMVERS="$1"
53 shift
54 elif [ "$1" = "--use-module-symvers" ]; then
55 shift
56 USE_MOD_SYMVERS="$1"
57 shift
58 elif [ "$1" = "--module-source" ]; then
59 shift
60 MODULE_SOURCE="$1"
61 shift
62 else
63 break
64 fi
65done
66
67# copy
68if [ -n "$MODULE_SOURCE" ]; then
69 cp -a "$MODULE_SOURCE"/* $tmpdir/
70else
71 cp -a ${0%/*}/* $tmpdir/
72fi
73if [ -n "$USE_MOD_SYMVERS" ]; then
74 cp $USE_MOD_SYMVERS $tmpdir/Module.symvers
75fi
76
77# make, cleanup if success
78cd "$tmpdir"
79if make "-j`echo ${MAKE_JOBS}`" "$@"; then # strip leading space from "MAKE_JOBS"
80 if [ -n "$SAVE_MOD_SYMVERS" ]; then
81 if [ -f Module.symvers ]; then
82 cp -f Module.symvers $SAVE_MOD_SYMVERS
83 else
84 cat /dev/null > $SAVE_MOD_SYMVERS
85 fi
86 fi
87 rm -rf $tmpdir
88 exit 0
89fi
90
91# failure
92rm -rf $tmpdir
93exit 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