summaryrefslogtreecommitdiffstats
path: root/core/modules/vbox/module.build
diff options
context:
space:
mode:
Diffstat (limited to 'core/modules/vbox/module.build')
-rw-r--r--core/modules/vbox/module.build142
1 files changed, 142 insertions, 0 deletions
diff --git a/core/modules/vbox/module.build b/core/modules/vbox/module.build
new file mode 100644
index 00000000..0f62eab4
--- /dev/null
+++ b/core/modules/vbox/module.build
@@ -0,0 +1,142 @@
+#!/bin/bash
+
+patch_vbox_scripts() {
+ # Patching virtualbox utility scripts to include openslx-busybox binary paths. Strange sed-ing, as the openslx
+ # binary paths need to be at the end of PATH to not impede with system binaries.
+ # It seems sufficient to patch just VBox, as eg. vboxmanage, vboxheadless etc. are just links to VBox.
+ # If only vboxmanage, vboxheadless or such should be patched (and not the base script VBox) just use a list
+ # in the loop (eg. 'for i in virtualbox vboxmanage vboxheadless; do'). These links will be replaced by patched
+ # 'real' files. Of course it will not make sense if VBox is included in the list, then.
+ # Patched files will be saved with extension .original.
+
+ pinfo "Patching virtual box scripts to include openslx (busybox)-paths ..."
+ for i in VBox; 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/sbin"\
+ "${MODULE_BUILD_DIR}/usr/bin/$i" # append openslx paths
+ done
+
+ # due to problems with group membership of kdm-spawned processes we need to
+ # patch ${MODULE_BUILD_DIR}/usr/share/virtualbox/VBoxCreateUSBNode.sh:
+ sed -i "s/0750/0755/g" "${MODULE_BUILD_DIR}/usr/share/virtualbox/VBoxCreateUSBNode.sh"
+ sed -i "s/0660/0666/g" "${MODULE_BUILD_DIR}/usr/share/virtualbox/VBoxCreateUSBNode.sh"
+}
+
+extract_extpack() {
+ pinfo "Unpacking Extension Pack ..."
+ mkdir -p "${MODULE_BUILD_DIR}/usr/lib/virtualbox/ExtensionPacks/Oracle_VM_VirtualBox_Extension_Pack"
+ cp "${MODULE_WORK_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_WORK_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_WORK_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_WORK_DIR}/../kernel/build/lib/modules/$(ls ${MODULE_WORK_DIR}/../kernel/build/lib/modules/)/build/"
+ pinfo "Using Kernel dir $KERN_DIR"
+ # export MODULE_DIR="${MODULE_WORK_DIR}/../kernel/build/lib/modules/$(ls ${MODULE_WORK_DIR}/../kernel/build/lib/modules/)/kernel/misc"
+ export MODULE_DIR="${MODULE_WORK_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() {
+ if [ -z "$REQUIRED_VBOXBASEURL" -o -z "$REQUIRED_VBOXEXTURL" ]; then
+ perror "Virtualbox download URLs not set - please write a module.conf-file for your linux flavour."
+ fi
+
+ 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 VBoxNetAdpCtl; 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.*/
+}
+