Commit 03e7c003 authored by Seblu's avatar Seblu
Browse files

remove no dkms support


git-svn-id: https://seblu.net/s/archpkg@237 02741741-5192-46b8-8916-7152b19231d9
parent 1561bb6e
Loading
Loading
Loading
Loading
+70 −69
Original line number Diff line number Diff line
@@ -9,13 +9,14 @@
pkgname=virtualbox-bin
pkgver=4.1.14
_build=77440
pkgrel=1
pkgrel=1.1
pkgdesc='Oracle VM VirtualBox Binary Edition'
arch=('i686' 'x86_64')
url='http://virtualbox.org/'
license=('GPL2')
options=('!strip')
depends=(
  'dkms'
  'fontconfig'
  'gcc'
  'libgl'
@@ -27,27 +28,24 @@ depends=(
  'python2'
  'sdl'
)
optdepends=('virtualbox-ext-oracle: for Oracle extensions'
            'dkms: for handling kernel modules with dkms')
optdepends=('virtualbox-ext-oracle: for Oracle extensions')
provides=("virtualbox=${pkgver}")
conflicts=('virtualbox' 'virtualbox-ose' 'virtualbox-modules')
replaces=('virtualbox_bin' 'virtualbox-sun')
backup=('etc/vbox/vbox.cfg' 'etc/conf.d/vboxdrv' 'etc/conf.d/vboxweb')
backup=('etc/vbox/vbox.cfg' 'etc/conf.d/vboxweb')
install='install'
_arch='amd64'
[[ "${CARCH}" = i686 ]] && _arch='x86'
source=(
  "VirtualBox-${pkgver}-${_build}-Linux_${_arch}.run::http://download.virtualbox.org/virtualbox/${pkgver}/VirtualBox-${pkgver}-${_build}-Linux_${_arch}.run"
  'VBoxFixUSB'
  '10-vboxdrv.rules'
  'vboxdrv.rc'
  'vboxdrv.conf'
  'vboxweb.rc'
  'vboxweb.conf'
)
md5sums=('97d0dc8d74bfdc710a3cd8f4e5a994dd'
         '2d04c2e2d8c71558c910a51ec773731a'
         'fe60f9510502bea67383d9198ae8c13c'
         'e7a94c97b1b1e1e843c1bb85181d2de8'
         '951bf4a5524e919fc4aaee6f46041e3d'
         'c159d683ba1947290fc2ad2c64194150'
         '3ac185709bfe688bb753c46e170d0546')
[[ "${CARCH}" = i686 ]] && md5sums[0]='4b408d6c7ced82edf3c1284b494a47bd'
@@ -55,21 +53,21 @@ _installdir='/opt/VirtualBox'

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}" \
  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}/${_installdir}"
  cd "${pkgdir}/${_installdir}"
  tar -xjf "${srcdir}/VirtualBox.tar.bz2"
  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}"
    ln -sf "$_installdir/$_lib" "components/$_lib"
  done
  chmod go-w .

@@ -80,88 +78,91 @@ package() {
  #  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#' 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}/${_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 the SDK
  pushd 'sdk/installer'
  VBOX_INSTALL_PATH="${_installdir}" python2 vboxapisetup.py install --root "${pkgdir}"
  rm -r -f build
  popd

  # Install udev rules
  install -D -m 0644 "${srcdir}/10-vboxdrv.rules" "${pkgdir}/usr/lib/udev/rules.d/10-vboxdrv.rules"
  install -D -m 0644 "$srcdir/10-vboxdrv.rules" "$pkgdir/usr/lib/udev/rules.d/10-vboxdrv.rules"
  # we need to move and not symlink VBoxCreateUSBNode.sh in /usr/lib/udev to avoid udevd
  # to look /opt when /opt is not mounted. This can be done until VBoxCreateUSBNode.sh doesn't
  # need more stuff from /opt
  mv VBoxCreateUSBNode.sh "${pkgdir}/usr/lib/udev/"
  mv VBoxCreateUSBNode.sh "$pkgdir/usr/lib/udev/"

  # Install the SDK
  cd "sdk/installer"
  VBOX_INSTALL_PATH="${_installdir}" python2 vboxapisetup.py install --root "${pkgdir}"
  rm -r -f build
  cd "${pkgdir}/${_installdir}"
  # Install Fixusb script
  install -D -m 0755 "$srcdir/VBoxFixUSB" VBoxFixUSB

  # Patch "vboxshell.py" to use Python 2.x instead of Python 3
  sed -i 's#/usr/bin/python#\02#' vboxshell.py

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

  # 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"

  # 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 || :
  install -d -m 0755 "$pkgdir/usr/bin"
  for _bin in VirtualBox VBox{Headless,Manage,SDL,SVC,Tunctl,NetAdpCtl,FixUSB} 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"
  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"
  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"
  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 module sources in /usr/src
  install -d -m 0755 "$pkgdir/usr/src"
  ln -s "$_installdir/src/vboxhost" "$pkgdir/usr/src/vboxhost-$pkgver"

  # Symlink icons
  cd icons
  pushd icons
  for _dir in *; do
    cd "${_dir}"
    install -d -m 0755 "${pkgdir}/usr/share/icons/hicolor/${_dir}/"{apps,mimetypes}
    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}"
      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}"
          ln -s "$_installdir/icons/$_dir/$_icon" "$pkgdir/usr/share/icons/hicolor/$_dir/mimetypes/$_icon"
      fi
    done
    cd - >/dev/null
  done
  popd

  # 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
  # No more need as /var/run is tmpfs
  #install -d -m 0755 "${pkgdir}/var/run/VirtualBox"
  install -D -m 0644 /dev/null "$pkgdir/etc/vbox/vbox.cfg"
  cat > "$pkgdir/etc/vbox/vbox.cfg" <<EOF
# VirtualBox installation directory"
INSTALL_DIR='$_installdir'

# VirtualBox version
INSTALL_VER='$pkgver'
INSTALL_REV='$_build'
EOF

  # Register into DKMS
  install -dm 755 "$pkgdir/var/lib/dkms/vboxhost/$pkgver"
  ln -s '/opt/VirtualBox/src/vboxhost' "$pkgdir/var/lib/dkms/vboxhost/$pkgver/source"

}

# vim:set ts=2 sw=2 ft=sh et:
+20 −19
Original line number Diff line number Diff line
@@ -2,18 +2,19 @@

update_databases() {
  # Update mime database
  [[ -x /usr/bin/update-mime-database ]] && 
    /usr/bin/update-mime-database /usr/share/mime &>/dev/null
  type -P update-mime-database &>/dev/null &&
    update-mime-database /usr/share/mime &>/dev/null

  # Update xdg icon database
  [[ -x /usr/bin/xdg-icon-resource ]] &&
    /usr/bin/xdg-icon-resource forceupdate --theme hicolor &>/dev/null
  type -P xdg-icon-resource &>/dev/null &&
    xdg-icon-resource forceupdate --theme hicolor &>/dev/null

  # Update desktop database
  [[ -x /usr/bin/update-desktop-database ]] && 
    /usr/bin/update-desktop-database -q &>/dev/null
  type -P update-desktop-database &>/dev/null && 
    update-desktop-database -q &>/dev/null
}

# arg 1:  the new package version
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
@@ -24,42 +25,42 @@ post_install() {
  # Update databases
  update_databases

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

==> 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 rc.d fixusb vboxdrv or reboot your computer
==> To load/compile virtualbox modules automatically you can add dkms in your DAEMONS
EOF
}

# arg 1:  the new package version
# arg 2:  the old package version
pre_upgrade() {
  pre_remove 
  # should be $2... pacman is bugged
  pre_remove "$1"

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

# arg 1:  the new package version
# arg 2:  the old package version
post_upgrade() {
  post_install
  post_install "$1"
}

# arg 1:  the old package version
pre_remove() {
  # Stop running services
  [[ -x /etc/rc.d/vboxdrv ]] && /etc/rc.d/vboxdrv stop
  [[ -x /etc/rc.d/vboxweb ]] && /etc/rc.d/vboxweb stop
  [[ -x /etc/rc.d/vboxweb ]] && /etc/rc.d/vboxweb stop >/dev/null

  # Remove modules
  [[ -x /etc/rc.d/vboxdrv ]] && /etc/rc.d/vboxdrv remove
  dkms remove vboxhost/${1%-*} --all >/dev/null
}

# arg 1:  the old package version
post_remove() {
  # Remove any stuff remaining from the module compilation
  rm -Rf "/opt/VirtualBox"

virtualbox-bin/vboxdrv.conf

deleted100644 → 0
+0 −7
Original line number Diff line number Diff line
# Try to build module if don't exist when calling start
# This variable is automatically set to no when DKMS is in use
START_BUILD=Yes

# Disable use of DKMS
# Elsewhere script try to detect DKMS
DISABLE_DKMS=No

virtualbox-bin/vboxdrv.rc

deleted100644 → 0
+0 −147
Original line number Diff line number Diff line
#!/bin/bash

. /etc/rc.conf
. /etc/rc.d/functions
. /etc/vbox/vbox.cfg
. /etc/conf.d/vboxdrv

if [[ -n "$INSTALL_DIR" ]]; then
  VBOXMANAGE="$INSTALL_DIR/VBoxManage"
  BUILDVBOXDRV="$INSTALL_DIR/src/vboxhost/vboxdrv/build_in_tmp"
  BUILDVBOXNETFLT="$INSTALL_DIR/src/vboxhost/vboxnetflt/build_in_tmp"
  BUILDVBOXNETADP="$INSTALL_DIR/src/vboxhost/vboxnetadp/build_in_tmp"
else
  echo "Missing /etc/vbox/vbox.cfg"
  exit 0
fi

# detection of dkms (if not disabled)
if [[ "$DISABLE_DKMS" =~ [yY][eE][sS] ]]; then
  USE_DKMS=0
else
  which dkms &>/dev/null
  USE_DKMS=$((! $?))
fi

# STARTBUILD cannot be used with dkms
(( USE_DKMS == 1 )) && START_BUILD=no


load() {
  if [[ "$START_BUILD" =~ [yY][eE][sS] ]]; then
    # check if module exists
    c=$('find' "/lib/modules/$(uname -r)" -type f -regex '.*/vbox\(drv\|netadp\|netflt\).ko' | wc -l)
    ((c == 0 )) && setup
  fi
  stat_busy "Loading VirtualBox kernel modules"
  # trivial loading
  for module in vbox{drv,netadp,netflt}; do
      modprobe $module &>/dev/null
  done
  # check
  for module in vbox{drv,netadp,netflt}; do
    if ! grep -q "^${module}" /proc/modules; then
      stat_fail
      return 1
    fi
  done
  add_daemon vboxdrv
  stat_done
}

unload() {
  stat_busy "Unloading VirtualBox kernel modules"
  # trivial unload
  for module in vbox{netflt,netadp,drv}; do
    if grep -q "^${module}" /proc/modules; then
      modprobe -r $module &>/dev/null
    fi
  done
  # check
  for module in vbox{drv,netadp,netflt}; do
    if grep -q "^${module}" /proc/modules; then
      stat_fail
      return 1
    fi
  done
  rm_daemon vboxdrv
  stat_done
}

remove() {
  if (( USE_DKMS == 1 )); then
    status "Removing VirtualBox kernel modules with DKMS" dkms remove -m vboxhost -v "$INSTALL_VER" --all
  else
    stat_busy "Removing VirtualBox kernel modules"
    find "/lib/modules/$(uname -r)" -type f -regex '.*/vbox\(drv\|netadp\|netflt\).ko' -delete
    stat_done
  fi
}

setup() {
  if (( USE_DKMS == 1 )); then
    status "Adding VirtualBox kernel modules in DKMS" dkms add -m vboxhost -v "$INSTALL_VER"
    status "Bulding VirtualBox kernel modules with DKMS" dkms build -m vboxhost -v "$INSTALL_VER"
    status "Installing VirtualBox kernel modules with DKMS" dkms install -m vboxhost -v "$INSTALL_VER"
  else
    remove
    stat_busy "Compiling VirtualBox kernel modules"
    LOG="/tmp/vbox-install.log"
    if ! $BUILDVBOXDRV \
      --save-module-symvers /tmp/vboxdrv-Module.symvers \
      --no-print-directory install > $LOG 2>&1; then
      echo  "Look at $LOG to find out what went wrong"
    fi
    if ! $BUILDVBOXNETFLT \
      --use-module-symvers /tmp/vboxdrv-Module.symvers \
      --no-print-directory install >> $LOG 2>&1; then
      echo "Look at $LOG to find out what went wrong"
    fi
    if ! $BUILDVBOXNETADP \
      --use-module-symvers /tmp/vboxdrv-Module.symvers \
      --no-print-directory install >> $LOG 2>&1; then
      echo "Look at $LOG to find out what went wrong"
    fi
    depmod -A
    stat_done
fi
}

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
    ;;
  stop)
      unload
      ;;
  restart)
      unload
      load
      ;;
  setup)
    setup
    ;;
  remove)
    remove
    ;;
  fixusb)
    fixusb
    ;;
  *)
    echo "usage: $0 {start|stop|restart|setup|remove|fixusb}"
esac

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