VirtualBox.tmpl.spec revision 17d67aeb3722c094c6493a3e9a9d0cdfb9453ecd
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# Spec file for creating VirtualBox rpm packages
17d67aeb3722c094c6493a3e9a9d0cdfb9453ecdvboxsync# Copyright (C) 2006-2011 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
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# General Public License as published by the Free Software Foundation,
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# distribution. VirtualBox OSE is distributed in the hope that it will
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# 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
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncmv components $RPM_BUILD_ROOT/usr/lib/virtualbox/components
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncmv *.so.4 $RPM_BUILD_ROOT/usr/lib/virtualbox || true
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
c48c4d769ded37e2496f97dddbbd36dc62f244b1vboxsync for i in *; do
24a8dd4360c4b4588fd2c340dd7687379a45e02evboxsync install -d $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/mimetypes
1d17a5f9688f3622ffe088b664588629b1e95801vboxsync mv $i/* $RPM_BUILD_ROOT/usr/share/icons/hicolor/$i/mimetypes
1d17a5f9688f3622ffe088b664588629b1e95801vboxsyncmv virtualbox.xml $RPM_BUILD_ROOT/usr/share/mime/packages
17d67aeb3722c094c6493a3e9a9d0cdfb9453ecdvboxsyncfor i in VBoxManage VBoxSVC VBoxSDL VirtualBox VBoxHeadless VBoxExtPackHelperApp VBoxBalloonCtrl vboxwebsrv webtest; do
81d1b221c2dfff6900e970e273dbb4e81ef6b5d9vboxsyncfor i in VBoxSDL VirtualBox VBoxHeadless VBoxNetDHCP VBoxNetAdpCtl; do
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync chmod 4511 $RPM_BUILD_ROOT/usr/lib/virtualbox/$i; done
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 \
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncfor i in rdesktop-vrdp.tar.gz rdesktop-vrdp-keymaps additions/VBoxGuestAdditions.iso; 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
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
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncln -sf ../etc/init.d/vboxweb-service $RPM_BUILD_ROOT/sbin/rcvboxweb-service
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
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
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# install udev rule (disable with INSTALL_NO_UDEV=1 in /etc/default/virtualbox)
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncif [ -d /etc/udev/rules.d -a "$INSTALL_NO_UDEV" != "1" ]; then
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync if [ "$udev_ver" = "" -o "$udev_ver" -lt 55 ]; then
c6adb272ec43d5eaadb1493cb2bf45f2f8adf588vboxsync usb_createnode="/usr/share/virtualbox/VBoxCreateUSBNode.sh"
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync echo "KERNEL=${udev_fix}\"vboxdrv\", NAME=\"vboxdrv\", OWNER=\"root\", GROUP=\"root\", MODE=\"0600\"" \
9671051adb2703364fe12ed9927291639a0f1c35vboxsync echo "SUBSYSTEM=${udev_fix}\"usb_device\", ACTION=${udev_fix}\"add\", RUN=\"${usb_createnode} \$major \$minor \$attr{bDeviceClass}\"" \
9671051adb2703364fe12ed9927291639a0f1c35vboxsync echo "SUBSYSTEM=${udev_fix}\"usb\", ACTION=${udev_fix}\"add\", ENV{DEVTYPE}==\"usb_device\", RUN=\"${usb_createnode} \$major \$minor \$attr{bDeviceClass}\"" \
9671051adb2703364fe12ed9927291639a0f1c35vboxsync echo "SUBSYSTEM=${udev_fix}\"usb_device\", ACTION=${udev_fix}\"remove\", RUN=\"${usb_createnode} --remove \$major \$minor\"" \
9671051adb2703364fe12ed9927291639a0f1c35vboxsync echo "SUBSYSTEM=${udev_fix}\"usb\", ACTION=${udev_fix}\"remove\", ENV{DEVTYPE}==\"usb_device\", RUN=\"${usb_createnode} --remove \$major \$minor\"" \
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# Remove old udev description file
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync rm -f /etc/udev/rules.d/60-vboxdrv.rules 2> /dev/null
c6adb272ec43d5eaadb1493cb2bf45f2f8adf588vboxsync# Build our device tree
c6adb272ec43d5eaadb1493cb2bf45f2f8adf588vboxsync if test -r "$i/dev"; then
c6adb272ec43d5eaadb1493cb2bf45f2f8adf588vboxsync sh ${usb_createnode} "$major" "$minor" "$class" ${usb_group} 2>/dev/null
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# XXX SELinux: allow text relocation entries
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync chcon -t texrel_shlib_t /usr/lib/virtualbox/*VBox* > /dev/null 2>&1
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync chcon -t texrel_shlib_t /usr/lib/virtualbox/VirtualBox.so > /dev/null 2>&1
b8908d384db2324f04a2f68a13e67ea32ebf609avboxsync chcon -t texrel_shlib_t /usr/lib/virtualbox/VBoxAuth.so > /dev/null 2>&1
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync chcon -t texrel_shlib_t /usr/lib/virtualbox/components/VBox*.so > /dev/null 2>&1
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync chcon -t java_exec_t /usr/lib/virtualbox/VirtualBox > /dev/null 2>&1
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync chcon -t java_exec_t /usr/lib/virtualbox/VBoxSDL > /dev/null 2>&1
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync chcon -t java_exec_t /usr/lib/virtualbox/VBoxHeadless > /dev/null 2>&1
e00d701bbdc8f27f25cc232d9e507622a731b390vboxsync chcon -t java_exec_t /usr/lib/virtualbox/VBoxExtPackHelperApp > /dev/null 2>&1
17d67aeb3722c094c6493a3e9a9d0cdfb9453ecdvboxsync chcon -t java_exec_t /usr/lib/virtualbox/VBoxBalloonCtrl > /dev/null 2>&1
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync chcon -t java_exec_t /usr/lib/virtualbox/vboxwebsrv > /dev/null 2>&1
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!"
17d67aeb3722c094c6493a3e9a9d0cdfb9453ecdvboxsync%{fillup_and_insserv -f -y -Y vboxdrv vboxballoonctrl-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
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."
60b3bb99d58c291474ef79573ae7738ce769fdbbvboxsync # remove our USB device tree
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
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync /sbin/service vboxweb-service restart > /dev/null 2>&1
17d67aeb3722c094c6493a3e9a9d0cdfb9453ecdvboxsync%restart_on_update vboxdrv vboxballoonctrl-service vboxweb-service
c48c4d769ded37e2496f97dddbbd36dc62f244b1vboxsyncupdate-mime-database /usr/share/mime &> /dev/null || :