--- trunk/virtualbox/virtualbox-config.sh 2011/07/04 16:53:05 1406 +++ trunk/virtualbox/virtualbox-config.sh 2012/03/03 02:48:55 1672 @@ -1,14 +1,17 @@ #!/bin/bash -# $Header: /root/magellan-cvs/src/virtualbox/virtualbox-config.sh,v 1.13 2010-06-09 22:29:52 niro Exp $ +# $Id$ # Configures virtualbox for Magellan-Linux -LIBDIR=/usr/lib -INSTDIR=${LIBDIR}/virtualbox -VBOXVERSION="$(< ${INSTDIR}/version)" +# get INSTALL_DIR location +source /etc/vbox/vbox.cfg + +VBOXVERSION="$(< ${INSTALL_DIR}/version)" VBOXMODEXT=ko VBOXMODULE=vboxdrv VBOXNETMODULE=vboxnetflt VBOXNETADPMODULE=vboxnetadp +VBOXPCIMODULE=vboxpci +KERNELMODULES="${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE} ${VBOXPCIMODULE}" COLRED="\033[1;6m\033[31m" COLGREEN="\033[1;6m\033[32m" @@ -43,18 +46,20 @@ mecho "Running $(basename $0) for kernelversion ${KERNEL_VERSION} ..." -# check module version an recompile if it doesen't fit else break here -compile="no" -for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE} +# check module version and recompile if it doesen't fit else break here +compile="yes" +for module in ${KERNELMODULES} do - myver=$(modinfo -k ${KERNEL_VERSION} -F version ${module} | sed "s:\(.*\)_.*:\1:") - if [[ ${VBOXVERSION} != ${myver} ]] + if [[ -f /lib/modules/${KERNEL_VERSION}/misc/${module}.${VBOXMODEXT} ]] then - compile="yes" - fi + myver=$(modinfo -k ${KERNEL_VERSION} -F version ${module} | sed "s:\(.*\)_.*:\1:") + if [[ ${VBOXVERSION} = ${myver} ]] + then + compile="no" + fi done -for module in ${VBOXNETADPMODULE} ${VBOXNETMODULE} ${VBOXMODULE} +for module in ${KERNELMODULES} do if [[ -f /lib/modules/${KERNEL_VERSION}/misc/${module}.${VBOXMODEXT} ]] then @@ -74,7 +79,7 @@ die "No kernel sources for kernel ${KERNEL_VERSION} found! Aborting." fi - for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE} + for module in ${KERNELMODULES} do if [[ -f /lib/modules/${KERNEL_VERSION}/misc/${module}.${VBOXMODEXT} ]] then @@ -83,25 +88,30 @@ fi done - for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE} + # compile the modules + pushd ${INSTALL_DIR}/src + for module in ${KERNELMODULES} do - # compile the module - cd ${INSTDIR}/src/${module} - - make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) clean || die "mod-compile ${module}" + make -C ${module} KBUILD_VERBOSE=1 clean || die "mod-compile ${module}" # need some symver from vboxmodule (must be run after clean!) - if [[ ${module} = ${VBOXNETMODULE} ]] || [[ ${module} = ${VBOXNETADPMODULE} ]] + if [[ ${module} = ${VBOXNETMODULE} ]] || + [[ ${module} = ${VBOXNETADPMODULE} ]] || + [[ ${module} = ${VBOXPCIMODULE} ]] then - [[ -f ../${VBOXMODULE}/Module.symvers ]] && cp ../${VBOXMODULE}/Module.symvers . + [[ -f ${VBOXMODULE}/Module.symvers ]] && cp ${VBOXMODULE}/Module.symvers ${module} fi - make -C ${KERNEL_SOURCES} SUBDIRS=$(pwd) SRCROOT=$(pwd) modules || die "mod-compile ${module}" + make -C ${module} KBUILD_VERBOSE=1 || die "mod-compile ${module}" # install the modules install -d /lib/modules/${KERNEL_VERSION}/misc - install -m0644 ${module}.${VBOXMODEXT} /lib/modules/${KERNEL_VERSION}/misc || die "mod-install ${module}" + install -m0644 ${module}/${module}.${VBOXMODEXT} /lib/modules/${KERNEL_VERSION}/misc || die "mod-install ${module}" + + # clean up + make -C ${module} KBUILD_VERBOSE=1 clean || die "mod-compile ${module}" done + popd # calc module dependencies mecho "Calculating module dependencies ..." @@ -111,14 +121,14 @@ if [[ -x $(which udevadm) ]] then mecho "Reloading udev configuration ..." - $(which udevadm) control --reload-rules + udevadm control --reload-rules fi fi # load the module if [[ x$(uname -r) = x${KERNEL_VERSION} ]] then - for module in ${VBOXMODULE} ${VBOXNETMODULE} ${VBOXNETADPMODULE} + for module in ${KERNELMODULES} do mecho "Loading kernel-module ${module} ..." modprobe ${module}