New package: Virtualbox

William Immendorf will.immendorf at gmail.com
Sat Apr 18 06:42:17 PDT 2009


Hey,

I have a sugestion for a new package: Virtualbox. VirtBox (as I refer
to it for short), is a open source/free virtulation program that can
let you run Linux, Windblows, Solaris, etc...

(The instructions are based on CBLFS.)

BTW, to build the OSE edition, you need to have these packages
installed arleady:

 * Which
 * Dev86 (yes, this is the same package you needed to build lilo.
VirtBox needs bcc from this package. Use version 0.16.17, and follow
the same instructions [make && make install]. However, CBLFS uses a
patch to suppress elksemu from building. [mabe it dosen't build with
GCC 4.3?])
 * ACPIA (VirtBox needs iasl from this package to compile some things.
To download it, browse to
http://www.acpica.org/downloads/unix_source_code.php and accept the
license agrement there to get the source for this package. The
compilation instructions are:

cd compiler &&
make &&
cd ../tools/acpisrc &&
make &&
cd ../acpixtract &&
make &&
cd ../acpiexec &&
make &&
cd ../../

And to install the package:

install -m755 -v compiler/iasl /usr/bin &&
install -m755 -v
tools/{acpisrc/acpisrc,acpixtract/acpixtract,acpiexec/acpiexec}
/usr/bin

)
* LibXSLT
* Qt4
* libIDL
* X.org
* SDL
* ALSA
* NSPR

The optional packages are:

* PulseAudio (can be supressed by passing --disable-pulse to configure)
* Python (also can be supressed by passing --disable-python to configure)
* Xulrunner/Firefox (VirtBox uses it for XPCOM, it can be disabled by
passing --disable-xpcom to configure)
* SDL_ttf (new package, it is a extention to SDL for displaying TTF
fonts. It's deps are SDL and Freetype. (meaning that this package can
be compiled right after SDL if you built it for X.org) The compliation
instructions are the standard ./configure --prefix=/usr && make &&
make install. Oh, and this can be disabled by passing
--disable-sdl-ttf to configure.)
* HAL (for hardware dection, can be disabled by passing --disable-dbus
to configure.)
* MesaLib (built as part of X.org, if for some reason someone diddn't
build that package, that persion can pass --disable-opengl to
configure.)

Download location:
http://download.virtualbox.org/virtualbox/2.2.0/VirtualBox-2.2.0-OSE.tar.bz2

And, for the guest additions ISO:
http://download.virtualbox.org/virtualbox/2.2.0/VBoxGuestAdditions_2.2.0.iso

Before compiling VirtBox, run this to add the vboxusers group:

groupadd -g 29 vboxusers

Compilation instructions:

./configure &&
source env.sh &&
kmk

And the instalation instructions:

cd out/linux.*/release/bin &&
install -m755 -d -v /opt/VirtualBox &&
cp -av * /opt/VirtualBox

OK, now you need the kernel module. It can be made and installed by
these commands:

cd src &&
make &&
make install

And then you need to install the guest additions ISO too:

install -m644 -v ../../../../../VBoxGuestAdditions_2.2.0.iso \
    /opt/VirtualBox/additions/VBoxGuestAdditions.iso

Finaly, run these commands as root:

chown -Rv root:root /opt/VirtualBox &&
chmod u+s /opt/VirtualBox/VirtualBox

Configuration:

First, make sure the host loads the vboxdrv kernel module:

echo "vboxdrv" >> /etc/sysconfig/modules

Then create a udev rule for vboxdrv:

cat > /etc/udev/rules.d/90-vboxdev.rules << "EOF"
KERNEL=="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="vboxusers", MODE="0660"
EOF

Then create a helper script to start the speficied service:

cat > /opt/VirtualBox/VBox.sh << "EOF"
#!/bin/sh

INSTALL_PATH="/opt/VirtualBox"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}${LD_LIBRARY_PATH+:}${INSTALL_PATH}"

export USER=$(whoami)

if [ ! -c /dev/vboxdrv ]; then
  echo "/dev/vboxdrv does not exist. Load the kernel module then try again."
  exit 1
fi
if [ ! -r /dev/vboxdrv -o ! -w /dev/vboxdrv ]; then
  echo "User $USER can not read and/or write to /dev/vboxdrv."
  exit 1
fi

echo "/dev/vboxdrv exists and $USER can access it."

SERVER_PID=$(ps -U $USER | grep VBoxSVC | awk '{ print $1 }')
if [ "$1" = "shutdown" ]; then
  if [ -n "$SERVER_PID" ]; then
    echo "Terminating VBoxSVC with PID $SERVER_PID."
    kill -TERM $SERVER_PID
  else
    echo "VBoxSVC Not Currently Running."
  fi
  exit 0
fi

if [ ! -x "$INSTALL_PATH/VBoxSVC" ]; then
  echo "$INSTALL_PATH/VBoxSVC does not exist! Can not continue."
  exit 1
fi

APP=$(which $0)
APP=${APP##/*/}

if [ ! -x "$INSTALL_PATH/$APP" ]; then
  echo "$INSTALL_PATH/$APP does not exist!"
  exit 1
fi
case "$APP" in
  VirtualBox|VBoxManage|VBoxSDL|VBoxVRDP)
    EXEC_APP="$INSTALL_PATH/$APP"
  ;;
  *)
    echo "Unknown application - $APP."
  ;;
esac

if [ -z "$SERVER_PID" ]; then
  rm -rf /tmp/.vbox-$USER-ipc
  echo "Starting VBoxSVC for $USER."
  "$INSTALL_PATH/VBoxSVC" --daemonize
fi

SERVER_PID=$(ps -U $USER | grep VBoxSVC | awk '{ print $1 }')
if [ -z "$SERVER_PID" ]; then
  echo "VBoxSVC failed to start! Can not continue"
  exit 1
fi

echo "VBoxSVC is running for user $USER with PID $SERVER_PID."

echo "Starting $EXEC_APP."
exec "$EXEC_APP" "$@"
EOF

And run links to that script:

for file in VirtualBox VBoxManage VBoxSDL VBoxVRDP; do
  [ -f "/opt/VirtualBox/$file" ] && ln -sfv
"../../opt/VirtualBox/VBox.sh" "/usr/bin/$file"
done

Finaly, create a desktop file for VirtBox:

cat > /usr/share/applications/VirtualBox.desktop << "EOF"
[Desktop Entry]
Encoding=UTF-8
Version=2.2.0
Name=Sun xVM VirtualBox
GenericName=Virtual Machine
Type=Application
Comment=Run several virtual systems on a single host computer
Exec=VirtualBox
TryExec=VirtualBox
Path=
Icon=/opt/VirtualBox/VBox.png
Categories=Application;Emulator;System
EOF

And that's it for the inscrutions! Also, VBOX knows LFS now, so that's
why I sugested that package.



More information about the blfs-dev mailing list