Commit f3b837d6 authored by Seblu's avatar Seblu
Browse files

virtualbox_bin-2


git-svn-id: https://seblu.net/s/archpkg@34 02741741-5192-46b8-8916-7152b19231d9
parent 1b359875
Loading
Loading
Loading
Loading
+23 −9
Original line number Diff line number Diff line
# Maintainer: Lukas Fleischer <archlinux at cryptocrack dot de>
# Maintainer: Sebastien Luttringer <seblu+arch@seblu.net>
# Contributor: Lukas Fleischer <archlinux at cryptocrack dot de>
# Contributor: thotypous <matiasΘarchlinux-br·org>
# Contributor: xduugu <xduuguΘgmx·com>
# Contributor: Peter 'piie' Feuerer <peterΘpiie·net>
@@ -8,8 +9,8 @@
pkgname=virtualbox_bin
pkgver=4.0.0
_build=69151
pkgrel=1
pkgdesc='Oracle VirtualBox Binary Edition'
pkgrel=2
pkgdesc='Oracle VM VirtualBox Binary Edition'
arch=('i686' 'x86_64')
url='http://virtualbox.org'
license=('GPL2')
@@ -23,7 +24,7 @@ optdepends=('virtualbox-ext-oracle: for Oracle extensions'
            'alsa-lib: for ALSA support'
            'pulseaudio: for PulseAudio support')
provides=("virtualbox=${pkgver}")
conflicts=('virtualbox' 'virtualbox-modules')
conflicts=('virtualbox' 'virtualbox-ose' 'virtualbox-modules')
backup=('etc/vbox/vbox.cfg')
install='virtualbox.install'
_arch='x86'
@@ -47,8 +48,6 @@ build() {
  cd "${pkgdir}/opt/VirtualBox"
  tar -xjf "${srcdir}/VirtualBox.tar.bz2"

  install -d "${pkgdir}/usr/"{bin,share/applications,share/pixmaps}

  # 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).
@@ -90,19 +89,34 @@ build() {
  install -Dm0644 "${srcdir}/10-vboxdrv.rules" "${pkgdir}/lib/udev/rules.d/10-vboxdrv.rules"

  # Symlink the launchers
  install -d "${pkgdir}/usr/bin"
  for _bin in VirtualBox VBox{Headless,Manage,SDL,SVC,Tunctl,NetAdpCtl} rdesktop-vrdp; do
    ln -s "/opt/VirtualBox/${_bin}" "${pkgdir}/usr/bin/${_bin}"
  done

  # Symlink the desktop icon and ".desktop" files
  ln -s /opt/VirtualBox/VBox.png "${pkgdir}/usr/share/pixmaps/VBox.png"
  ln -s /opt/VirtualBox/virtualbox.desktop "${pkgdir}/usr/share/applications/VirtualBox.desktop"
  install -d "${pkgdir}/usr/"{share/applications,share/pixmaps}
  ln -s "/opt/VirtualBox/VBox.png" "${pkgdir}/usr/share/pixmaps/VBox.png"
  ln -s "/opt/VirtualBox/virtualbox.desktop" "${pkgdir}/usr/share/applications/VirtualBox.desktop"

  # Symlink mime info
  install -d "${pkgdir}/usr/share/mime/packages"
  ln -s "/opt/VirtualBox/virtualbox.xml" "${pkgdir}/usr/share/mime/packages/virtualbox.xml"

  # Symlink doc
  install -d "${pkgdir}/usr/share/doc/${pkgname}"
  ln -s "/opt/VirtualBox/VirtualBox.chm" "${pkgdir}/usr/share/doc/$pkgname/VirtualBox.chm"

  # Symlink the license
  install -d "${pkgdir}/usr/share/licenses/${pkgname}"
  ln -s /opt/VirtualBox/LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/PUEL"
  ln -s /opt/VirtualBox/LICENSE "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"

  # Setup configuration
  install -d "${pkgdir}/etc/vbox"
  echo 'INSTALL_DIR="/opt/VirtualBox"' > "${pkgdir}/etc/vbox/vbox.cfg"
  
  # Create the directory below if it doesn't exist
  install -d "${pkgdir}/var/run/VirtualBox"
}

# vim:set ts=2 sw=2 ft=sh et:
+28 −71
Original line number Diff line number Diff line
# $1: The new package version
post_install() {
  # Build new module
  /etc/rc.d/vboxdrv setup

  # Add vboxusers group, GID 108 is reserved (http://wiki.archlinux.org/index.php/UID_and_GID_list),
  # but in some systems it may be being used - please replace if needed.
  groupadd -f -g 108 vboxusers

  # Create the directory below if it doesn't exist
  mkdir -p "/var/run/VirtualBox"
  getent group vboxusers >> /dev/null || groupadd -f -g 108 vboxusers

  # Load new udev rule for module vboxdrv
  udevadm control --reload-rules

  # Show the license
  echo >&2
  echo '==> You must agree to the following license in order to use this program:' >&2
  echo '------------------------------------------------------------------------' >&2
  echo >&2
  cat "/opt/VirtualBox/LICENSE" >&2
  echo >&2
  echo '------------------------------------------------------------------------' >&2
  # Update mime database
  [ -x usr/bin/update-mime-database ] && update-mime-database /usr/share/mime &>/dev/null

  # Build new module
  /etc/rc.d/vboxdrv setup
  
  # Show warnings
  /bin/cat <<EOF

==> Add your user to the vboxusers group:
@@ -41,78 +31,45 @@ post_install() {
==>
==> Run \`/etc/rc.d/vboxdrv setup\` as root every time your kernel is
==> upgraded, to compile the module for the new kernel version.
==>
==> If USB does not work for you out-of-the-box, add the following line
==> to "/etc/fstab":
==> "none /proc/bus/usb usbfs auto,busgid=108,busmode=0775,devgid=108,devmode=0664 0 0"

EOF
}

# $1: The new package version
# $2: The old package version
post_upgrade() {
  _NEWVERSION=`echo $1 | cut -f-1 -d '-'`
  _OLDVERSION=`echo $2 | cut -f-1 -d '-'`

  # Remove any stuff (e.g. module compilation files) from an old installation - old versions used
  # to use these directories.
  if [ "$_NEWVERSION" != "$_OLDVERSION" ]; then
    rm -Rf "/opt/VirtualBox-${_OLDVERSION}" &> /dev/null
  fi
  if [ "$1" != "$2" ]; then
    rm -Rf "/opt/virtualbox" &> /dev/null
  fi
  
  # Build new module
  /etc/rc.d/vboxdrv setup

  # Create the directory below if it doesn't exist
  mkdir -p "/var/run/VirtualBox"

  /bin/cat <<EOF

==> You must load vboxdrv module before starting VirtualBox:
==> # modprobe vboxdrv
==>
==> You must load vboxnetflt for Host Interface Networking:
==> # modprobe vboxnetflt
==>
==> You must load vboxnetadp for Host-Only networking:
==> # modprobe vboxnetadp
==>
==> To load it automatically, add vboxdrv module to the "MODULES" array
==> "/etc/rc.conf".
==>
==> Run \`/etc/rc.d/vboxdrv setup\` as root every time your kernel is
==> upgraded, to compile the module for the new kernel version.
==>
==> If USB does not work for you out-of-the-box, add the following line
==> to "/etc/fstab":
==> "none /proc/bus/usb usbfs auto,busgid=108,busmode=0775,devgid=108,devmode=0664 0 0"

EOF
pre_upgrade() {
  pre_remove 
  # Remove the module files
  rm -f "/lib/modules/`uname -r`/misc/"{vboxdrv,vboxnetadp,vboxnetflt}.ko

  if [ "`vercmp $_OLDVERSION 3.2.2`" -lt 0 ]; then
    /bin/cat <<EOF
==> IMPORTANT: This package now uses \`/etc/rc.d/vboxdrv setup\` instead
==>            of the old "vbox_build_module" script.
  # Remove any stuff remaining from the module compilation
  rm -Rf "/opt/VirtualBox"
}

EOF
  fi
post_upgrade() {
  post_install
}

# $1: The old package version
pre_remove() {
  # Unload modules (if any)
  for _mod in vbox{drv,netadp,netflt}; do
    modprobe -r $_mod &> /dev/null
  done
}

post_remove() {
  # Remove the module files
  rm -f "/lib/modules/`uname -r`/misc/"{vboxdrv,vboxnetadp,vboxnetflt}.ko

  # Remove any stuff remaining from the module compilation
  rm -Rf "/opt/VirtualBox"
  
  # Remove any run files
  rm -Rf "/var/run/VirtualBox"

  # Update mime database
  [ -x usr/bin/update-mime-database ] && update-mime-database /usr/share/mime &>/dev/null

  # remove vboxusers group
  groupdel vboxusers &>/dev/null || true
}

# vim:set ts=2 sw=2 ft=sh et: