VirtualBox.tmpl.spec revision cf5af7fccfec4bef83f4ec21662d6a6e6cbe3835
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# Spec file for creating VirtualBox rpm packages
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# Copyright (C) 2006-2010 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()")}
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncLicense: VirtualBox Personal Use and Evaluation License (PUEL)
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
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncinstall -m 755 -d $RPM_BUILD_ROOT%{_defaultdocdir}/virtualbox
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncinstall -m 755 -d $RPM_BUILD_ROOT/usr/lib/virtualbox
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncinstall -m 755 -d $RPM_BUILD_ROOT/usr/share/virtualbox
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
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncfor i in VBoxManage VBoxSVC VBoxSDL VirtualBox VBoxHeadless vboxwebsrv webtest; do
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncfor 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
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncinstall -D -m 755 vboxweb-service.init $RPM_BUILD_ROOT%{_initrddir}/vboxweb-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
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# check for active VMs
cf5af7fccfec4bef83f4ec21662d6a6e6cbe3835vboxsyncif [ -n "$VBOXSVC_PID" ]; then
cf5af7fccfec4bef83f4ec21662d6a6e6cbe3835vboxsync # try graceful termination; terminate the webservice first
cf5af7fccfec4bef83f4ec21662d6a6e6cbe3835vboxsync echo "A copy of VirtualBox is currently running. Please close it and try again. Please note"
cf5af7fccfec4bef83f4ec21662d6a6e6cbe3835vboxsync echo "that it can take up to ten seconds for VirtualBox (in particular the VBoxSVC daemon) to"
cf5af7fccfec4bef83f4ec21662d6a6e6cbe3835vboxsync echo "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
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync echo "KERNEL=${udev_fix}\"vboxdrv\", NAME=\"vboxdrv\", OWNER=\"root\", GROUP=\"root\", MODE=\"0600\"" \
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync echo "SUBSYSTEM=${udev_fix}\"usb_device\", GROUP=\"vboxusers\", MODE=\"0664\"" \
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync echo "SUBSYSTEM=${udev_fix}\"usb\", ENV{DEVTYPE}==\"usb_device\", GROUP=\"vboxusers\", MODE=\"0664\"" \
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# Remove old udev description file
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync rm -f /etc/udev/rules.d/60-vboxdrv.rules 2> /dev/null
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# Push the permissions to the USB device nodes. One of these should match.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# Rather nasty to use udevadm trigger for this, but I don't know of any
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# better way.
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncudevadm trigger --subsystem-match=usb > /dev/null 2>&1
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncudevtrigger --subsystem-match=usb_device > /dev/null 2>&1
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
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync chcon -t texrel_shlib_t /usr/lib/virtualbox/VRDPAuth.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
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!"
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
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsync# check for active VMs
cf5af7fccfec4bef83f4ec21662d6a6e6cbe3835vboxsyncif [ -n "$VBOXSVC_PID" ]; then
cf5af7fccfec4bef83f4ec21662d6a6e6cbe3835vboxsync # try graceful termination; terminate the webservice first
cf5af7fccfec4bef83f4ec21662d6a6e6cbe3835vboxsync echo "A copy of VirtualBox is currently running. Please close it and try again. Please note"
cf5af7fccfec4bef83f4ec21662d6a6e6cbe3835vboxsync echo "that it can take up to ten seconds for VirtualBox (in particular the VBoxSVC daemon) to"
cf5af7fccfec4bef83f4ec21662d6a6e6cbe3835vboxsync echo "finish running."
5f9dfb422a6ed57822f9c0cb94fa7df8d24acc9bvboxsyncif [ -n "$DKMS" ]; then
7eaaa8a4480370b82ef3735994f986f338fb4df2vboxsync $DKMS remove -m vboxhost -v %VER% --all > /dev/null 2>&1 || true