diff options
author | Nicolás Reynolds <apoyosis@correo.inta.gob.ar> | 2011-10-31 17:09:03 -0300 |
---|---|---|
committer | Nicolás Reynolds <apoyosis@correo.inta.gob.ar> | 2011-10-31 17:09:03 -0300 |
commit | a69609e9403d199e1ed53fc1973ffde7898345fb (patch) | |
tree | 6473f7c5a497cc97a1ef59bbfde67a123f70a76a /libre/virtualbox-libre/vboxbuild | |
parent | f29ad7a147afed6adce95e3ab909e96e843b0560 (diff) | |
download | abslibre-a69609e9403d199e1ed53fc1973ffde7898345fb.tar.gz abslibre-a69609e9403d199e1ed53fc1973ffde7898345fb.tar.bz2 abslibre-a69609e9403d199e1ed53fc1973ffde7898345fb.zip |
libre/virtualbox-libre-4.1.4-3
Diffstat (limited to 'libre/virtualbox-libre/vboxbuild')
-rw-r--r-- | libre/virtualbox-libre/vboxbuild | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/libre/virtualbox-libre/vboxbuild b/libre/virtualbox-libre/vboxbuild new file mode 100644 index 000000000..cfc3c0a66 --- /dev/null +++ b/libre/virtualbox-libre/vboxbuild @@ -0,0 +1,78 @@ +#!/bin/bash + +. /etc/rc.conf +. /etc/rc.d/functions +. /etc/vbox/vbox.cfg + +MODLIST=() +LOG="/var/log/vbox-install.log" +>| "$LOG" + +if [[ $INSTALL_DIR ]]; then + VBOXMANAGE=$INSTALL_DIR/VBoxManage + BUILDVBOXDRV=$INSTALL_DIR/src/vboxdrv/build_in_tmp + BUILDVBOXNETFLT=$INSTALL_DIR/src/vboxnetflt/build_in_tmp + BUILDVBOXNETADP=$INSTALL_DIR/src/vboxnetadp/build_in_tmp + BUILDVBOXPCI=$INSTALL_DIR/src/vboxpci/build_in_tmp +else + echo "error: missing vbox.cfg" + exit 1 +fi + +if [[ -f /proc/modules ]]; then + IFS=$'\n' read -r -d '' -a MODLIST < \ + <(grep -oE '^vbox(pci|netflt|netadp|drv)' /proc/modules) +fi + +if (( ${#MODLIST[*]} )); then + stat_busy "Unloading VirtualBox kernel modules" + modprobe -ar "${MODLIST[@]}" && stat_done || stat_fail +fi + +for kdir in /lib/modules/[2-3]*; do + if [[ ! -d $kdir/kernel ]]; then + # found a stale kernel + mods=("$kdir/misc/vbox"{drv,netadp,netflt,pci}.ko*) + if (( ${#mods[@]} )); then + stat_busy "Removing all old VirtualBox kernel modules" + if rm -f "${mods[@]}" && + rmdir -p --ignore-fail-on-non-empty "$p/misc/" 2>/dev/null; then + stat_done + else + stat_fail + fi + fi + fi +done + +# default to the currently running kernel +if (( ! $# )); then + set -- $(uname -r) +fi + +for kernver; do + export KERN_DIR=/lib/modules/$kernver/build + if [[ ! -d $KERN_DIR ]]; then + printf "error: \`%s' does not appear to be a valid kernel build directory.\n" \ + "$KERN_DIR" + continue + fi + + stat_busy "Recompiling VirtualBox kernel modules ($kernver)" + for build in BUILDVBOX{DRV,NETFLT,NETADP,PCI}; do + if ! ${!build} \ + --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" + stat_fail + continue + fi + done + stat_done +done + +if (( ${#MODLIST[*]} )); then + stat_busy "Reloading VirtualBox kernel modules" + modprobe -a "${MODLIST[@]}" && stat_done || stat_fail +fi + |