2010-05-11 22:55:36 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Slackware build script for virtualbox-ose
|
|
|
|
|
2013-04-02 07:11:57 +02:00
|
|
|
# Copyright 2008-2013 Heinz Wiesinger, Amsterdam, The Netherlands
|
2010-05-11 22:55:36 +02:00
|
|
|
# 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.
|
|
|
|
|
2011-04-03 20:45:31 +02:00
|
|
|
PRGNAM=virtualbox
|
2010-05-11 22:55:36 +02:00
|
|
|
SRCNAM=VirtualBox
|
2013-04-02 07:11:57 +02:00
|
|
|
VERSION=4.2.10
|
|
|
|
BUILD=${BUILD:-1}
|
2010-05-11 22:55:36 +02:00
|
|
|
TAG=${TAG:-_SBo}
|
|
|
|
|
2010-11-25 09:09:03 +01:00
|
|
|
if [ -z "$ARCH" ]; then
|
|
|
|
case "$( uname -m )" in
|
|
|
|
i?86) ARCH=i486 ;;
|
|
|
|
arm*) ARCH=arm ;;
|
|
|
|
*) ARCH=$( uname -m ) ;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
2010-05-11 22:55:36 +02:00
|
|
|
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
|
2012-09-18 23:07:20 +02:00
|
|
|
gui=""
|
2010-05-11 22:55:36 +02:00
|
|
|
|
2010-05-13 00:42:20 +02:00
|
|
|
# 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
|
2010-05-11 22:55:36 +02:00
|
|
|
fi
|
|
|
|
|
2010-05-12 17:46:18 +02:00
|
|
|
# Enable Hardening - Defaulting to yes as requested by upstream
|
2010-05-11 22:55:36 +02:00
|
|
|
if [ "${HARDENING:-yes}" = "yes" ]; then
|
|
|
|
harden="--enable-hardening"
|
|
|
|
else
|
|
|
|
harden="--disable-hardening"
|
|
|
|
fi
|
|
|
|
|
2010-11-25 09:09:03 +01:00
|
|
|
if [ "${WEBSERVICE:-no}" = "no" ]; then
|
2010-05-13 00:42:20 +02:00
|
|
|
web_service=""
|
|
|
|
vboxwebsrv=""
|
2010-11-25 09:09:03 +01:00
|
|
|
else
|
|
|
|
web_service="--enable-webservice"
|
|
|
|
vboxwebsrv="vboxwebsrv"
|
|
|
|
if ! grep ^vboxweb: /etc/passwd 2>&1 > /dev/null; then
|
|
|
|
echo " You must have a vboxweb user to run this script."
|
|
|
|
echo " # useradd -u 240 -g 215 -d /var/lib/vboxweb vboxweb"
|
|
|
|
exit 1
|
|
|
|
fi
|
2010-05-13 00:42:20 +02:00
|
|
|
fi
|
|
|
|
|
2010-05-11 22:55:36 +02:00
|
|
|
if [ "$ARCH" = "i486" ]; then
|
|
|
|
SLKCFLAGS="-O2 -march=i486 -mtune=i686"
|
2010-05-13 00:42:20 +02:00
|
|
|
LIBDIRSUFFIX=""
|
|
|
|
BUILDDIR="x86"
|
2010-05-11 22:55:36 +02:00
|
|
|
elif [ "$ARCH" = "i686" ]; then
|
|
|
|
SLKCFLAGS="-O2 -march=i686 -mtune=i686"
|
2010-05-13 00:42:20 +02:00
|
|
|
LIBDIRSUFFIX=""
|
|
|
|
BUILDDIR="x86"
|
2010-05-11 22:55:36 +02:00
|
|
|
elif [ "$ARCH" = "x86_64" ]; then
|
|
|
|
SLKCFLAGS="-O2 -fPIC"
|
2010-05-13 00:42:20 +02:00
|
|
|
LIBDIRSUFFIX="64"
|
|
|
|
BUILDDIR="amd64"
|
2010-05-11 22:55:36 +02:00
|
|
|
fi
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
rm -rf $PKG
|
|
|
|
mkdir -p $TMP $PKG $OUTPUT
|
|
|
|
cd $TMP
|
2012-05-08 05:05:19 +02:00
|
|
|
rm -rf $SRCNAM-${VERSION}
|
2011-04-03 20:45:31 +02:00
|
|
|
tar xvf $CWD/$SRCNAM-${VERSION}.tar.bz2
|
2012-05-08 05:05:19 +02:00
|
|
|
cd $SRCNAM-${VERSION}
|
2010-05-11 22:55:36 +02:00
|
|
|
chown -R root:root .
|
|
|
|
chmod -R u+w,go+r-w,a-s .
|
|
|
|
|
2010-05-13 00:42:20 +02:00
|
|
|
GROUP="vboxusers"
|
2011-04-03 20:45:31 +02:00
|
|
|
MODE="755"
|
2010-05-11 22:55:36 +02:00
|
|
|
|
2012-09-18 23:07:20 +02:00
|
|
|
# We don't want an init-script building kernel modules.
|
2010-05-13 00:42:20 +02:00
|
|
|
# Use virtualbox-kernel.SlackBuild for this.
|
|
|
|
patch -d src/VBox/Installer/linux -i $CWD/vboxdrv.sh-setup.diff
|
2010-05-11 22:55:36 +02:00
|
|
|
|
|
|
|
# Support for the qt4-frontend
|
2012-09-18 23:07:20 +02:00
|
|
|
if [ "${HEADLESS:-no}" = "no" ]; then
|
2010-05-11 22:55:36 +02:00
|
|
|
mkdir -p $PKG/usr/share/applications
|
2012-09-18 23:07:20 +02:00
|
|
|
guiapp="VirtualBox VBoxSDL VBoxBFE"
|
2010-05-12 17:46:18 +02:00
|
|
|
else
|
2012-09-18 23:07:20 +02:00
|
|
|
gui+=" --build-headless"
|
2010-03-16 04:01:23 +01:00
|
|
|
guiapp=""
|
2010-05-11 22:55:36 +02:00
|
|
|
fi
|
|
|
|
|
2012-09-18 23:07:20 +02:00
|
|
|
if [ "${JAVA:-no}" = "no" ]; then
|
|
|
|
java="--disable-java"
|
|
|
|
else
|
|
|
|
java=""
|
|
|
|
fi
|
|
|
|
|
2011-04-03 20:45:31 +02:00
|
|
|
# Do not require makeself. We don't plan on building an automatic installer
|
|
|
|
# Patch taken from gentoo
|
|
|
|
patch -p1 -i $CWD/virtualbox-4-makeself-check.patch
|
|
|
|
|
2010-05-11 22:55:36 +02:00
|
|
|
CFLAGS="$SLKCFLAGS" \
|
|
|
|
CXXFLAGS="$SLKCFLAGS" \
|
|
|
|
./configure \
|
2010-05-12 17:46:18 +02:00
|
|
|
--disable-kmods \
|
2010-05-13 00:42:20 +02:00
|
|
|
--disable-pulse \
|
2011-04-03 20:45:31 +02:00
|
|
|
--enable-vde \
|
2011-06-20 05:37:33 +02:00
|
|
|
--enable-vnc \
|
2010-05-13 00:42:20 +02:00
|
|
|
$web_service \
|
2010-05-11 22:55:36 +02:00
|
|
|
$harden \
|
2012-09-18 23:07:20 +02:00
|
|
|
$gui \
|
|
|
|
$java
|
2010-05-13 00:42:20 +02:00
|
|
|
|
|
|
|
. ./env.sh
|
2010-05-11 22:55:36 +02:00
|
|
|
|
2010-05-13 00:42:20 +02:00
|
|
|
cp $CWD/LocalConfig.kmk .
|
|
|
|
sed -i "s|LIBDIR|lib$LIBDIRSUFFIX|" ./LocalConfig.kmk
|
2010-05-11 22:55:36 +02:00
|
|
|
|
2010-05-13 00:42:20 +02:00
|
|
|
kmk -j ${JOBS} LOCALCFG=./LocalConfig.kmk
|
2010-05-11 22:55:36 +02:00
|
|
|
|
2012-09-18 23:07:20 +02:00
|
|
|
# build VBoxFUSE
|
|
|
|
cd src/VBox/ImageMounter/VBoxFUSE
|
|
|
|
kmk -j ${JOBS}
|
|
|
|
cd -
|
|
|
|
|
2010-05-13 00:42:20 +02:00
|
|
|
mkdir -p $PKG/usr/{lib$LIBDIRSUFFIX,share,include}/virtualbox \
|
2010-05-11 22:55:36 +02:00
|
|
|
$PKG/usr/{bin,src} \
|
2011-04-03 20:45:31 +02:00
|
|
|
$PKG/usr/share/{pixmaps,mime/packages} \
|
2010-05-13 00:42:20 +02:00
|
|
|
$PKG/etc/{default,rc.d,vbox}
|
2010-05-11 22:55:36 +02:00
|
|
|
|
2012-09-18 23:07:20 +02:00
|
|
|
for i in vboxdrv vboxballoonctrl-service vboxautostart-service; do
|
2011-10-31 03:36:44 +01:00
|
|
|
cp -f src/VBox/Installer/linux/$i.sh.in $PKG/etc/rc.d/rc.$i.new
|
|
|
|
sed -i "s/%PACKAGE%/virtualbox/g" $PKG/etc/rc.d/rc.$i.new
|
|
|
|
sed -i "s/%NOLSB%/yes/" $PKG/etc/rc.d/rc.$i.new
|
|
|
|
sed -i "s/%DEBIAN%/no/" $PKG/etc/rc.d/rc.$i.new
|
|
|
|
sed -i "s/%GROUP%/vboxusers/" $PKG/etc/rc.d/rc.$i.new
|
|
|
|
sed -i "s/\[ -z \"\$DEBIAN\"/#\[ -z \"\$DEBIAN\"/" $PKG/etc/rc.d/rc.$i.new
|
|
|
|
done
|
2010-05-13 00:42:20 +02:00
|
|
|
|
2010-05-11 22:55:36 +02:00
|
|
|
cp -f $CWD/vbox.cfg $PKG/etc/vbox/vbox.cfg.new
|
2010-05-13 00:42:20 +02:00
|
|
|
sed -i "s|LIBDIR|lib$LIBDIRSUFFIX|" $PKG/etc/vbox/vbox.cfg.new
|
|
|
|
cp -f $CWD/virtualbox.default $PKG/etc/default/virtualbox.new
|
2010-05-11 22:55:36 +02:00
|
|
|
|
2010-05-13 00:42:20 +02:00
|
|
|
cd out/linux.$BUILDDIR/release/bin/
|
2011-04-03 20:45:31 +02:00
|
|
|
rm -f vboxdrv.ko
|
2010-05-12 17:46:18 +02:00
|
|
|
mv src $PKG/usr/src/virtualbox-kernel-$VERSION
|
2011-04-03 20:45:31 +02:00
|
|
|
|
2012-09-18 23:07:20 +02:00
|
|
|
if [ "${HEADLESS:-no}" = "no" ]; then
|
2011-04-03 20:45:31 +02:00
|
|
|
mv virtualbox.desktop $PKG/usr/share/applications/
|
2012-09-27 18:04:33 +02:00
|
|
|
sed -i "s|/opt/VirtualBox|/usr/share/virtualbox|" \
|
2011-04-03 20:45:31 +02:00
|
|
|
$PKG/usr/share/applications/virtualbox.desktop
|
2012-09-18 23:07:20 +02:00
|
|
|
mv nls* *.tar.bz2 $PKG/usr/share/virtualbox/
|
2011-04-03 20:45:31 +02:00
|
|
|
fi
|
|
|
|
mv VBox.png $PKG/usr/share/pixmaps/
|
|
|
|
|
|
|
|
cd icons
|
|
|
|
for i in *; do
|
|
|
|
install -d $PKG/usr/share/icons/hicolor/$i/mimetypes
|
|
|
|
mv $i/* $PKG/usr/share/icons/hicolor/$i/mimetypes
|
|
|
|
done
|
|
|
|
cd -
|
|
|
|
rm -rf icons
|
|
|
|
|
|
|
|
mv virtualbox.xml $PKG/usr/share/mime/packages
|
|
|
|
|
|
|
|
export VBOX_INSTALL_PATH=/usr/lib$LIBDIRSUFFIX/virtualbox
|
|
|
|
cd sdk/installer
|
|
|
|
python ./vboxapisetup.py install --prefix "/usr" --root $PKG
|
|
|
|
cd -
|
|
|
|
rm -rf sdk/installer
|
|
|
|
|
2010-03-16 04:01:23 +01:00
|
|
|
mv sdk $PKG/usr/share/virtualbox/
|
2010-05-11 22:55:36 +02:00
|
|
|
install -m $MODE -g $GROUP VBoxSysInfo.sh $PKG/usr/share/virtualbox/
|
2011-04-03 20:45:31 +02:00
|
|
|
install -m $MODE -g $GROUP VBoxCreateUSBNode.sh $PKG/usr/share/virtualbox/
|
2010-05-11 22:55:36 +02:00
|
|
|
install -m $MODE -g $GROUP VBoxTunctl $PKG/usr/bin/
|
2012-09-18 23:07:20 +02:00
|
|
|
install -m $MODE -g $GROUP VBoxFUSE $PKG/usr/bin/
|
2011-04-03 20:45:31 +02:00
|
|
|
rm -f VBoxSysInfo.sh VBoxCreateUSBNode.sh VBoxTunctl
|
2010-05-13 00:42:20 +02:00
|
|
|
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
|
2012-05-08 05:05:19 +02:00
|
|
|
cd $TMP/$SRCNAM-${VERSION}
|
2010-05-11 22:55:36 +02:00
|
|
|
|
2012-09-18 23:07:20 +02:00
|
|
|
for i in VBoxManage vboxmanage VBoxHeadless \
|
|
|
|
vboxheadless VBoxVRDP VBoxBalloonCtrl vboxballoonctrl \
|
|
|
|
VBoxAutostart vboxautostart $guiapp $vboxwebsrv; do
|
2011-04-03 20:45:31 +02:00
|
|
|
ln -s /usr/lib$LIBDIRSUFFIX/virtualbox/VBox $PKG/usr/bin/$i
|
2010-05-11 22:55:36 +02:00
|
|
|
done
|
|
|
|
|
2012-09-18 23:07:20 +02:00
|
|
|
if [ "${HEADLESS:-no}" = "no" ]; then
|
|
|
|
for i in virtualbox vboxsdl vboxbfe; do
|
|
|
|
ln -s /usr/lib$LIBDIRSUFFIX/virtualbox/VBox $PKG/usr/bin/$i
|
|
|
|
done
|
2011-04-03 20:45:31 +02:00
|
|
|
fi
|
|
|
|
|
2010-11-25 09:09:03 +01:00
|
|
|
if [ "$vboxwebsrv" = "vboxwebsrv" ]; then
|
|
|
|
mkdir -p $PKG/var/{lib,log}/vboxweb
|
|
|
|
chown vboxweb:vboxusers $PKG/var/{lib,log}/vboxweb
|
|
|
|
cp -f src/VBox/Installer/linux/vboxweb-service.sh.in $PKG/etc/rc.d/rc.vboxweb-service.new
|
|
|
|
sed -i "s/%PACKAGE%/virtualbox/g" $PKG/etc/rc.d/rc.vboxweb-service.new
|
|
|
|
sed -i "s/%NOLSB%/yes/" $PKG/etc/rc.d/rc.vboxweb-service.new
|
|
|
|
sed -i "s/%DEBIAN%/no/" $PKG/etc/rc.d/rc.vboxweb-service.new
|
|
|
|
sed -i "s/\[ -z \"\$DEBIAN\"/#\[ -z \"\$DEBIAN\"/" $PKG/etc/rc.d/rc.vboxweb-service.new
|
|
|
|
fi
|
|
|
|
|
2010-05-11 22:55:36 +02:00
|
|
|
if [ "$harden" = "--enable-hardening" ]; then
|
2012-09-18 23:07:20 +02:00
|
|
|
for i in VBoxHeadless $guiapp VBoxNetDHCP VBoxNetAdpCtl; do
|
2011-04-03 20:45:31 +02:00
|
|
|
chmod 4711 $PKG/usr/lib$LIBDIRSUFFIX/virtualbox/$i
|
2010-05-11 22:55:36 +02:00
|
|
|
done
|
|
|
|
fi
|
|
|
|
|
2010-05-13 00:42:20 +02:00
|
|
|
# install headers. Needed by some third party tools
|
|
|
|
cp -rf include/* $PKG/usr/include/virtualbox/
|
|
|
|
rm -f $PKG/usr/include/virtualbox/Makefile.kmk
|
2010-05-11 22:55:36 +02:00
|
|
|
|
2010-05-13 00:42:20 +02:00
|
|
|
cp -f $CWD/VBoxGuestAdditions_$VERSION.iso \
|
|
|
|
$PKG/usr/share/virtualbox/VBoxGuestAdditions.iso
|
|
|
|
|
|
|
|
cp -f $CWD/UserManual.pdf \
|
|
|
|
$PKG/usr/share/virtualbox/UserManual.pdf
|
2010-05-11 22:55:36 +02:00
|
|
|
|
2010-11-25 09:09:03 +01:00
|
|
|
cp -f $CWD/SDKRef.pdf \
|
|
|
|
$PKG/usr/share/virtualbox/SDKRef.pdf
|
|
|
|
|
2010-07-20 16:20:44 +02:00
|
|
|
# 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/*
|
|
|
|
|
2011-06-20 05:37:33 +02:00
|
|
|
# setup udev rules for vboxdrv and USB device support
|
|
|
|
mkdir -p $PKG/lib/udev/rules.d
|
|
|
|
install -m 644 $CWD/10-virtualbox.rules $PKG/lib/udev/rules.d/
|
|
|
|
|
2010-05-11 22:55:36 +02:00
|
|
|
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
|
|
|
|
cp -f COPYING COPYING.CDDL $PKG/usr/doc/$PRGNAM-$VERSION
|
2010-05-13 00:42:20 +02:00
|
|
|
cat $CWD/README.SLACKWARE > $PKG/usr/doc/$PRGNAM-$VERSION/README.SLACKWARE
|
2010-05-11 22:55:36 +02:00
|
|
|
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
|
|
|
|
|
2010-11-25 09:09:03 +01:00
|
|
|
if [ "$vboxwebsrv" = "vboxwebsrv" ]; then
|
|
|
|
echo "preserve_perms etc/rc.d/rc.vboxweb-service.new" >> $PKG/install/doinst.sh
|
|
|
|
fi
|
|
|
|
|
2010-05-11 22:55:36 +02:00
|
|
|
cd $PKG
|
2010-05-13 00:42:20 +02:00
|
|
|
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-tgz}
|