VirtualBox.tmpl.spec revision 396f76437ff8f66e088cea96fc7474554ea3fb7b
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# Spec file for creating VirtualBox rpm packages
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync# Copyright (C) 2006-2012 Oracle Corporation
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# This file is part of VirtualBox Open Source Edition (OSE), as
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# available from http://www.virtualbox.org. This file is free software;
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# you can redistribute it and/or modify it under the terms of the GNU
d63de4508a08b11f57c307a15eda3cd95485bf2cvboxsync# General Public License (GPL) as published by the Free Software
d63de4508a08b11f57c307a15eda3cd95485bf2cvboxsync# Foundation, in version 2 as it comes in the "COPYING" file of the
d63de4508a08b11f57c307a15eda3cd95485bf2cvboxsync# VirtualBox OSE distribution. VirtualBox OSE is distributed in the
d63de4508a08b11f57c307a15eda3cd95485bf2cvboxsync# hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync%{!?python_sitelib: %define python_sitelib %(%{__python} -c "from distutils.sysconfig import get_python_lib; print get_python_lib()")}
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncVirtualBox is a powerful PC virtualization solution allowing
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncyou to run a wide range of PC operating systems on your Linux
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncsystem. This includes Windows, Linux, FreeBSD, DOS, OpenBSD
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncand others. VirtualBox comes with a broad feature set and
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncexcellent performance, making it the premier virtualization
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# Mandriva: prevent replacing 'echo' by 'gprintf'
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncinstall -m 755 -d $RPM_BUILD_ROOT/usr/share/applications
c6adb272ec43d5eaadb1493cb2bf45f2f8adf588vboxsyncinstall -m 755 -d $RPM_BUILD_ROOT/usr/share/icons/hicolor
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncinstall -m 755 -d $RPM_BUILD_ROOT%{_defaultdocdir}/virtualbox
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncinstall -m 755 -d $RPM_BUILD_ROOT/usr/lib/virtualbox
58b7773f17a933ab8d53f450bed0afcf2f003508vboxsyncinstall -m 755 -d $RPM_BUILD_ROOT/usr/lib/virtualbox/ExtensionPacks
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncinstall -m 755 -d $RPM_BUILD_ROOT/usr/share/virtualbox
c48c4d769ded37e2496f97dddbbd36dc62f244b1vboxsyncinstall -m 755 -d $RPM_BUILD_ROOT/usr/share/mime/packages
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncmv VBoxEFI32.fd $RPM_BUILD_ROOT/usr/lib/virtualbox || true
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncmv VBoxEFI64.fd $RPM_BUILD_ROOT/usr/lib/virtualbox || true
e7159a7ab092aaf8a7423d811c2b7a8286e2669bvboxsyncif [ -f VBoxVolInfo ]; then
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncmv components $RPM_BUILD_ROOT/usr/lib/virtualbox/components
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncmv *.so.4 $RPM_BUILD_ROOT/usr/lib/virtualbox || true
a48f6e21f8737ef47d30d716171ae2bcb10c3382vboxsyncln -s ../VBoxVMM.so $RPM_BUILD_ROOT/usr/lib/virtualbox/components/VBoxVMM.so
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync %{__python} ./vboxapisetup.py install --prefix %{_prefix} --root $RPM_BUILD_ROOT)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncmv VBoxSysInfo.sh $RPM_BUILD_ROOT/usr/share/virtualbox
c6adb272ec43d5eaadb1493cb2bf45f2f8adf588vboxsyncmv VBoxCreateUSBNode.sh $RPM_BUILD_ROOT/usr/share/virtualbox
b28fef07fef379ecc179e0bc0d5d1be753e482b5vboxsynccp icons/128x128/virtualbox.png $RPM_BUILD_ROOT/usr/share/pixmaps/virtualbox.png
c48c4d769ded37e2496f97dddbbd36dc62f244b1vboxsync for i in *; do
257927abbaa6d9774427049fcbea552cda362281vboxsync install -d $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/apps
bc9b73486456ff24179b43bb413c0f9c13ff64c4vboxsync mv $i/virtualbox.* $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/apps
24a8dd4360c4b4588fd2c340dd7687379a45e02evboxsync install -d $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/mimetypes
3c49234930c10a52368b992781dae0306a72b5f5vboxsync mv $i/* $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/mimetypes || true
1d17a5f9688f3622ffe088b664588629b1e95801vboxsyncmv virtualbox.xml $RPM_BUILD_ROOT/usr/share/mime/packages
396f76437ff8f66e088cea96fc7474554ea3fb7bvboxsyncfor i in VBoxManage VBoxSVC VBoxSDL VirtualBox VBoxHeadless VBoxExtPackHelperApp VBoxBalloonCtrl VBoxAutostart vbox-img; do
20fc4a350a4a8e56ffaac6cf57dcd677a7ac36c5vboxsyncfor i in VBoxSDL VirtualBox VBoxHeadless VBoxNetDHCP VBoxNetNAT VBoxNetAdpCtl; do
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/$i; done
e7159a7ab092aaf8a7423d811c2b7a8286e2669bvboxsyncif [ -f $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxVolInfo ]; then
e7159a7ab092aaf8a7423d811c2b7a8286e2669bvboxsync chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/VBoxVolInfo
4bc1bbf45f30ff3ca38c2ad006836e490972c7ccvboxsync mv ExtensionPacks/VNC $RPM_BUILD_ROOT/usr/lib/virtualbox/ExtensionPacks
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync --save-module-symvers /tmp/vboxdrv-Module.symvers \
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync KBUILD_VERBOSE= KERN_DIR=$d/build MODULE_DIR=$RPM_BUILD_ROOT/$d/misc -j4 \
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync KBUILD_VERBOSE= KERN_DIR=$d/build MODULE_DIR=$RPM_BUILD_ROOT/$d/misc -j4 \
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync KBUILD_VERBOSE= KERN_DIR=$d/build MODULE_DIR=$RPM_BUILD_ROOT/$d/misc -j4 \
9704f1d0180960069e2c4eb8fe2ddee350910e5dvboxsync KBUILD_VERBOSE= KERN_DIR=$d/build MODULE_DIR=$RPM_BUILD_ROOT/$d/misc -j4 \
a3d06a524c4f1cde2f0eada83656543d5a24115dvboxsync for i in rdesktop-vrdp.tar.gz rdesktop-vrdp-keymaps; do
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncif [ -d accessible ]; then
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncinstall -D -m 755 vboxdrv.init $RPM_BUILD_ROOT%{_initrddir}/vboxdrv
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncln -sf ../etc/init.d/vboxdrv $RPM_BUILD_ROOT/sbin/rcvboxdrv
17d67aeb3722c094c6493a3e9a9d0cdfb9453ecdvboxsyncinstall -D -m 755 vboxballoonctrl-service.init $RPM_BUILD_ROOT%{_initrddir}/vboxballoonctrl-service
87c50c527af59e43745475c4b8ac907c5f9bc204vboxsyncinstall -D -m 755 vboxautostart-service.init $RPM_BUILD_ROOT%{_initrddir}/vboxautostart-service
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncinstall -D -m 755 vboxweb-service.init $RPM_BUILD_ROOT%{_initrddir}/vboxweb-service
17d67aeb3722c094c6493a3e9a9d0cdfb9453ecdvboxsyncln -sf ../etc/init.d/vboxballoonctrl-service $RPM_BUILD_ROOT/sbin/rcvboxballoonctrl-service
87c50c527af59e43745475c4b8ac907c5f9bc204vboxsyncln -sf ../etc/init.d/vboxautostart-service $RPM_BUILD_ROOT/sbin/rcvboxautostart-service
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncln -sf ../etc/init.d/vboxweb-service $RPM_BUILD_ROOT/sbin/rcvboxweb-service
396f76437ff8f66e088cea96fc7474554ea3fb7bvboxsyncln -s /usr/lib/virtualbox/vbox-img $RPM_BUILD_ROOT/usr/bin/vbox-img
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsyncln -s /usr/share/virtualbox/src/vboxhost $RPM_BUILD_ROOT/usr/src/vboxhost-%VER%
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncmv virtualbox.desktop $RPM_BUILD_ROOT/usr/share/applications/virtualbox.desktop
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncmv VBox.png $RPM_BUILD_ROOT/usr/share/pixmaps/VBox.png
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync# check for active VMs of the installed (old) package
cf5af7fccfec4bef83f4ec21662d6a6e6cbe3835vboxsyncif [ -n "$VBOXSVC_PID" ]; then
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync # executed before the new package is installed!
17d67aeb3722c094c6493a3e9a9d0cdfb9453ecdvboxsync if [ -f /etc/init.d/vboxballoonctrl-service ]; then
17d67aeb3722c094c6493a3e9a9d0cdfb9453ecdvboxsync # try graceful termination; terminate the balloon control service first
17d67aeb3722c094c6493a3e9a9d0cdfb9453ecdvboxsync /etc/init.d/vboxballoonctrl-service stop 2>/dev/null || true
87c50c527af59e43745475c4b8ac907c5f9bc204vboxsync # try graceful termination; terminate the autostart service first
87c50c527af59e43745475c4b8ac907c5f9bc204vboxsync /etc/init.d/vboxautostart-service stop 2>/dev/null || true
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync # try graceful termination; terminate the webservice first
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync /etc/init.d/vboxweb-service stop 2>/dev/null || true
17d67aeb3722c094c6493a3e9a9d0cdfb9453ecdvboxsync # ask the daemon to terminate immediately
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync echo "A copy of VirtualBox is currently running. Please close it and try again."
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync echo "Please note that it can take up to ten seconds for VirtualBox (in particular"
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync echo "the VBoxSVC daemon) to finish running."
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# check for old installation
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync if [ "x$INSTALL_DIR" != "x" -a -d "$INSTALL_DIR" ]; then
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync echo "An old installation of VirtualBox was found. To install this package the"
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync echo "old package has to be removed first. Have a look at /etc/vbox/vbox.cfg to"
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync echo "determine the installation directory of the previous installation. After"
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync echo "uninstalling the old package remove the file /etc/vbox/vbox.cfg."
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# XXX remove old modules from previous versions (disable with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync find /lib/modules -name "vboxdrv\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync find /lib/modules -name "vboxnetflt\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync find /lib/modules -name "vboxnetadp\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
9704f1d0180960069e2c4eb8fe2ddee350910e5dvboxsync find /lib/modules -name "vboxpci\.*" 2>/dev/null|xargs rm -f 2> /dev/null || true
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync[ -r /etc/default/virtualbox ] && . /etc/default/virtualbox
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# remove old cruft
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync echo "Found old version of /etc/init.d/vboxdrv.sh, removing."
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync echo "Found old version of /etc/vbox/vbox.cfg, removing."
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# XXX SELinux: allow text relocation entries
45c2de093cddc990b8d1583aa49b9a40de7a3d97vboxsyncset_selinux_permissions /usr/lib/virtualbox /usr/share/virtualbox
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# create users groups (disable with INSTALL_NO_GROUP=1 in /etc/default/virtualbox)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync echo "Creating group 'vboxusers'. VM users must be member of that group!"
d15e1d56958bda40cd12a7c3a71c962b5a710be2vboxsync# install udev rule (disable with INSTALL_NO_UDEV=1 in /etc/default/virtualbox)
d15e1d56958bda40cd12a7c3a71c962b5a710be2vboxsync# and /dev/vboxdrv and /dev/vboxusb/*/* device nodes
d15e1d56958bda40cd12a7c3a71c962b5a710be2vboxsyncinstall_device_node_setup root 0600 /usr/share/virtualbox "${usb_group}"
87c50c527af59e43745475c4b8ac907c5f9bc204vboxsync%{fillup_and_insserv -f -y -Y vboxdrv vboxballoonctrl-service vboxautostart-service vboxweb-service}
c48c4d769ded37e2496f97dddbbd36dc62f244b1vboxsyncupdate-mime-database /usr/share/mime &> /dev/null || :
c48c4d769ded37e2496f97dddbbd36dc62f244b1vboxsyncgtk-update-icon-cache -q /usr/share/icons/hicolor 2> /dev/null || :
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync# Disable module compilation with INSTALL_NO_VBOXDRV=1 in /etc/default/virtualbox
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsyncif [ ! -f /lib/modules/`uname -r`/misc/vboxdrv.ko ]; then
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync # compile problem
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncNo precompiled module for this kernel found -- trying to build one. Messages
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncemitted during module compilation will be logged to $LOG.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# if INSTALL_NO_VBOXDRV is set to 1, remove all shipped modules
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync if [ -n "$DKMS" ]; then
f5ab5688c35373443d953e2a9fa8a054defdece8vboxsync $DKMS remove -m vboxhost -v %VER% --all > /dev/null 2>&1 || true
17d67aeb3722c094c6493a3e9a9d0cdfb9453ecdvboxsync/etc/init.d/vboxballoonctrl-service start > /dev/null
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync# $1==0: remove the last version of the package
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync# $1==1: install the first time
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync# $1>=2: upgrade
17d67aeb3722c094c6493a3e9a9d0cdfb9453ecdvboxsync /sbin/service vboxballoonctrl-service stop > /dev/null
87c50c527af59e43745475c4b8ac907c5f9bc204vboxsync /sbin/service vboxautostart-service stop > /dev/null
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync # check for active VMs
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync if [ -n "$VBOXSVC_PID" ]; then
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync echo "A copy of VirtualBox is currently running. Please close it and try again."
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync echo "Please note that it can take up to ten seconds for VirtualBox (in particular"
0c587d7af645db20acefebcfc15b6f46c440ba4avboxsync echo "the VBoxSVC daemon) to finish running."
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncif [ -n "$DKMS" ]; then
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync $DKMS remove -m vboxhost -v %VER% --all > /dev/null 2>&1 || true
17d67aeb3722c094c6493a3e9a9d0cdfb9453ecdvboxsync /sbin/service vboxballoonctrl-service restart > /dev/null 2>&1
87c50c527af59e43745475c4b8ac907c5f9bc204vboxsync /sbin/service vboxautostart-service restart > /dev/null 2>&1
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync /sbin/service vboxweb-service restart > /dev/null 2>&1
87c50c527af59e43745475c4b8ac907c5f9bc204vboxsync%restart_on_update vboxdrv vboxballoonctrl-service vboxautostart-service vboxweb-service
c48c4d769ded37e2496f97dddbbd36dc62f244b1vboxsyncupdate-mime-database /usr/share/mime &> /dev/null || :