Some SlackBuild scripts for Slackware.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

187 lines
5.4 KiB

#!/bin/bash
# Build script for Slackware
# Copyright (C) 2009 Damien Goutte-Gattat
#
# 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.
#
# Contact: Damien Goutte-Gattat <dgouttegattat@incenp.org>
#
# Latest virtualbox-ose sourcecode is available at:
# <http://http://www.virtualbox.org/>.
#
# Depends: d/iasl
#
# Notes: To build VirtualBox, you need a compiler able to generate
# 32-bit binaries and the corresponding 32-bit libraries; these
# are provided by Eric Hameleers' "multilib" packages, found at
# <http://connie.slackware.com/~alien/multilib/>.
#
# This SlackBuild does not build the kernel modules needed to run
# VirtualBox; instead, their sources are installed in
# /usr/src/virtualbox-kmods-$VERSION. It is up to the
# administrator to compile these modules against the desired
# Linux kernel and install them.
# Source package infos
NAMESRC=${NAMESRC:-VirtualBox}
VERSION=${VERSION:-3.0.4}
ARCHIVE=${ARCHIVE:-$NAMESRC-$VERSION-OSE.tar.bz2}
GUESTISO=${GUESTISO:-VBoxGuestAdditions_$VERSION.iso}
BASEURL=${BASEURL:-http://download.virtualbox.org/virtualbox/$VERSION}
# Build infos
NAMEPKG=${NAMEPKG:-virtualbox-ose}
BUILD=${BUILD:-1GGD}
ARCH=${ARCH:-i486}
JOBS=${JOBS:-1}
EXT=${EXT:-txz}
# Directories
TMP=${TMP:-/tmp}
OUT=${OUT:-$TMP/build}
PKG=${PKG:-$OUT/$NAMEPKG}
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
# Compilation flags
LIBDIR=/usr/lib/virtualbox
case "$ARCH" in
i?86)
CPUOPT="-O2 -march=$ARCH -mtune=i686"
ARCHNAME="x86"
;;
x86_64)
CPUOPT="-O2 -fPIC"
LIBDIR=/usr/lib64/virtualbox
ARCHNAME="amd64"
;;
*)
CPUOPT="-O2"
ARCHNAME=$ARCH
;;
esac
# Get and verify the files
if [ ! -r $ARCHIVE ]; then
wget -c -O $ARCHIVE.part "$BASEURL/$ARCHIVE"
mv $ARCHIVE.part $ARCHIVE
fi
if [ ! -r $GUESTISO ]; then
wget -c -O $GUESTISO.part "$BASEURL/$GUESTISO"
mv $GUESTISO.part $GUESTISO
fi
if [ ! -r UserManual.pdf ]; then
wget -c -O UserManual.pdf.part "$BASEURL/UserManual.pdf"
mv UserManual.pdf.part UserManual.pdf
fi
sha1sum -c checksums
NAME=$(tar ft $ARCHIVE | head -n 1 | cut -d / -f 1)
# Compile
cd $TMP
echo "Building $ARCHIVE..."
tar xf $CWD/$ARCHIVE
cd $NAME
CFLAGS=$CPUOPT \
CXXFLAGS=$CPUOPT \
./configure \
--disable-kmods \
--disable-pulse
. env.sh
sed -e "s,/usr/lib/virtualbox,$LIBDIR," $CWD/LocalConfig.kmk > LocalConfig.kmk
kmk -j ${JOBS} LOCALCFG=LocalConfig.kmk
# Create directories
mkdir -p $PKG/etc/vbox \
$PKG/lib/udev/rules.d \
$PKG/usr/bin \
$PKG$LIBDIR \
$PKG/usr/share/applications \
$PKG/usr/share/pixmaps \
$PKG/usr/share/virtualbox \
$PKG/usr/doc/$NAMEPKG-$VERSION \
$PKG/usr/src \
$PKG/install
# Install config file and udev rule
echo "INSTALL_DIR='$LIBDIR'" > $PKG/etc/vbox/vbox.cfg.new
echo 'KERNEL=="vboxdrv", NAME"vboxdrv", OWNER="root", GROUP="vbox", ' \
'MODE="0660"' > $PKG/lib/udev/rules.d/60-vboxdrv.rules
# Install main files
(
cd out/linux.$ARCHNAME/release/bin
mv VBox.png $PKG/usr/share/pixmaps/
mv VirtualBox.desktop $PKG/usr/share/applications
mv src $PKG/usr/src/virtualbox-kmods-$VERSION
mv sdk nls *.tar.gz $PKG/usr/share/virtualbox/
install -m 750 VBoxSysInfo.sh $PKG/usr/share/virtualbox/
install -m 750 VBoxTunctl $PKG/usr/bin
rm VBoxSysInfo.sh VBoxTunctl
mv * $PKG$LIBDIR/
chmod -R 750 $PKG$LIBDIR/
mv $PKG$LIBDIR/VBox.sh $PKG$LIBDIR/VBox
)
# Create symlinks
for i in VirtualBox VBoxManage VBoxSDL VBoxHeadless VBoxVRDP ; do
ln -s $LIBDIR/VBox $PKG/usr/bin/$i
done
# Copy auxiliary files
cp $CWD/$GUESTISO $PKG/usr/share/virtualbox/
cp $CWD/UserManual.pdf $PKG/usr/share/virtualbox/
sed -ri 's,^DocPath=.*$,DocPath=file:///usr/share/virtualbox/UserManual.pdf,' \
$PKG/usr/share/applications/VirtualBox.desktop
# Install the documentation
mkdir -p $PKG/usr/doc/$NAMEPKG-$VERSION
install -m 644 COPYING COPYING.CDDL $PKG/usr/doc/$NAMEPKG-$VERSION
# Copy slack-desc and doinst.sh files
mkdir -p $PKG/install
install -m 644 $CWD/slack-desc $PKG/install/slack-desc
sed -e "s,/usr/lib/virtualbox,$LIBDIR," $CWD/doinst.sh > $PKG/install/doinst.sh
chmod 755 $PKG/install/doinst.sh
# Package the tree
cd $PKG
mkdir -p $OUT
PACKAGING="
chown root:root . -R
/sbin/makepkg -l y -c n $OUT/$NAMEPKG-$VERSION-$ARCH-$BUILD.$EXT
rm -rf $PKG
rm -rf $TMP/$NAME
"
if type -p fakeroot ; then
echo "$PACKAGING" | fakeroot
else
su -c "$PACKAGING"
fi