slackbuilds_ponce/system/virtualbox-ose/virtualbox-ose.SlackBuild
Heinz Wiesinger 7949f262c6 system/virtualbox-ose: Updated for version 3.2.6.
Signed-off-by: Robby Workman <rworkman@slackbuilds.org>
2010-07-21 01:43:05 -05:00

209 lines
6.4 KiB
Bash

#!/bin/sh
# Slackware build script for virtualbox-ose
# Copyright 2008-2010 Heinz Wiesinger, Amsterdam, The Netherlands
# Copyright 2008 Mauro Giachero <mauro.giachero@gmail.com>
# All rights reserved.
#
# Redistribution and use of this script, with or without modification, is
# permitted provided that the following conditions are met:
#
# 1. Redistributions of this script must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ''AS IS'' AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
PRGNAM=virtualbox-ose
SRCNAM=VirtualBox
VERSION=3.2.6
ARCH=${ARCH:-i486}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
# kmk doesn't support MAKEFLAGS, so we use JOBS here
JOBS=${JOBS:-3}
# Define Variable Names
qtgui=""
# Check for vboxusers group here
if ! grep ^vboxusers: /etc/group 2>&1 > /dev/null; then
echo " You must have a vboxusers group to run this script."
echo " # groupadd -g 215 vboxusers"
exit 1
fi
# Enable Hardening - Defaulting to yes as requested by upstream
if [ "${HARDENING:-yes}" = "yes" ]; then
harden="--enable-hardening"
else
harden="--disable-hardening"
fi
if [ "${WEBSERVICE:-no}" = "yes" ]; then
web_service="--enable-webservice"
vboxwebsrv="vboxwebsrv"
else
web_service=""
vboxwebsrv=""
fi
if [ "$ARCH" = "i486" ]; then
SLKCFLAGS="-O2 -march=i486 -mtune=i686"
LIBDIRSUFFIX=""
BUILDDIR="x86"
elif [ "$ARCH" = "i686" ]; then
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
LIBDIRSUFFIX=""
BUILDDIR="x86"
elif [ "$ARCH" = "x86_64" ]; then
SLKCFLAGS="-O2 -fPIC"
LIBDIRSUFFIX="64"
BUILDDIR="amd64"
fi
set -e
rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $SRCNAM-${VERSION}_OSE
tar xvf $CWD/$SRCNAM-${VERSION}-OSE.tar.bz2
cd $SRCNAM-${VERSION}_OSE
chown -R root:root .
chmod -R u+w,go+r-w,a-s .
GROUP="vboxusers"
MODE="750"
mkdir -p $PKG/lib/udev/rules.d
echo 'KERNEL=="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="vboxusers", MODE="0660"' \
> $PKG/lib/udev/rules.d/60-vboxdrv.rules
# We don't want a init-script building kernel modules.
# Use virtualbox-kernel.SlackBuild for this.
patch -d src/VBox/Installer/linux -i $CWD/vboxdrv.sh-setup.diff
# Support for the qt4-frontend
if [ "${QT4:-yes}" = "yes" ]; then
mkdir -p $PKG/usr/share/applications
cp -f src/VBox/Installer/linux/virtualbox.desktop $PKG/usr/share/applications/
sed -i "s|\$VBOX_DOC_PATH|/usr/share/virtualbox|" \
$PKG/usr/share/applications/virtualbox.desktop
guiapp="VirtualBox"
else
qtgui+=" --disable-qt4"
guiapp=""
fi
# Fix issues with newer acpica versions
patch -p0 -i $CWD/patch-src-VBox-Devices-PC-vbox.dsl
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./configure \
--ose \
--disable-kmods \
--disable-pulse \
$web_service \
$harden \
$qtgui
. ./env.sh
cp $CWD/LocalConfig.kmk .
sed -i "s|LIBDIR|lib$LIBDIRSUFFIX|" ./LocalConfig.kmk
kmk -j ${JOBS} LOCALCFG=./LocalConfig.kmk
mkdir -p $PKG/usr/{lib$LIBDIRSUFFIX,share,include}/virtualbox \
$PKG/usr/{bin,src} \
$PKG/usr/share/pixmaps \
$PKG/etc/{default,rc.d,vbox}
cp -f src/VBox/Installer/linux/vboxdrv.sh.in $PKG/etc/rc.d/rc.vboxdrv.new
sed -i "s/%PACKAGE%/virtualbox/g" $PKG/etc/rc.d/rc.vboxdrv.new
sed -i "s/%NOLSB%/yes/" $PKG/etc/rc.d/rc.vboxdrv.new
sed -i "s/%DEBIAN%/no/" $PKG/etc/rc.d/rc.vboxdrv.new
sed -i "s/\[ -z \"\$DEBIAN\"/#\[ -z \"\$DEBIAN\"/" $PKG/etc/rc.d/rc.vboxdrv.new
cp -f $CWD/vbox.cfg $PKG/etc/vbox/vbox.cfg.new
sed -i "s|LIBDIR|lib$LIBDIRSUFFIX|" $PKG/etc/vbox/vbox.cfg.new
cp -f $CWD/virtualbox.default $PKG/etc/default/virtualbox.new
cd out/linux.$BUILDDIR/release/bin/
rm -f vboxdrv.ko virtualbox.desktop
mv VBox.png $PKG/usr/share/pixmaps/
mv src $PKG/usr/src/virtualbox-kernel-$VERSION
mv sdk $PKG/usr/share/virtualbox/
if [ "${QT4:-yes}" = "yes" ]; then
mv nls* *.tar.bz2 $PKG/usr/share/virtualbox/
fi
install -m $MODE -g $GROUP VBoxSysInfo.sh $PKG/usr/share/virtualbox/
install -m $MODE -g $GROUP VBoxTunctl $PKG/usr/bin/
rm -f VoxSysInfo.sh VBoxTunctl
mv * $PKG/usr/lib$LIBDIRSUFFIX/virtualbox/
chown -R root:$GROUP $PKG/usr/lib$LIBDIRSUFFIX/virtualbox/
chmod -R $MODE $PKG/usr/lib$LIBDIRSUFFIX/virtualbox/
mv $PKG/usr/lib$LIBDIRSUFFIX/virtualbox/VBox.sh $PKG/usr/lib$LIBDIRSUFFIX/virtualbox/VBox
cd -
for i in VBoxManage VBoxSDL VBoxHeadless VBoxVRDP $guiapp $vboxwebsrv; do
ln -s /usr/lib$LIBDIRSUFFIX/virtualbox/VBox $PKG/usr/bin/$i ;
done
if [ "$harden" = "--enable-hardening" ]; then
for i in VBoxSDL VBoxHeadless $guiapp; do
chmod 4${MODE} $PKG/usr/lib$LIBDIRSUFFIX/virtualbox/$i
done
fi
# install headers. Needed by some third party tools
cp -rf include/* $PKG/usr/include/virtualbox/
rm -f $PKG/usr/include/virtualbox/Makefile.kmk
cp -f $CWD/VBoxGuestAdditions_$VERSION.iso \
$PKG/usr/share/virtualbox/VBoxGuestAdditions.iso
cp -f $CWD/UserManual.pdf \
$PKG/usr/share/virtualbox/UserManual.pdf
# install profile.d scripts for 3rd party apps
mkdir -p $PKG/etc/profile.d/
cat << EOF > $PKG/etc/profile.d/vbox.csh
#!/bin/csh
setenv VBOX_PROGRAM_PATH /usr/lib${LIBDIRSUFFIX}/virtualbox/
setenv VBOX_SDK_PATH /usr/share/virtualbox/sdk/
EOF
cat << EOF > $PKG/etc/profile.d/vbox.sh
#!/bin/sh
export VBOX_PROGRAM_PATH=/usr/lib${LIBDIRSUFFIX}/virtualbox/
export VBOX_SDK_PATH=/usr/share/virtualbox/sdk/
EOF
chmod 0755 $PKG/etc/profile.d/*
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -f COPYING COPYING.CDDL $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/README.SLACKWARE > $PKG/usr/doc/$PRGNAM-$VERSION/README.SLACKWARE
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
cat $CWD/doinst.sh > $PKG/install/doinst.sh
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}