#!/bin/bash # # virtualbox.SlackBuild # code: Vicious (michal@scxd.info); improvements: Zielony (e-pl@o2.pl) set -e # PACKAGE GENERAL INFO [EDIT] # Wymaga: dev86, iasl, xerces-c++, xalan-c++. PKGNAME=virtualbox VERSION=1.6.0 BUILD=1X ARCH=i686 URL=http://scxd.info/pub/archives/VirtualBox-$VERSION-OSE.tar.bz2 CWD=`pwd` TMP=/tmp/$PKGNAME PKG=$TMP/package if [ ! -d $TMP/$PKGNAME-$VERSION ]; then rm -rf $PKG mkdir -p $PKG/install # PACKAGE DESCRIPTION [EDIT] cat << 'SLACKDESC' | fmt -w $(( 80 - `echo $PKGNAME | wc -c` - 3 )) | perl -pe "s/^/$PKGNAME: /" > $PKG/install/slack-desc VirtualBox (virtual machine) VirtualBox is a general-purpose full virtualizer for x86 hardware. Targeted at server, desktop and embedded use, it is now the only professional-quality virtualization solution. This is the OSE version. Package prepared by Zielony (e-pl@o2.pl) SLACKDESC cd $TMP # step 1: DOWNLOAD SOURCE case "${URL//*\/}" in *.tar.bz2) EXTENSION="tar.bz2"; DECOMPRESS="tar jxvf" ;; *.tar.gz) EXTENSION="tar.gz"; DECOMPRESS="tar zxvf" ;; *.zip) EXTENSION="zip"; DECOMPRESS="unzip" ;; esac PKGFNAME="$PKGNAME-$VERSION.$EXTENSION" ( wget -c $URL -P $TMP -O $PKGFNAME ) # step 2: UNPACK SOURCE AND PREPARE PACKAGE $DECOMPRESS $PKGFNAME DIRNAME=`tar tf $PKGFNAME | head -1` echo $DIRNAME | grep '/' && DIRNAME=${DIRNAME%${DIRNAME#*/}} if [ "$DIRNAME" != "$PKGNAME-$VERSION/" ]; then mv $DIRNAME $PKGNAME-$VERSION; fi chown root:root $TMP -R fi cd $TMP/$PKGNAME-$VERSION case "$ARCH" in "i686") SLKCFLAGS="-O2 -march=i686 -mtune=i686" ;; "i486") SLKCFLAGS="-O2 -march=i486 -mtune=i686" ;; "i386") SLKCFLAGS="-O2 -march=i386 -mcpu=i686" ;; "s390") SLKCFLAGS="-O2" ;; "x86_64") SLKCFLAGS="-O2" ;; *) SLKCFLAGS="-O2" ;; esac if [ ! -e 'env.sh' ]; then if [ -s 'configure' ]; then CFLAGS="$SLKCFLAGS" CXXFLAGS="$SLKCFLAGS" ./configure \ --setup-wine \ --with-qt-dir=/usr/lib/qt \ --disable-pulse \ --nofatal fi cat << 'PATCH' | patch -p0 -N --- src/recompiler/dyngen.c.old 2008-05-29 20:05:09.000000000 +0200 +++ src/recompiler/dyngen.c 2008-05-29 20:06:43.000000000 +0200 @@ -2103,7 +2103,8 @@ fprintf(outfile, " extern char %s;\n", sym_name); #else - fprintf(outfile, "extern char %s;\n", sym_name); + if (strcmp(sym_name, "memcpy")) + fprintf(outfile, "extern char %s;\n", sym_name); #endif } } PATCH fi source env.sh kmk all CFLAGS="$SLKCFLAGS" CXXFLAGS="$SLKCFLAGS" mkdir -p $PKG/usr/bin $PKG/usr/lib/virtualbox \ $PKG/usr/share/{applications,pixmaps} \ $PKG/etc/{vbox,rc.d} \ $PKG/etc/udev/rules.d find . -name *.ko -exec rm -f \{} \; cp -Rf out/linux.x86/release/bin/* $PKG/usr/lib/virtualbox for i in vboxmanage vboxsdl vboxvrdp virtualbox vboxheadless vboxwebsrv; do sed -i "s@$i)@$i)@i" $PKG/usr/lib/virtualbox/VBox.sh ln -sf ../lib/virtualbox/VBox.sh $PKG/usr/bin/$i done ln -sf ../lib/virtualbox $PKG/usr/share/virtualbox mv -f $PKG/usr/lib/virtualbox/VBox.png $PKG/usr/share/pixmaps/vbox.png cat << 'DESKTOP' > $PKG/usr/share/applications/vbox.desktop [Desktop Entry] Encoding=UTF-8 Version=1.0 Name=innotek VirtualBox GenericName=Virtual Machine Type=Application Comment=Run several virtual systems on a single host computer Exec=virtualbox TryExec=virtualbox Path= Icon=vbox.png Categories=Application;Emulator;System; DESKTOP cat << 'CFG' > $PKG/etc/vbox/vbox.cfg # VirtualBox installation directory INSTALL_DIR="/usr/lib/virtualbox" CFG cp -af out/linux.x86/release/obj/src/VBox/Installer/linux/VBoxTunctl/VBoxTunctl \ $PKG/usr/bin/tunctl cp -af src/VBox/Installer/linux/vboxnet.sh.in $PKG/etc/rc.d/rc.vboxnet cp -af src/VBox/Installer/linux/vboxdrv.sh.in $PKG/etc/rc.d/rc.vboxdrv sed -i 's@virtualbox-ose@virtualbox@g' $PKG/etc/rc.d/rc.vboxdrv chmod 755 $PKG/etc/rc.d/* echo 'KERNEL=="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="vboxusers", MODE="0660"' \ > $PKG/etc/udev/rules.d/60-vboxdrv.rules cat << 'DOINST' > $PKG/install/doinst.sh #!/bin/bash /usr/sbin/groupadd vboxusers 2> /dev/null cat << 'INFO' ******************************************************************************** * Remember to run '/etc/rc.d/rc.vboxdrv setup' to compile kernel module. * * * * If you want to run /etc/rc.d/rc.vboxdrv and /etc/rc.d/rc.vboxnet at startup, * * you have to add those to /etc/rc.d/rc.local. * * * * Only users added to vboxusers group are allowed to run virtualbox. * ******************************************************************************** INFO DOINST # step 3: STRIP BINARIES & GZIP MANUALS cd $PKG ( find . | xargs file | grep "executable" | grep ELF | cut -f 1 -d : \ | xargs strip --strip-unneeded 2> /dev/null find . | xargs file | grep "shared object" | grep ELF | cut -f 1 -d : \ | xargs strip --strip-unneeded 2> /dev/null find . | xargs file | grep "current ar archive" | grep ELF | cut -f 1 -d : \ | xargs strip --strip-debug 2> /dev/null ) find $PKG/usr -regex '.+/man/\(.+?/\)?man./.+' -exec gzip -9 \{} \; # step 4: CREATE PACKAGE & CLEAN TMP if [ `find . | wc -l` -le 1 ]; then echo "Brak plików pakietu!" else ( requiredbuilder -y -s $PKG/install $PKG ) makepkg -l y -c n $CWD/$PKGNAME-$VERSION-$ARCH-$BUILD.tgz if [ "$1" != "-nc" ]; then rm -rf $TMP; fi fi