|
|
|
#!/bin/bash
|
|
|
|
# Build script for Slackware
|
|
|
|
# Damien Goutte-Gattat "gouttegd" <Damien.Goutte-Gattat at e.ujf-grenoble.fr>
|
|
|
|
#
|
|
|
|
# Redistribution and use of this script, with or without modifications, 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.
|
|
|
|
#
|
|
|
|
# Latest virtualbox sourcecode is available at:
|
|
|
|
# http://virtualbox.org/
|
|
|
|
|
|
|
|
# Source package infos
|
|
|
|
NAMESRC=${NAMESRC:-VirtualBox}
|
|
|
|
VERSION=${VERSION:-2.1.0}
|
|
|
|
REVISION=${REVISION:-41146}
|
|
|
|
ARCHIVE=${ARCHIVE:-$NAMESRC-$VERSION-$REVISION-Linux_x86.run}
|
|
|
|
WGET=${WGET:-http://download.virtualbox.org/virtualbox/$VERSION/$ARCHIVE}
|
|
|
|
|
|
|
|
# Built package infos
|
|
|
|
NAMETGZ=${NAMETGZ:-virtualbox}
|
|
|
|
BUILD=${BUILD:-1GGD}
|
|
|
|
ARCH=${ARCH:-i486}
|
|
|
|
TARGET=${TARGET:-i486}
|
|
|
|
KERNELSRC=${KERNELSRC:-/usr/src/linux} # Set to anything else than a
|
|
|
|
# directory to not build the
|
|
|
|
# kernel modules
|
|
|
|
|
|
|
|
# Directories
|
|
|
|
TMP=${TMP:-/tmp}
|
|
|
|
OUT=${OUT:-$TMP/build}
|
|
|
|
PKG=${PKG:-$OUT/$NAMETGZ}
|
|
|
|
CWD=$(pwd)
|
|
|
|
|
|
|
|
set -e # Quit if a command returns non-zero
|
|
|
|
|
|
|
|
# Sanity checks
|
|
|
|
if [ $UID -eq 0 ]; then
|
|
|
|
echo "You should NOT run this script as ROOT!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ ! -d $TMP ]; then
|
|
|
|
echo "$TMP does not exist or is not a directory!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ -d "$KERNELSRC" ]; then
|
|
|
|
if [ ! -f $KERNELSRC/include/config/kernel.release ]; then
|
|
|
|
echo "No kernel.release found! Please configure your kernel"
|
|
|
|
echo "sources before attempting to build the VBox modules."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Get and verify the source archive
|
|
|
|
if [ ! -r $ARCHIVE ]; then
|
|
|
|
wget "$WGET" -O "$ARCHIVE"
|
|
|
|
fi
|
|
|
|
sha1sum -c $ARCHIVE.sha1
|
|
|
|
|
|
|
|
# Extract the archive
|
|
|
|
cd $TMP
|
|
|
|
echo "Building $ARCHIVE..."
|
|
|
|
sh $CWD/$NAMESRC-$VERSION-$REVISION-Linux_x86.run --target VirtualBoxBuild --noexec
|
|
|
|
cd VirtualBoxBuild
|
|
|
|
mkdir -p virtualbox
|
|
|
|
tar xf $NAMESRC.tar.bz2 --directory=virtualbox
|
|
|
|
|
|
|
|
# Build the kernel modules (if asked to do so)
|
|
|
|
if [ -d "$KERNELSRC" ]; then
|
|
|
|
KERNELVER=$(< $KERNELSRC/include/config/kernel.release)
|
|
|
|
cd virtualbox/src
|
|
|
|
make -j 3 KERN_DIR=$KERNELSRC
|
|
|
|
mkdir -p $PKG/lib/modules/$KERNELVER/kernel/misc
|
|
|
|
install -m 0644 vbox{drv,netflt}.ko $PKG/lib/modules/$KERNELVER/kernel/misc
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Install user-space files
|
|
|
|
cd $TMP/VirtualBoxBuild
|
|
|
|
rm -rf virtualbox/src
|
|
|
|
mkdir -p $PKG/opt
|
|
|
|
cp -r virtualbox $PKG/opt/VirtualBox-$VERSION
|
|
|
|
|
|
|
|
# Create symbolic links
|
|
|
|
mkdir -p $PKG/usr/bin $PKG/usr/share/{pixmaps,applications}
|
|
|
|
ln -sf /opt/VirtualBox-$VERSION/VBoxVMM.so $PKG/opt/VirtualBox-$VERSION/components/VBoxVMM.so
|
|
|
|
ln -sf /opt/VirtualBox-$VERSION/VBoxREM.so $PKG/opt/VirtualBox-$VERSION/components/VBoxREM.so
|
|
|
|
ln -sf /opt/VirtualBox-$VERSION/VBoxRT.so $PKG/opt/VirtualBox-$VERSION/components/VBoxRT.so
|
|
|
|
ln -sf /opt/VirtualBox-$VERSION/VBoxDDU.so $PKG/opt/VirtualBox-$VERSION/components/VBoxDDU.so
|
|
|
|
ln -sf /opt/VirtualBox-$VERSION/VBoxXPCOM.so $PKG/opt/VirtualBox-$VERSION/components/VBoxXPCOM.so
|
|
|
|
ln -sf /opt/VirtualBox-$VERSION/VBox.sh $PKG/usr/bin/VirtualBox
|
|
|
|
ln -sf /opt/VirtualBox-$VERSION/VBox.sh $PKG/usr/bin/VBoxManage
|
|
|
|
ln -sf /opt/VirtualBox-$VERSION/VBox.sh $PKG/usr/bin/VBoxSDL
|
|
|
|
ln -sf /opt/VirtualBox-$VERSION/VBox.sh $PKG/usr/bin/VBoxVRDP
|
|
|
|
ln -sf /opt/VirtualBox-$VERSION/VBox.sh $PKG/usr/bin/VBoxHeadless
|
|
|
|
ln -sf /opt/VirtualBox-$VERSION/VBox.sh $PKG/usr/bin/vboxwebsrv
|
|
|
|
ln -sf /opt/VirtualBox-$VERSION/VBox.png $PKG/usr/share/pixmaps/VBox.png
|
|
|
|
ln -sf /opt/VirtualBox-$VERSION/VirtualBox.desktop $PKG/usr/share/applications/VirtualBox.desktop
|
|
|
|
ln -sf /opt/VirtualBox-$VERSION/rdesktop-vrdp $PKG/usr/bin/rdesktop-vrdp
|
|
|
|
|
|
|
|
# Install udev rules and config file
|
|
|
|
install -D -m 644 $CWD/60-vboxdrv.rules $PKG/etc/udev/rules.d/60-vboxdrv.rules
|
|
|
|
install -D -m 644 $CWD/vbox.cfg $PKG/etc/vbox/vbox.cfg.new
|
|
|
|
|
|
|
|
# Install slack-desc and doinst.sh files
|
|
|
|
install -D -m 644 $CWD/slack-desc $PKG/install/slack-desc
|
|
|
|
install -m 755 $CWD/doinst.sh $PKG/install/doinst.sh
|
|
|
|
|
|
|
|
find $(find $PKG -type d -name man -o -name info) -type f | \
|
|
|
|
xargs gzip -9 2> /dev/null
|
|
|
|
|
|
|
|
# Package the tree
|
|
|
|
cd $PKG
|
|
|
|
mkdir -p $OUT
|
|
|
|
PACKAGING="
|
|
|
|
chown root:root . -R
|
|
|
|
chmod 4511 $PKG/opt/VirtualBox-$VERSION/VirtualBox
|
|
|
|
chmod 4511 $PKG/opt/VirtualBox-$VERSION/VBoxSDL
|
|
|
|
chmod 4511 $PKG/opt/VirtualBox-$VERSION/VBoxHeadless
|
|
|
|
/sbin/makepkg -l y -c n $OUT/$NAMETGZ-$VERSION-$ARCH-$BUILD.tgz
|
|
|
|
rm -rf $PKG
|
|
|
|
rm -rf $TMP/VirtualBoxBuild
|
|
|
|
"
|
|
|
|
if type -p fakeroot ; then
|
|
|
|
echo "$PACKAGING" | fakeroot
|
|
|
|
else
|
|
|
|
su -c "$PACKAGING"
|
|
|
|
fi
|