Added wrapper script and desktop item support to VirtualBox

svn path=/nixpkgs/trunk/; revision=15030
This commit is contained in:
Sander van der Burg 2009-04-14 13:29:19 +00:00
parent 5951e31121
commit 140a3d416f
3 changed files with 87 additions and 5 deletions

View File

@ -1,5 +1,7 @@
{stdenv, fetchurl, iasl, dev86, libxslt, libxml2, libX11, xproto, libXext, libXcursor, qt3, qt4, libIDL, SDL, hal, libcap, zlib, libpng, glib, kernel, python}:
{stdenv, fetchurl, iasl, dev86, libxslt, libxml2, libX11, xproto, libXext, libXcursor, qt3, qt4, libIDL, SDL, hal, libcap, zlib, libpng, glib, kernel, python, which}:
let vboxScript = ./VBox.sh;
in
stdenv.mkDerivation {
name = "virtualbox-2.2.0";
@ -34,14 +36,14 @@ stdenv.mkDerivation {
END_PATHS
'';
buildPhase = "
buildPhase = ''
source env.sh
kmk
cd out/linux.*/release/bin/src
export KERN_DIR=${kernel}/lib/modules/*/build
make
cd ../../../../..
";
'';
installPhase = ''
cd out/linux.*/release/bin
@ -50,8 +52,22 @@ stdenv.mkDerivation {
cd src
kernelVersion=$(cd ${kernel}/lib/modules; ls)
export MODULE_DIR=$out/lib/modules/$kernelVersion/misc
ensureDir $MODULE_DIR
ensureDir $MODULE_DIR
make install
ensureDir $out/bin
cp -v ${vboxScript} $out/bin/VBox.sh
sed -i -e "s|@INSTALL_PATH@|$out/virtualbox|" \
-e "s|@QT4_PATH@|${qt4}/lib|" \
-e "s|which|${which}/bin/which|" \
-e "s|gawk|${stdenv.gawk}/bin/gawk|" \
$out/bin/VBox.sh
chmod 755 $out/bin/VBox.sh
for file in VirtualBox VBoxManage VBoxSDL
do
[ -f "$out/virtualbox/$file" ] && ln -sfv $out/bin/VBox.sh $out/bin/$file
done
ensureDir $out/share/applications
ln -sfv $out/virtualbox/VirtualBox.desktop $out/share/applications
'';
meta = {

View File

@ -0,0 +1,66 @@
#!/bin/sh
INSTALL_PATH="@INSTALL_PATH@"
export LD_LIBRARY_PATH="@INSTALL_PATH@:@QT4_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" "$@"

View File

@ -7263,7 +7263,7 @@ let
virtualbox = import ../applications/virtualization/virtualbox/2.2.0.nix {
inherit stdenv fetchurl iasl dev86 libxslt libxml2 qt3 qt4 SDL hal
libcap libpng zlib kernel python;
libcap libpng zlib kernel python which;
inherit (gtkLibs) glib;
inherit (xlibs) xproto libX11 libXext libXcursor;
inherit (gnome) libIDL;