desktop/virtualbox/PKGBUILD
2012-09-09 10:51:27 +00:00

170 lines
7.0 KiB
Bash

#
# Apps Packages for Chakra, part of chakra-project.org
#
# Maintainer abveritas@chakra-project.org
# Contributor: Sebastien Luttringer <seblu[plus]arch[at]seblu[dot]net>
pkgname=virtualbox
pkgver=4.1.22
_build=80657
pkgrel=1
pkgdesc='Oracle VM VirtualBox Binary Edition'
arch=('i686' 'x86_64')
url='http://virtualbox.org/'
license=('GPL2')
depends=('libidl2' 'libxcursor' 'libxinerama' 'libxslt' 'curl' 'linux-headers'
'python2' 'make' 'gcc')
options=('!strip')
optdepends=('virtualbox-ext-oracle: for Oracle extensions'
'dkms: for handling kernel modules with dkms'
'qt: for GUI support'
'sdl: for VBoxSDL and GUI support'
'mesa: for OpenGL support'
'libgl: for shared OpenGL support'
'libxt: for shared clipboard support'
'alsa-lib: for ALSA support'
'pulseaudio: for PulseAudio support')
provides=("virtualbox=${pkgver}")
conflicts=('virtualbox' 'virtualbox-ose' 'virtualbox-modules')
categories=('system')
backup=('etc/vbox/vbox.cfg' 'etc/conf.d/vboxdrv' 'etc/conf.d/vboxweb')
install='install'
screenshot='https://www.virtualbox.org/raw-attachment/wiki/Screenshots/gnome.png'
_sarch='x86'
[ "${CARCH}" = 'x86_64' ] && _sarch='amd64'
source=(
"VirtualBox-${pkgver}-${_build}-Linux_${_sarch}.run::http://download.virtualbox.org/virtualbox/${pkgver}/VirtualBox-${pkgver}-${_build}-Linux_${_sarch}.run"
'10-vboxdrv.rules'
'vboxdrv.rc'
'vboxdrv.conf'
'vboxweb.rc'
'vboxweb.conf'
'vboxdrv.service'
'vboxweb.service'
)
sha256sums=('d53a5cc2d1b9431d4f9443462b84549678e943be1d8b4a714d7844c741507c76'
'69417a9e8855cab8e4878886abe138f559fd17ae487d4cd19c8a24974a8bbec2'
'578b63ab173cdcd9169d8aff00caf48668e46a6886bb90fd34a0fbe63e180a4e'
'71740893a5f226f9d9fcc607ab9d39b7de816b2759625b34da19162bc7e579ff'
'656905de981ffa24f6f921c920538854a235225053f44baedacc07b46ca0cf56'
'12dbba3b59991f2b68cddeeeda20236aeff63e11b7e2d1b08d9d6a82225f6651'
'b8d4d82c90f81af67f7449d880430bda4d1d73c571851f40c339faee809d7239'
'e6e875ef186578b53106d7f6af48e426cdaf1b4e86834f01696b8ef1c685787f')
[[ "${CARCH}" = i686 ]] && sha256sums[0]='e084db553064fb85136df22d13f262fef602daca56b95799cef7df761310a8d5'
_installdir='/opt/VirtualBox'
package() {
# Check and unpack the run package via sh(1)
sh "VirtualBox-${pkgver}-${_build}-Linux_${_sarch}.run" --check
echo yes | sh "VirtualBox-${pkgver}-${_build}-Linux_${_sarch}.run" --target "${srcdir}" \
--nox11 --noexec &> /dev/null
# Unpack bundled files
install -d "${pkgdir}/${_installdir}"
cd "${pkgdir}/${_installdir}"
tar -xjf "${srcdir}/VirtualBox.tar.bz2"
# Hardened build: Mark binaries suid root, create symlinks for working around
# unsupported $ORIGIN/.. in VBoxC.so and make sure the
# directory is only writable by the user (paranoid).
chmod 4511 VirtualBox VBox{SDL,Headless,NetDHCP,NetAdpCtl}
for _lib in VBox{VMM,REM,RT,DDU,XPCOM}.so; do
ln -sf "${_installdir}/${_lib}" "components/${_lib}"
done
chmod go-w .
# Replace VirtualBox built-in Qt by system Qt libraries (disabled as of
# 2010-03-26, 3.1.6-1)
#for _lib in libQt{Core,Gui,Network,OpenGL}; do
# rm "${_lib}VBox.so.4"
# ln -s "/usr/lib/${_lib}.so.4" "${_lib}VBox.so.4"
#done
# Patch "vboxshell.py" to use Python 2.x instead of Python 3
sed -i 's#/usr/bin/python#\02#' "${pkgdir}/${_installdir}/vboxshell.py"
# Update new initscripts way of life in VBox.sh
sed -i -e 's,sudo /etc/init.d/vboxdrv setup,/etc/rc.d/vboxdrv setup,g' \
"${pkgdir}/${_installdir}/VBox.sh"
sed -i -e 's,sudo /etc/init.d/vboxdrv restart,/etc/rc.d/vboxdrv restart,g' \
"${pkgdir}/${_installdir}/VBox.sh"
# Install vboxdrv initscript
install -D -m 0755 "${srcdir}/vboxdrv.rc" "${pkgdir}/etc/rc.d/vboxdrv"
install -D -m 0644 "${srcdir}/vboxdrv.conf" "${pkgdir}/etc/conf.d/vboxdrv"
# Install vboxweb initscript
install -D -m 0755 "${srcdir}/vboxweb.rc" "${pkgdir}/etc/rc.d/vboxweb"
install -D -m 0644 "${srcdir}/vboxweb.conf" "${pkgdir}/etc/conf.d/vboxweb"
# Install udev rules
install -D -m 0644 "${srcdir}/10-vboxdrv.rules" "${pkgdir}/lib/udev/rules.d/10-vboxdrv.rules"
ln -s "${_installdir}/VBoxCreateUSBNode.sh" "${pkgdir}/lib/udev/VBoxCreateUSBNode.sh"
# Install the SDK
cd "${pkgdir}/${_installdir}/sdk/installer"
VBOX_INSTALL_PATH="${_installdir}" python2 vboxapisetup.py install --root "${pkgdir}"
rm -r -f build
cd "${pkgdir}/${_installdir}"
# Symlink the launchers. Second link can fail if fs is not case sensitive.
install -d -m 0755 "${pkgdir}/usr/bin"
for _bin in VirtualBox VBox{Headless,Manage,SDL,SVC,Tunctl,NetAdpCtl} rdesktop-vrdp; do
ln -s "${_installdir}/${_bin}" "${pkgdir}/usr/bin/${_bin}"
ln -s "${_installdir}/${_bin}" "${pkgdir}/usr/bin/${_bin,,}" &>/dev/null || :
done
# Symlink the desktop icon and ".desktop" files
install -d -m 0755 "${pkgdir}/usr/"{share/applications,share/pixmaps}
ln -s "${_installdir}/VBox.png" "${pkgdir}/usr/share/pixmaps/VBox.png"
ln -s "${_installdir}/icons/128x128/virtualbox.png" "${pkgdir}/usr/share/pixmaps/virtualbox.png"
ln -s "${_installdir}/virtualbox.desktop" "${pkgdir}/usr/share/applications/virtualbox.desktop"
# Symlink mime info
install -d -m 0755 "${pkgdir}/usr/share/mime/packages"
ln -s "${_installdir}/virtualbox.xml" "${pkgdir}/usr/share/mime/packages/virtualbox.xml"
# Symlink doc
install -d -m 0755 "${pkgdir}/usr/share/doc/${pkgname}"
ln -s "${_installdir}/VirtualBox.chm" "${pkgdir}/usr/share/doc/$pkgname/virtualbox.chm"
# Symlink module sources
install -d -m 0755 "${pkgdir}/usr/src"
ln -s "${_installdir}/src/vboxhost" "${pkgdir}/usr/src/vboxhost-${pkgver}"
# Symlink icons
cd "${pkgdir}/${_installdir}/icons"
for _dir in *; do
cd "${_dir}"
install -d -m 0755 "${pkgdir}/usr/share/icons/hicolor/${_dir}/"{apps,mimetypes}
for _icon in *; do
if [[ "${_icon}" = 'virtualbox.png' ]]; then
ln -s "${_installdir}/icons/${_dir}/${_icon}" "${pkgdir}/usr/share/icons/hicolor/${_dir}/apps/${_icon}"
else
ln -s "${_installdir}/icons/${_dir}/${_icon}" "${pkgdir}/usr/share/icons/hicolor/${_dir}/mimetypes/${_icon}"
fi
done
cd - >/dev/null
done
# Write the configuration file
install -d -m 0755 "${pkgdir}/etc/vbox"
echo "# VirtualBox installation directory" > "${pkgdir}/etc/vbox/vbox.cfg"
echo "INSTALL_DIR='${_installdir}'" >> "${pkgdir}/etc/vbox/vbox.cfg"
echo "# VirtualBox version" >> "${pkgdir}/etc/vbox/vbox.cfg"
echo "INSTALL_VER='${pkgver}'" >> "${pkgdir}/etc/vbox/vbox.cfg"
echo "INSTALL_REV='${_build}'" >> "${pkgdir}/etc/vbox/vbox.cfg"
chmod 0644 "${pkgdir}/etc/vbox/vbox.cfg"
# Create the directory below if it doesn't exist
install -d -m 0755 "${pkgdir}/var/run/VirtualBox"
# Install systemd services
install -D -m644 "$srcdir/vboxweb.service" "$pkgdir/usr/lib/systemd/system/vboxweb.service"
install -D -m644 "$srcdir/vboxservice.service" "$pkgdir/usr/lib/systemd/system/vboxservice.service"
}