Commit 07eff5a2 authored by Seblu's avatar Seblu
Browse files

vboxdrv.rc:

- bashify
- now call depmod after building module. initscripts doesn't do it automagically at startup.
- add a fixusb option, which rebuild vbox usb in /dev
vboxweb.rc:
- bashify & cleaning
- fix stop report fail even if service is stopped
install:
- now call update-desktop-database
- fix typo error
10-vboxdrv.rules
- updated to latest version in upstream tarball
PKGBUILD:
- use package insted of build function
- remove dead comments
- create a symlink of udev tools into /lib/udev
- launchers are now also symlinked in lowercase
- a virtualbox.png icon needed by .desktop is present
- more config var in /etc/vbox/vbox.cfg
- modules sources are symlinked into /usr/src
- icons are now symlinked into /usr/share/icons/hicolor/
- install path can be customized
- remove deps to base-devel


git-svn-id: https://seblu.net/s/archpkg@70 02741741-5192-46b8-8916-7152b19231d9
parent c227b10c
Loading
Loading
Loading
Loading
+5 −3
Original line number Diff line number Diff line
KERNEL=="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="vboxusers", MODE="0660"
SUBSYSTEM=="usb_device", GROUP="vboxusers", MODE="0664"
SUBSYSTEM=="usb", ENV{DEVTYPE}=="usb_device", GROUP="vboxusers", MODE="0664"
KERNEL=="vboxdrv", NAME="vboxdrv", OWNER="root", GROUP="root", MODE="0600"
SUBSYSTEM=="usb_device", ACTION=="add", RUN="VBoxCreateUSBNode.sh $major $minor $attr{bDeviceClass}"
SUBSYSTEM=="usb", ACTION=="add", ENV{DEVTYPE}=="usb_device", RUN="VBoxCreateUSBNode.sh $major $minor $attr{bDeviceClass}"
SUBSYSTEM=="usb_device", ACTION=="remove", RUN="VBoxCreateUSBNode.sh --remove $major $minor"
SUBSYSTEM=="usb", ACTION=="remove", ENV{DEVTYPE}=="usb_device", RUN="VBoxCreateUSBNode.sh --remove $major $minor"
+65 −48
Original line number Diff line number Diff line
@@ -9,12 +9,12 @@
pkgname=virtualbox_bin
pkgver=4.0.6
_build=71344
pkgrel=2
pkgrel=3
pkgdesc='Oracle VM VirtualBox Binary Edition'
arch=('i686' 'x86_64')
url='http://virtualbox.org'
license=('GPL2')
depends=('libidl2' 'libxcursor' 'libxinerama' 'libxslt' 'curl' 'gcc' 'make' 'kernel26-headers' 'python2')
depends=('libidl2' 'libxcursor' 'libxinerama' 'libxslt' 'curl' 'kernel26-headers' 'python2')
options=('!strip')
optdepends=('virtualbox-ext-oracle: for Oracle extensions'
            'qt: for GUI support'
@@ -39,95 +39,112 @@ source=(
  'vboxweb.conf'
)
md5sums=('133cfbb8dc11da780b24f1ef5ef06697'
         '98859bfca9ef2ebf2ea43eb9123316fc'
         '55f7acbeb37c0ed2b4fe0452b84b4eb0'
         'fe60f9510502bea67383d9198ae8c13c'
         'c162cfc3683bb8e6970cf08a88b1e4a3'
         '2d5a0c5275bf660da9f30f75820b6078'
         '9d5f1eeea43f23d4696e3568671a4c4d'
         'c159d683ba1947290fc2ad2c64194150'
         '3ac185709bfe688bb753c46e170d0546')
[[ "${CARCH}" = 'i686' ]] && md5sums[0]='45414b45e5b43e95068b1f3fec71de76'
_installdir='/opt/VirtualBox'

build() {
package() {
  # Check and unpack the run package via sh(1)
  sh "VirtualBox-${pkgver}-${_build}-Linux_${_arch}.run" --check
  echo yes | sh "VirtualBox-${pkgver}-${_build}-Linux_${_arch}.run" --target "${srcdir}" \
    --nox11 --noexec &> /dev/null

  # Unpack bundled files
  install -d "${pkgdir}/opt/VirtualBox"
  cd "${pkgdir}/opt/VirtualBox"
  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}
  chmod 4511 VirtualBox VBox{SDL,Headless,NetDHCP,NetAdpCtl}
  for _lib in VBox{VMM,REM,RT,DDU,XPCOM}.so; do
    ln -sf "/opt/VirtualBox/${_lib}" "components/${_lib}"
    ln -sf "${_installdir}/${_lib}" "components/${_lib}"
  done
  chmod go-w .

  # VBoxNetAdpCtl needs to be suid root in any case
  chmod 4511 VBoxNetAdpCtl

  # 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}/opt/VirtualBox/vboxshell.py"

  # Install the SDK
  cd "${pkgdir}/opt/VirtualBox/sdk/installer"
  VBOX_INSTALL_PATH="/opt/VirtualBox" python2 vboxapisetup.py install --root "${pkgdir}"
  rm -Rf build
  cd "${pkgdir}/opt/VirtualBox"
  sed -i 's#/usr/bin/python#\02#' "${pkgdir}/${_installdir}/vboxshell.py"

  # Update Arch initscripts way of life in VBox.sh
  sed -i -e 's,sudo /etc/init.d/vboxdrv setup,/etc/rc.d/vboxdrv setup,g' \
    "${pkgdir}/opt/VirtualBox/VBox.sh"
    "${pkgdir}/${_installdir}/VBox.sh"
  sed -i -e 's,sudo /etc/init.d/vboxdrv restart,/etc/rc.d/vboxdrv restart,g' \
    "${pkgdir}/opt/VirtualBox/VBox.sh"
    "${pkgdir}/${_installdir}/VBox.sh"

  # Install vboxdrv initscript
  install -Dm0755 "${srcdir}/vboxdrv.rc" "${pkgdir}/etc/rc.d/vboxdrv"
  install -Dm0644 "${srcdir}/vboxdrv.conf" "${pkgdir}/etc/conf.d/vboxdrv"
  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 -Dm0755 "${srcdir}/vboxweb.rc" "${pkgdir}/etc/rc.d/vboxweb"
  install -Dm0644 "${srcdir}/vboxweb.conf" "${pkgdir}/etc/conf.d/vboxweb"
  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 -Dm0644 "${srcdir}/10-vboxdrv.rules" "${pkgdir}/lib/udev/rules.d/10-vboxdrv.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"

  # Symlink the launchers
  install -dm0755 "${pkgdir}/usr/bin"
  # 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 "/opt/VirtualBox/${_bin}" "${pkgdir}/usr/bin/${_bin}"
    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 -dm0755 "${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"
  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 -dm0755 "${pkgdir}/usr/share/mime/packages"
  ln -s "/opt/VirtualBox/virtualbox.xml" "${pkgdir}/usr/share/mime/packages/virtualbox.xml"
  install -d -m 0755 "${pkgdir}/usr/share/mime/packages"
  ln -s "${_installdir}/virtualbox.xml" "${pkgdir}/usr/share/mime/packages/virtualbox.xml"

  # Symlink doc
  install -dm0755 "${pkgdir}/usr/share/doc/${pkgname}"
  ln -s "/opt/VirtualBox/VirtualBox.chm" "${pkgdir}/usr/share/doc/$pkgname/VirtualBox.chm"
  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

  # Setup default configuration
  install -dm 0755 "${pkgdir}/etc/vbox"
  echo 'INSTALL_DIR="/opt/VirtualBox"' > "${pkgdir}/etc/vbox/vbox.cfg"
  # 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 -dm0755 "${pkgdir}/var/run/VirtualBox"
  install -d -m 0755 "${pkgdir}/var/run/VirtualBox"
}

# vim:set ts=2 sw=2 ft=sh et:
+12 −4
Original line number Diff line number Diff line
post_install() {
  # Add vboxusers group, GID 108 is reserved (http://wiki.archlinux.org/index.php/UID_and_GID_list),
  getent group vboxusers >> /dev/null || groupadd -f -g 108 vboxusers
  getent group vboxusers &> /dev/null || groupadd -f -g 108 vboxusers

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

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

  # Update desktop database
  [[ -x =update-desktop-database ]] && update-desktop-database -q &>/dev/null

  # Build new module
  /etc/rc.d/vboxdrv setup
@@ -14,11 +17,13 @@ post_install() {
  # Show warnings
  /bin/cat <<EOF

==> Remember to add user to the vboxusers group:
==> Remember to add allowed users to the vboxusers group:
==> # gpasswd -a USERNAME vboxusers
==>
==> To load virtualbox modules automatically you can add vboxdrv in your DAEMONS
==> To start virtualbox web service automatically you can add vboxweb in your DAEMONS
==>
==> To fix missing usb devices, you can call /etc/rc.d/vboxdrv fixusb or reboot
EOF
}

@@ -50,7 +55,10 @@ post_remove() {
  rm -Rf "/var/run/VirtualBox"

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

  # Update desktop database
  [[ -x =update-desktop-database ]] && update-desktop-database -q &>/dev/null

  # remove vboxusers group
  groupdel vboxusers &>/dev/null || true
+18 −1
Original line number Diff line number Diff line
@@ -81,9 +81,23 @@ setup() {
    --no-print-directory install >> $LOG 2>&1; then
    echo "Look at $LOG to find out what went wrong"
  fi
  depmod -A
  stat_done
}

fixusb() {
  # Build our device tree
  for i in /sys/bus/usb/devices/*; do
    if test -r "$i/dev"; then
      dev="`cat "$i/dev" 2> /dev/null`"
      major="`expr "$dev" : '\(.*\):' 2> /dev/null`"
      minor="`expr "$dev" : '.*:\(.*\)' 2> /dev/null`"
      class="`cat $i/bDeviceClass 2> /dev/null`"
      sh "$INSTALL_DIR/VBoxCreateUSBNode.sh" "$major" "$minor" "$class" 2>/dev/null
    fi
  done
}

case "$1" in
  start)
    load
@@ -101,8 +115,11 @@ case "$1" in
  remove)
    remove
    ;;
  fixusb)
    fixusb
    ;;
  *)
    echo "usage: $0 {start|stop|restart|setup|remove}"
    echo "usage: $0 {start|stop|restart|setup|remove|fixusb}"
esac

# vim:set ts=2 sw=2 ft=sh et:
+17 −22
Original line number Diff line number Diff line
@@ -6,28 +6,26 @@
. /etc/conf.d/vboxweb

BINARY="$INSTALL_DIR/vboxwebsrv"
PID=$(pidof -o %PPID $BINARY)

start() {
  stat_busy "Starting VirtualBox Web Service";
  if [[ ! -n "$PID" ]]; then
      [[ -n "$VBOXWEB_USER" ]] || stat_die
  if ! pidof -o %PPID $BINARY >/dev/null; then
      [[ "$VBOXWEB_USER" ]] || stat_die
      lsmod | grep -q "vboxdrv[^_-]" || stat_die
      PARAMS="--background"
      [[ -n "$VBOXWEB_HOST" ]]           && PARAMS="$PARAMS -H $VBOXWEB_HOST"
      [[ -n "$VBOXWEB_PORT" ]]           && PARAMS="$PARAMS -p $VBOXWEB_PORT"
      [[ -n "$VBOXWEB_TIMEOUT" ]]        && PARAMS="$PARAMS -t $VBOXWEB_TIMEOUT"
      [[ -n "$VBOXWEB_CHECK_INTERVAL" ]] && PARAMS="$PARAMS -i $VBOXWEB_CHECK_INTERVAL"
      [[ -n "$VBOXWEB_THREADS" ]]        && PARAMS="$PARAMS -T $VBOXWEB_THREADS"
      [[ -n "$VBOXWEB_KEEPALIVE" ]]      && PARAMS="$PARAMS -k $VBOXWEB_KEEPALIVE"
      [[ -n "$VBOXWEB_LOGFILE" ]]        && PARAMS="$PARAMS -F $VBOXWEB_LOGFILE"
      [[ "$VBOXWEB_HOST" ]]           && PARAMS+=" -H $VBOXWEB_HOST"
      [[ "$VBOXWEB_PORT" ]]           && PARAMS+=" -p $VBOXWEB_PORT"
      [[ "$VBOXWEB_TIMEOUT" ]]        && PARAMS+=" -t $VBOXWEB_TIMEOUT"
      [[ "$VBOXWEB_CHECK_INTERVAL" ]] && PARAMS+=" -i $VBOXWEB_CHECK_INTERVAL"
      [[ "$VBOXWEB_THREADS" ]]        && PARAMS+=" -T $VBOXWEB_THREADS"
      [[ "$VBOXWEB_KEEPALIVE" ]]      && PARAMS+=" -k $VBOXWEB_KEEPALIVE"
      [[ "$VBOXWEB_LOGFILE" ]]        && PARAMS+=" -F $VBOXWEB_LOGFILE"
      # prevent inheriting this setting to VBoxSVC
      unset VBOX_RELEASE_LOG_DEST
      su - $VBOXWEB_USER -c "$BINARY $PARAMS" &>/dev/null
      # ugly: wait until the final process has forked
      sleep .2
      PID=$(pidof -o %PPID $BINARY)
      if [ -n "$PID" ]; then
      if pidof -o %PPID $BINARY >/dev/null; then
          add_daemon vboxweb
          stat_done
      else
@@ -40,17 +38,14 @@ start() {

stop() {
  stat_busy "Stopping VirtualBox Web Service"
  if [[ -n $PID ]]; then
    kill $PID
    if [[ $? -eq 0 ]]; then 
  PID=$(pidof -o %PPID $BINARY)
  [[ $PID ]] && kill $PID &>/dev/null
  if ! pidof -o %PPID $BINARY >/dev/null; then
    rm_daemon vboxweb
    stat_done
  else
    stat_die
  fi
  else
      stat_die
  fi
}

restart() {
@@ -59,7 +54,7 @@ restart() {

status() {
  stat_busy "Checking for VirtualBox Web Service"
  if [[ -n $PID ]]; then
  if pidof -o %PPID $BINARY >/dev/null; then
      stat_done
  else
      stat_fail