From 3d1235af060955e271be68240c0ca46bc6d81b03 Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Tue, 25 Mar 2014 15:24:04 +0100 Subject: [modules] new module naming convention rename $MODULE.{conf,build} to module.{conf,build} --- remote/modules/vbox/module.build | 127 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 127 insertions(+) create mode 100644 remote/modules/vbox/module.build (limited to 'remote/modules/vbox/module.build') diff --git a/remote/modules/vbox/module.build b/remote/modules/vbox/module.build new file mode 100644 index 00000000..f095b4e2 --- /dev/null +++ b/remote/modules/vbox/module.build @@ -0,0 +1,127 @@ +#!/bin/bash + +patch_vbox_scripts() { + # patching some virtualbox utility scripts to include openslx-busybox paths. Strange sed-ing, as the added + # openslx paths need to be at the end of PATH to not impede with system binaries to not impede with system binaries + pinfo "Patching virtual box scripts to include openslx (busybox)-paths ..." + # vboxmanage is a link to VBox; will get unlinked. Original link will be vboxmanage.original + for i in virtualbox vboxmanage vboxheadless; do + pinfo "Patching virtual box script $i ..." + SCRIPTPATH=$(grep -m 1 PATH "${MODULE_BUILD_DIR}/usr/bin/$i"|sed 's/"//g') # assume first hit is real path + sed -i "-i.original" "/^PATH=/c ${SCRIPTPATH}:/opt/openslx/bin:/opt/openslx/usr/bin:/opt/openslx/sbin"\ + "${MODULE_BUILD_DIR}/usr/bin/$i" # append openslx paths + done +} + +extract_extpack() { + pinfo "Unpacking Extension Pack ..." + mkdir -p ${MODULE_BUILD_DIR}/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack + cp ${MODULE_DIR}/src/vbox/extpack/[EP][xX][tE]* ${MODULE_BUILD_DIR}/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack + if [ x${AMD64_X86} == "xamd64" ]; then + pinfo "Unpacking 64bit branch of Extension Pack ..." + cp -r ${MODULE_DIR}/src/vbox/extpack/linux.amd64 ${MODULE_BUILD_DIR}/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack + else # then we assume 32bit x86... + pinfo "Unpacking32bit branch of Extension Pack ..." + cp -r ${MODULE_DIR}/src/vbox/extpack/linux.x86 ${MODULE_BUILD_DIR}/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack + fi +} + +build_modules() { + pinfo "Recompiling VirtualBox kernel modules ..." + # Set some variables to use/patch VBox scripts + local MODULE_SRC="${MODULE_BUILD_DIR}/usr/share/virtualbox/src/vboxhost" + local BUILDINTMP="$MODULE_SRC/build_in_tmp" + local BUILDSUBDIR="modules" + + # Some Vars for VBs kernel module makefiles + MODULE_DIR_ALT="$MODULE_DIR" # save usual MODULE_DIR + export KERN_DIR="${MODULE_DIR}/../kernel/build/lib/modules/$(ls ${MODULE_DIR}/../kernel/build/lib/modules/)/build/" + # export MODULE_DIR="${MODULE_DIR}/../kernel/build/lib/modules/$(ls ${MODULE_DIR}/../kernel/build/lib/modules/)/kernel/misc" + export MODULE_DIR="${MODULE_DIR}/build/lib/modules/vbox" + + pinfo "Recompiling VirtualBox kernel module vboxdrv ..." + if ! $BUILDINTMP \ + --save-module-symvers /tmp/vboxdrv-Module.symvers \ + --module-source "$MODULE_SRC/vboxdrv" \ + --no-print-directory install; + then + perror "[vbox]: Error compiling VirtualBox kernel module vboxdrv" + fi + pinfo "Recompiling VirtualBox kernel module vboxnetflt ..." + if ! $BUILDINTMP \ + --use-module-symvers /tmp/vboxdrv-Module.symvers \ + --module-source "$MODULE_SRC/vboxnetflt" \ + --no-print-directory install; + then + perror "[vbox]: Error compiling VirtualBox kernel module vboxnetflt" + fi + pinfo "Recompiling VirtualBox kernel module vboxnetadp ..." + if ! $BUILDINTMP \ + --use-module-symvers /tmp/vboxdrv-Module.symvers \ + --module-source "$MODULE_SRC/vboxnetadp" \ + --no-print-directory install; + then + perror "[vbox]: Error compiling VirtualBox kernel module vboxnetadp" + fi + pinfo "Recompiling VirtualBox kernel module vboxpci ..." + if ! $BUILDINTMP \ + --use-module-symvers /tmp/vboxdrv-Module.symvers \ + --module-source "$MODULE_SRC/vboxpci" \ + --no-print-directory install; + then + perror "[vbox]: Error compiling VirtualBox kernel module vboxpci" + fi + pinfo "Compiled successfully the VirtualBox kernel modules." + export MODULE_DIR="$MODULE_DIR_ALT" # re-set MODULE_DIR +} + + +fetch_source() { + mkdir -p "src/vbox" + cd src/vbox + # pinfo "Downloading $REQUIRED_VBOXBASEURL" + download "$REQUIRED_VBOXBASEURL" + # pinfo "Downloading $REQUIRED_VBOXEXTURL" + download_untar "$REQUIRED_VBOXEXTURL" "extpack" "vbox_extpack.tar.gz" + cd - +} + + +build() { + case "$PACKET_HANDLER" in + rpm) + pinfo "Unpacking rpm ..." + cd build || perror "Cannot cd to build directory!" + rpm2cpio ../src/vbox/$(basename "$REQUIRED_VBOXBASEURL")|cpio -idmv || perror "Could not unpack rpm-archive!" + # it seems that sometimes directories from rpm will be created with 700-permissions, + # if that directory is not explicitly mentioned to create. So eg. usr, etc will carry the + # permissions 700, which is no fun. So we search for these directories and correct them. + find . -type d -perm 700 -exec chmod 755 {} \; + ;; + dpkg ) + pinfo "Unpacking deb ..." + cd build || perror "Cannot cd to build directory!" + dpkg -x ../src/vbox/$(basename "$REQUIRED_VBOXBASEURL") . || perror "Could not unpack deb-archive!" + # VirtualBox needs to be suid-root: + for i in VBoxHeadless VBoxNetAdpCtl VBoxNetDHCP VBoxSDL VBoxVolInfo VirtualBox; do + chmod u+s ${MODULE_BUILD_DIR}/usr/lib/virtualbox/$i || pwarning "(Debian/Ubuntu) Could not suid $i executable!" + done + ;; + *) perror "Unknown Distribution: $SYS_DISTRIBUTION - Please specify its packet manager in remote/setup_target" ;; + esac + + build_modules + patch_vbox_scripts + extract_extpack + + COPYLIST="list_dpkg_output" + [ -e "$COPYLIST" ] && rm "$COPYLIST" + list_packet_files >> "$COPYLIST" + tarcopy "$(cat "$COPYLIST" | sort -u)" "${MODULE_BUILD_DIR}" +} + +post_copy() { + # clean a bit, as sometimes there are residual files in /tmp/vbox.*/ + rm -rf /tmp/vbox.*/ +} + -- cgit v1.2.3-55-g7522