There are more recent changes to this page which have not yet been approved, click "edit page" to see it.
# Warning: VirtualBox source ships with many blobs, these instructions try to remove and substitute them but may miss some
# Note: VirtualBox can currently only be built on 32-bit x86 systems or 64-bit systems with multilib, which the AOS buildscript doesn't do.

# Note: depends on mesa
# Note: depends on dev86
# Note: depends on libxml2
# Note: depends on libIDL
# Note: depends on libXmu
# Note: depends on serf (provides http-support for subversion)
# Note: depends on subversion
# Note: depends on acpica
# Note: depends on cdrtools
# Note: depends on SDL
# Note: depends on autoconf
# Note: depends on automake
# Note: depends on openssl
# Note: depends on curl
# Note: depends on libpng
# Note: depends on libXcursor
# Note: depends on libXinerama
# Note: depends on libXrandr
# Note: depends on glu
# Note: depends on pulseaudio
# Note: depends on alsa-lib
# Note: depends on libcap
# Note: depends on makeself
# Note: depends on yasm
# Note: depends on qt4
# Note: depends on texlive
# Note: depends on texinfo
wget -c http://download.virtualbox.org/virtualbox/4.2.18/VirtualBox-4.2.18.tar.bz2
tar -xjf VirtualBox-4.2.18.tar.bz2
cd VirtualBox-4.2.18
# Clear out binary blobs
rm -rf kBuild*
rm -rf tools/*.*6*
rm -rf src/libs/libxml2-2.6.31
rm -rf src/libs/kStuff/kStuff/kLdr/testcase/bin
rm -rf src/VBox/Main/webservice/jaxlibs

# Use the system's tools instead
ln -s /usr tools/linux.x86
# Build specific kBuild version to replace the included blob
ln -s kBuild_build/kBuild kBuild
svn co -r 2680 http://svn.netlabs.org/repos/kbuild/trunk kBuild_build
cd kBuild_build
rm -rf kBuild/bin
sed -i -e 's/-O3/-O2/' Config.kmk # Too much optimization triggers a bug
sed -i -e 's|s/URL|s/^URL|' Config.kmk # Work around odd "empty variable" error
kBuild/env.sh --full make -f bootstrap.gmk
cd ..

# Now build the actual virtualbox package
./configure --enable-webservice --disable-java --nofatal --enable-vnc --enable-vde
source ./env.sh
echo 'VBOX_WITH_PAM=' >> Config.kmk # Disable PAM support+dependency, unless you use PAM
echo 'VBOX_PATH_APP_PRIVATE_ARCH := /usr/lib/virtualbox' > LocalConfig.kmk
echo 'VBOX_PATH_SHARED_LIBS := $(VBOX_PATH_APP_PRIVATE_ARCH)' >> LocalConfig.kmk
echo 'VBOX_WITH_ORIGIN :=' >> LocalConfig.kmk
echo 'VBOX_WITH_RUNPATH := $(VBOX_PATH_APP_PRIVATE_ARCH)' >> LocalConfig.kmk
echo 'VBOX_PATH_APP_PRIVATE := /usr/share/virtualbox' >> LocalConfig.kmk
echo 'VBOX_PATH_APP_DOCS := /usr/share/doc/virtualbox' >> LocalConfig.kmk
kmk # Doesn't mind -j#
# Install
cp -r out/*/release/bin /usr/lib/virtualbox
chown -R 0.0 /usr/lib/virtualbox
chmod +s /usr/lib/virtualbox/VirtualBox /usr/lib/virtualbox/VBoxManage /usr/lib/virtualbox/VBoxHeadless /usr/lib/virtualbox/VBoxTunctl
ln -s ../lib/virtualbox/VirtualBox ../lib/virtualbox/VBoxManage ../lib/virtualbox/VBoxHeadless /usr/bin
install out/*/release/bin/virtualbox.desktop /usr/share/applications
# Install icons
for size in `ls out/*/release/bin/icons`; do
  if [ -e out/*/release/bin/icons/${size}/virtualbox.* ]; then
    mkdir -p "/usr/share/icons/hicolor/${size}/apps"
    install out/*/release/bin/icons/${size}/virtualbox.* "/usr/share/icons/hicolor/${size}/apps"
  fi
  if ls out/*/release/bin/icons/${size} | grep -q virtualbox-; then
    mkdir -p "/usr/share/icons/hicolor/${size}/mimetypes"
    install out/*/release/bin/icons/${size}/virtualbox-* "/usr/share/icons/hicolor/${size}/mimetypes"
  fi
done

# Kernel module:
cd out/*/release/bin/src
make
make install