build_in_tmp revision 3bf4bd3347c2bc3bc7c6b24672096f514235ad76
341N/A#!/bin/sh
341N/A
341N/A#
341N/A# Script to build a kernel module in /tmp. Useful if the module sources
851N/A# are installed in read-only directory.
851N/A#
341N/A# Copyright (C) 2007 InnoTek Systemberatung GmbH
341N/A#
919N/A# This file is part of VirtualBox Open Source Edition (OSE), as
919N/A# available from http://www.virtualbox.org. This file is free software;
919N/A# you can redistribute it and/or modify it under the terms of the GNU
919N/A# General Public License as published by the Free Software Foundation,
919N/A# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
919N/A# distribution. VirtualBox OSE is distributed in the hope that it will
919N/A# be useful, but WITHOUT ANY WARRANTY of any kind.
919N/A#
919N/A# If you received this file as part of a commercial VirtualBox
919N/A# distribution, then only the terms of your commercial VirtualBox
919N/A# license agreement apply instead of the previous paragraph.
919N/A#
919N/A
919N/A# find a unique temp directory
919N/Anum=0
919N/Awhile true; do
919N/A tmpdir="/tmp/vbox.$num"
341N/A if mkdir -m 0755 "$tmpdir" 2> /dev/null; then
341N/A break
341N/A fi
341N/A num=`expr $num + 1`
341N/A if [ $num -gt 200 ]; then
341N/A echo "Could not find a valid tmp directory"
341N/A exit 1
341N/A fi
341N/Adone
341N/A
341N/A# copy
341N/Acp -a ${0%/*}/* $tmpdir/
341N/A
341N/A# make, cleanup if success
341N/Acd "$tmpdir"
341N/Aif make "$@"; then
341N/A rm -rf $tmpdir
341N/A exit 0
341N/Afi
341N/A
341N/A# failure
341N/Aexit 1
341N/A