#!/bin/sh # Slackware build script for # Written by torimus PRGNAM=virtualbox-bin VERSION=${VERSION:-4.2.12} ARCH=${ARCH:-i486} # Architecture code of the source package case $ARCH in "x86_64") SRCARCH="amd64" ;; "i[3-6]86") SRCARCH="x86" ;; *) echo "unsupported architecture !" ;; esac BUILD=${BUILD:-1} TAG=${TAG:-_SBo} VERBUILD=84980 CWD=$(pwd) TMP=${TMP:-/tmp/SBo} PKG=$TMP/package-$PRGNAM OUTPUT=${OUTPUT:-/tmp} INST_DIR=/opt/VirtualBox # need to be this one as this is hardcoded in Oracle's # binaries if [ "$ARCH" = "i486" ]; then SLKCFLAGS="-O2 -march=i486 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "i686" ]; then SLKCFLAGS="-O2 -march=i686 -mtune=i686" LIBDIRSUFFIX="" elif [ "$ARCH" = "x86_64" ]; then SLKCFLAGS="-O2 -fPIC" LIBDIRSUFFIX="64" fi set -e rm -rf $PKG mkdir -p $TMP $PKG $OUTPUT cd $TMP rm -rf $PRGNAM-$VERSION mkdir -p $PRGNAM-$VERSION cd $PRGNAM-$VERSION sh $CWD/VirtualBox-${VERSION}-${VERBUILD}-Linux_${SRCARCH}.run --check sh $CWD/VirtualBox-${VERSION}-${VERBUILD}-Linux_${SRCARCH}.run --target . --nox11 --noexec chown -R root:root . find . \ \( -perm 777 -o -perm 775 -o -perm 711 -o -perm 555 -o -perm 511 \) \ -exec chmod 755 {} \; -o \ \( -perm 666 -o -perm 664 -o -perm 600 -o -perm 444 -o -perm 440 -o -perm 400 \) \ -exec chmod 644 {} \; install -d $PKG/$INST_DIR tar xjf VirtualBox.tar.bz2 -C $PKG/$INST_DIR # Hardened build: Mark binaries suid root, create symlinks for working around # unsupported $ORIGIN/.. in VBoxC.so and make sure the # directory is only writable by the user (paranoid). chmod 4511 $PKG/$INST_DIR/VirtualBox $PKG/$INST_DIR/VBox{SDL,Headless,NetDHCP,NetAdpCtl} for _lib in VBox{VMM,REM,RT,DDU,XPCOM}.so; do ln -sf "$INST_DIR/$_lib" "$PKG/$INST_DIR/components/$_lib" done chmod go-w . # Install the SDK pushd "$PKG/$INST_DIR/sdk/installer" VBOX_INSTALL_PATH="${INST_DIR}" python vboxapisetup.py install --root "${PKG}" rm -r -f build popd # Install udev rules install -D -m 0644 "$CWD/10-vboxdrv.rules" "$PKG/usr/lib/udev/rules.d/10-vboxdrv.rules" # we need to move and not symlink VBoxCreateUSBNode.sh in /usr/lib/udev to avoid udevd # to look /opt when /opt is not mounted. This can be done until VBoxCreateUSBNode.sh doesn't # need more stuff from /opt mv $PKG/$INST_DIR/VBoxCreateUSBNode.sh "$PKG/usr/lib/udev/" # Install Fixusb script install -D -m 0755 "$CWD/VBoxFixUSB" $PKG/$INST_DIR/VBoxFixUSB # Update Slack's initscripts way of life in VBox.sh sed -i -e 's,sudo /etc/init.d/vboxdrv setup,/etc/rc.d/rc.vboxdrv start,g' \ "$PKG/$INST_DIR/VBox.sh" sed -i -e 's,sudo /etc/init.d/vboxdrv restart,/etc/rc.d/vboxdrv start,g' \ "$PKG/$INST_DIR/VBox.sh" # Install vboxweb initscript install -D -m 0755 "$CWD/vboxweb.rc" "$PKG/etc/rc.d/rc.vboxweb.new" install -D -m 0644 "$CWD/vboxweb.conf" "$PKG/etc/vbox/vboxweb.conf.new" # Symlink the launchers. Second link can fail if fs is not case sensitive. install -d -m 0755 "$PKG/usr/bin" for _bin in VirtualBox VBox{Headless,Manage,SDL,SVC,Tunctl,NetAdpCtl,FixUSB} rdesktop-vrdp; do ln -s "$INST_DIR/$_bin" "$PKG/usr/bin/$_bin" ln -s "$INST_DIR/$_bin" "$PKG/usr/bin/${_bin,,}" &>/dev/null || : done # Symlink the desktop icon and ".desktop" files install -d -m 0755 "$PKG/usr/"{share/applications,share/pixmaps} ln -s "$INST_DIR/VBox.png" "$PKG/usr/share/pixmaps/VBox.png" ln -s "$INST_DIR/icons/128x128/virtualbox.png" "$PKG/usr/share/pixmaps/virtualbox.png" ln -s "$INST_DIR/virtualbox.desktop" "$PKG/usr/share/applications/virtualbox.desktop" # Symlink mime info install -d -m 0755 "$PKG/usr/share/mime/packages" ln -s "$INST_DIR/virtualbox.xml" "$PKG/usr/share/mime/packages/virtualbox.xml" # Symlink doc install -d -m 0755 "$PKG/usr/doc/$PRGNAM-$VERSION" ln -s "$INST_DIR/VirtualBox.chm" "$PKG/usr/doc/$PRGNAM-$VERSION/virtualbox.chm" # Symlink module sources in /usr/src #install -d -m 0755 "$PKG/usr/src" #ln -s "$INST_DIR/src/vboxhost" "$PKG/usr/src/vboxhost-$VERSION" # Symlink icons pushd $PKG/$INST_DIR/icons for _dir in *; do cd "$_dir" install -d -m 0755 "$PKG/usr/share/icons/hicolor/$_dir/"{apps,mimetypes} for _icon in *; do if [[ "$_icon" = 'virtualbox.png' ]]; then ln -s "$INST_DIR/icons/$_dir/$_icon" "$PKG/usr/share/icons/hicolor/$_dir/apps/$_icon" else ln -s "$INST_DIR/icons/$_dir/$_icon" "$PKG/usr/share/icons/hicolor/$_dir/mimetypes/$_icon" fi done cd - >/dev/null done popd # Write the configuration file install -D -m 0644 /dev/null "$PKG/etc/vbox/vbox.cfg" cat > "$PKG/etc/vbox/vbox.cfg" < /dev/null || true find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : | \ xargs strip --strip-unneeded 2> /dev/null || true ) #( cd $PKG/usr/man # find . -type f -exec gzip -9 {} \; # for i in $( find . -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done #) mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION # Move documentation to the right place. # omitted: VirtualBox.chm mv \ $PKG/$INST_DIR/{LICENSE,UserManual.pdf} \ $PKG/usr/doc/$PRGNAM-$VERSION 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:-txz}