diff options
Diffstat (limited to 'remote/modules')
| -rw-r--r-- | remote/modules/dnbd3/module.build | 2 | ||||
| -rw-r--r-- | remote/modules/kernel-system/module.build | 92 | ||||
| -rw-r--r-- | remote/modules/kernel-system/module.conf.ubuntu | 5 | ||||
| -rw-r--r-- | remote/modules/kernel/module.build | 57 | ||||
| -rw-r--r-- | remote/modules/nvidia_kernel/module.build | 2 | ||||
| -rw-r--r-- | remote/modules/vmware/module.build | 16 |
6 files changed, 69 insertions, 105 deletions
diff --git a/remote/modules/dnbd3/module.build b/remote/modules/dnbd3/module.build index 2651daac..cdbd8251 100644 --- a/remote/modules/dnbd3/module.build +++ b/remote/modules/dnbd3/module.build @@ -25,7 +25,7 @@ HEREEND build() { cd "$MODULE_DIR/src/kmod" || perror "Could not CD to standalone dnbd3 kmod dir" - make MODULE_NAME=dnbd3 KDIR="$KERNEL_HEADERS_PATH" || perror "Could not compile kernel module" + make MODULE_NAME=dnbd3 KDIR="$KERNEL_HEADERS_DIR" || perror "Could not compile kernel module" mkdir -p "$MODULE_BUILD_DIR/lib/modules/dnbd3" || perror "Could not create lib/modules/dnbd3" mkdir -p "$MODULE_BUILD_DIR/opt/openslx/bin" || perror "Coould not create opt/openslx/bin" cp "$MODULE_DIR/src/kmod/dnbd3.ko" "$MODULE_BUILD_DIR/lib/modules/dnbd3/" || perror "could not cp dnbd3.ko" diff --git a/remote/modules/kernel-system/module.build b/remote/modules/kernel-system/module.build index d698db22..a5bd747c 100644 --- a/remote/modules/kernel-system/module.build +++ b/remote/modules/kernel-system/module.build @@ -1,42 +1,39 @@ -# overloaded get_kernel_version function +# kernel-system: Try to use the system's kernel without recompiling + +# overloaded get_kernel_version function from kernel.inc get_kernel_version(){ - [ -z "${KERNEL_CURRENT_VERSION}" ] && perror "KERNEL_CURRENT_VERSION is not set, 'uname -r' output: '$(uname -r)'. Aborting..." - - # set SYS_UTS_RELEASE and SYS_KERNEL correctly - declare -rg SYS_UTS_RELEASE="${KERNEL_CURRENT_VERSION}" 2>/dev/null - declare -rg SYS_KERNEL="$(echo ${KERNEL_CURRENT_VERSION} | grep -o -E '^[0-9\.]+')" 2>/dev/null - - # KERNEL_NEW_VERSION is the same as KERNEL_CURRENT_VERSION - declare -rg KERNEL_NEW_VERSION="$KERNEL_CURRENT_VERSION" 2>/dev/null - - # check linux headers directory - if [ -d "/lib/modules/$KERNEL_CURRENT_VERSION/build" ]; then - declare -rg KERNEL_HEADERS_PATH="/lib/modules/$KERNEL_CURRENT_VERSION/build" 2>/dev/null - elif [ -d "/lib/modules/$KERNEL_CURRENT_VERSION/source" ]; then - declare -rg KERNEL_HEADERS_PATH="/lib/modules/$KERNEL_CURRENT_VERSION/source" 2>/dev/null - elif [ -d "/usr/src/linux-headers-$KERNEL_CURRENT_VERSION" ]; then - declare -rg KERNEL_HEADERS_PATH="/usr/src/linux-headers-$KERNEL_CURRENT_VERSION" 2>/dev/null - elif [ -d "/usr/src/kernels/$KERNEL_CURRENT_VERSION" ]; then - declare -rg KERNEL_HEADERS_PATH="/usr/src/kernels/$KERNEL_CURRENT_VERSION" 2>/dev/null - else - # fetch source did not install the headers correctly. - perror "kernel headers for $KERNEL_CURRENT_VERSION not found! Re-build the kernel-system module" - fi + [ -z "${SYSTEM_KERNEL_LONG}" ] && perror "SYSTEM_KERNEL_LONG is not set, should be done by kernel.inc on startup. Aborting..." + [ -n "${TARGET_KERNEL_LONG}" ] && return + + # set TARGET_KERNEL_LONG and TARGET_KERNEL_SHORT correctly + declare -rg TARGET_KERNEL_LONG="${SYSTEM_KERNEL_LONG}" + declare -rg TARGET_KERNEL_SHORT="$(echo ${SYSTEM_KERNEL_LONG} | grep -o -E '^[0-9\.]+')" + + # figure out linux headers directory + local DIR + local RES= + for DIR in "/lib/modules/$SYSTEM_KERNEL_LONG/build" "/lib/modules/$SYSTEM_KERNEL_LONG/source" \ + "/usr/src/linux-headers-$SYSTEM_KERNEL_LONG" "/usr/src/kernels/$SYSTEM_KERNEL_LONG"; do + [ -e "$DIR/include/linux/input" ] && RES=$DIR && break + # Sometimes the directory exists, but doesn't contain headers yet. Need a good way to + # figure that out. "include/linux/input" is a quick first idea that works on fedora and ubuntu. :) + done + # maybe fetch source did not install the headers correctly? + [ -z "$RES" ] && perror "kernel headers for $SYSTEM_KERNEL_LONG not found! Re-build the kernel-system module" + declare -rg KERNEL_HEADERS_DIR="$RES" 2>/dev/null # check kernel modules/firmware directory - if [ -d "/lib/modules/${KERNEL_CURRENT_VERSION}" -a \ - -d "/lib/firmware" ]; then + if [ -d "/lib/modules/${SYSTEM_KERNEL_LONG}" -a -d "/lib/firmware" ]; then # The expected paths exists, set KERNEL_BASE_DIR to / declare -rg KERNEL_BASE_DIR="/" 2>/dev/null else - perror "Could not find kernel modules / firmware for kernel version '$KERNEL_CURRENT_VERSION'. \ - Does '/lib/modules/$KERNEL_CURRENT_VERSION' exist?" + perror "Could not find kernel modules / firmware for kernel version '$SYSTEM_KERNEL_LONG'. \ + Does '/lib/modules/$SYSTEM_KERNEL_LONG' exist?" fi # print debug info - pdebug "SYS_UTS_RELEASE: '$SYS_UTS_RELEASE'" - pdebug "SYS_KERNEL: '$SYS_KERNEL'" - pdebug "KERNEL_NEW_VERSION: '$KERNEL_NEW_VERSION'" + pinfo "TARGET_KERNEL_LONG: '$TARGET_KERNEL_LONG'" + pinfo "TARGET_KERNEL_SHORT: '$TARGET_KERNEL_SHORT'" pdebug "KERNEL_BASE_DIR: '$KERNEL_BASE_DIR'" } @@ -44,13 +41,7 @@ get_kernel_version(){ fetch_source() { - - # get the source from repos, use meta-package for now - pinfo "Installing kernel headers from the repositories for version '${KERNEL_CURRENT_VERSION}'" - - # the actual install routine is done via config file - # through the REQUIRED_INSTALLED_PACKAGES variable - + : } build() { @@ -87,34 +78,11 @@ build() { pinfo "Live kernel path: $KERNEL_SYSTEM_PATH" # copy kernel to build directory - [ -z "${KERNEL_TARGET_NAME}" ] && perror "KERNEL_TARGET_NAME not set, this mean something is wrong with remote/include/kernel.inc" - cp "${KERNEL_SYSTEM_PATH}" "${MODULE_BUILD_DIR}/${KERNEL_TARGET_NAME}" && \ - pinfo "Copied kernel from '${KERNEL_SYSTEM_PATH}' to '${MODULE_BUILD_DIR}/${KERNEL_TARGET_NAME}'" + cp "${KERNEL_SYSTEM_PATH}" "${MODULE_BUILD_DIR}/kernel" \ + || perror "Copy of kernel failed: From '${KERNEL_SYSTEM_PATH}' to '${MODULE_BUILD_DIR}/kernel'" } post_copy() { : - #mkdir -p "$TARGET_BUILD_DIR/../kernel" - #cp -a "$MODULE_BUILD_DIR/kernel" "$TARGET_BUILD_DIR/../kernel/kernel" || perror "could not copy kernel to remote build dir." } -# currently not used -get_kernel_headers_path(){ - # determine the path to the kernel headers we just installed - for DIR in $(list_content_package --dirs linux-headers-$(uname -r) ); do - if [[ "$DIR" =~ .*linux-headers-$(uname -r)$ ]]; then - # validate candidate - [ -e "$DIR/./include/generated/utsrelease.h" ] \ - || perror "Could not find utsrelease.h at '$DIR/./include/generated/utsrelease.h'" - # TODO: maybe check if SYS_UTS_RELEASE is the same as in the header. - - # all good, we found it - pinfo "Kernel headers found at '$DIR'." - declare -rg KERNEL_HEADERS_PATH="$DIR" - break - fi - done - - [ -z "$KERNEL_HEADERS_PATH" ] && perror "KERNEL_HEADERS_PATH was not set correctly." - -} diff --git a/remote/modules/kernel-system/module.conf.ubuntu b/remote/modules/kernel-system/module.conf.ubuntu index 4d47b243..2f2ce122 100644 --- a/remote/modules/kernel-system/module.conf.ubuntu +++ b/remote/modules/kernel-system/module.conf.ubuntu @@ -1,6 +1,7 @@ REQUIRED_INSTALLED_PACKAGES=" - linux-headers-$(uname -r) + linux-headers-${SYSTEM_KERNEL_LONG} " REQUIRED_CONTENT_PACKAGES=" - linux-headers-$(uname -r) + linux-headers-${SYSTEM_KERNEL_LONG} " + diff --git a/remote/modules/kernel/module.build b/remote/modules/kernel/module.build index 9270024d..78179df6 100644 --- a/remote/modules/kernel/module.build +++ b/remote/modules/kernel/module.build @@ -1,28 +1,28 @@ +# Customized kernel from system: fetch Distro's kernel sources, patch configuration, recompile + +# This overrides get_kernel_version from kernel.inc, so the variables will be set properly get_kernel_version() { + [ -n "${TARGET_KERNEL_LONG}" ] && return 0 + [ ! -e "${MODULE_DIR}/ksrc/include/generated/utsrelease.h" ] && return 0 # determine kernel version that will be running in the generated system - if [ -e "$MODULES_DIR/kernel/ksrc/include/generated/utsrelease.h" ]; then - # declare kernel version stuff - declare -rg SYS_UTS_RELEASE=$(grep 'UTS_RELEASE' "$MODULES_DIR/kernel/ksrc/include/generated/utsrelease.h" | awk -F '"' '{print $2}') - declare -rg SYS_KERNEL=$(echo "$SYS_UTS_RELEASE" | grep -o -E '^[0-9\.]+') - declare -rg KERNEL_NEW_VERSION="$SYS_UTS_RELEASE" - - # declare path to kernel headers and modules/firmware - declare -rg KERNEL_HEADERS_PATH="$MODULES_DIR/kernel/ksrc" - declare -rg KERNEL_BASE_DIR="$MODULES_DIR/kernel/build" - fi + + # declare kernel version stuff + declare -rg TARGET_KERNEL_LONG=$(grep 'UTS_RELEASE' "${MODULE_DIR}/ksrc/include/generated/utsrelease.h" | awk -F '"' '{print $2}') + declare -rg TARGET_KERNEL_SHORT=$(echo "$TARGET_KERNEL_LONG" | grep -o -E '^[0-9\.]+') + + # declare path to kernel headers and modules/firmware + declare -rg KERNEL_HEADERS_DIR="${MODULE_DIR}/ksrc" + declare -rg KERNEL_BASE_DIR="${MODULE_DIR}/build" # print debug info - pdebug "SYS_UTS_RELEASE: '$SYS_UTS_RELEASE'" - pdebug "SYS_KERNEL: '$SYS_KERNEL'" - pdebug "KERNEL_NEW_VERSION: '$KERNEL_NEW_VERSION'" + pinfo "TARGET_KERNEL_LONG: '$TARGET_KERNEL_LONG'" + pinfo "TARGET_KERNEL_SHORT: '$TARGET_KERNEL_SHORT'" pdebug "KERNEL_BASE_DIR: '$KERNEL_BASE_DIR'" - - # check the headers/src path } fetch_source() { pdebug "getting kernel sources via git ...." - [ -d ./ksrc ] && rm -rf ./ksrc # slightly brutal ... + [ -d ./ksrc ] && rm -rf ./ksrc git clone --depth 1 "${REQUIRED_GIT}" -b "${REQUIRED_GIT_BRANCH}" ksrc || perror "Could not clone kernel git." # check for aufs local RSL=$(find ksrc/ -type d -name aufs) @@ -33,16 +33,16 @@ fetch_source() { pinfo "aufs detected in kernel source :)" fi # remember the current kernel version - echo "${KERNEL_CURRENT_VERSION}" > ksrc/KVERSION + echo "${SYSTEM_KERNEL_LONG}" > ksrc/KVERSION } build() { local TARGET_CONFIG_FILE="openslx.config" - [ -e "${TARGET_CONFIG_FILE}" ] && rm -f "${TARGET_CONFIG_FILE}" + rm -f "${TARGET_CONFIG_FILE}" # update config and copy to ksrc pinfo "Updating kernel config..." update_config - cp "${TARGET_CONFIG_FILE}" ksrc/.config + cp "${TARGET_CONFIG_FILE}" "ksrc/.config" # make kernel with the new config cd ksrc || perror "Could not cd to ksrc, was the kernel source fetched properly?" pinfo "Preparing kernel for new config ('make oldconfig')." @@ -55,14 +55,9 @@ build() { make scripts || perror "make scripts failed." pinfo "Compiling kernel... (this will take some time)" - if gcc --version | grep "4\.7" && which distcc; then - pinfo "USING DISTCC" - make CC="distcc gcc-4.7" -j16 || perror "make failed." - else - # explicitly state number of cores here, as MAKEFLAGS seems to be overridden - make "-j$CPU_CORES" || perror "make failed." - fi - + # explicitly state number of cores here, as MAKEFLAGS seems to be overridden + make "-j$CPU_CORES" || perror "make failed." + # install modules to build directory pinfo "Installing kernel modules..." if [ -d "${MODULE_BUILD_DIR}/lib/modules" ]; then @@ -72,8 +67,8 @@ build() { cd - 2> /dev/null # copy kernel to build - cp ksrc/arch/x86/boot/bzImage "${MODULE_BUILD_DIR}/${KERNEL_TARGET_NAME}" - pinfo "Kernel was successfully built at ${MODULE_BUILD_DIR}/${KERNEL_TARGET_NAME}" + cp ksrc/arch/x86/boot/bzImage "${MODULE_BUILD_DIR}/kernel" + pinfo "Kernel was successfully built at ${MODULE_BUILD_DIR}/kernel" [ -z "${KERNEL_BUILD_DIR}" ] && KERNEL_BUILD_DIR="${MODULE_BUILD_DIR}" } @@ -123,8 +118,8 @@ patch_aufs() { # git: --depth 1 won't work here due to later "checkout origin/branch" git clone "git://aufs.git.sourceforge.net/gitroot/aufs/aufs3-standalone.git" || perror "Cloning aufs3 failed." # get the needed version - [ ! -z ${KERNEL_CURRENT_VERSION} ] && local NEEDED_BRANCH=$(echo $KERNEL_CURRENT_VERSION | awk -F "." '{print $1"."$2}') \ - || perror "KERNEL_CURRENT_VERSION not set, this should not happen!" + [ ! -z ${SYSTEM_KERNEL_LONG} ] && local NEEDED_BRANCH=$(echo $SYSTEM_KERNEL_LONG | awk -F "." '{print $1"."$2}') \ + || perror "SYSTEM_KERNEL_LONG not set, this should not happen!" pinfo "Getting branch origin/$NEEDED_BRANCH" cd "$MODULE_DIR/aufs3-standalone" || perror "Could not CD to aufs3-standalone" git checkout "origin/aufs$NEEDED_BRANCH" || perror "Could not checkout needed branch." diff --git a/remote/modules/nvidia_kernel/module.build b/remote/modules/nvidia_kernel/module.build index a1275c70..648115c1 100644 --- a/remote/modules/nvidia_kernel/module.build +++ b/remote/modules/nvidia_kernel/module.build @@ -28,7 +28,7 @@ build() { chroot_run "$ROOTUPPERDIR" <<-EOF - /NVIDIA/nvidia-installer --no-nouveau-check --no-network --no-backup --no-rpms --no-runlevel-check --no-distro-scripts --no-cc-version-check --no-x-check --no-precompiled-interface --silent --kernel-source-path /"$KERNEL_HEADERS_PATH" # Do the work! + /NVIDIA/nvidia-installer --no-nouveau-check --no-network --no-backup --no-rpms --no-runlevel-check --no-distro-scripts --no-cc-version-check --no-x-check --no-precompiled-interface --silent --kernel-source-path /"$KERNEL_HEADERS_DIR" # Do the work! # fake success since the installer will exit with an error due to the module not loading properly. exit 0 EOF diff --git a/remote/modules/vmware/module.build b/remote/modules/vmware/module.build index 57e8cb91..094d5271 100644 --- a/remote/modules/vmware/module.build +++ b/remote/modules/vmware/module.build @@ -28,8 +28,8 @@ build() { cp "${MODULE_DIR}/src/$VMWARE_BUNDLE_FILE" "${MODULE_BUILD_DIR}/$VMWARE_BUNDLE_FILE" cp -r "${MODULE_DIR}/patches" "${MODULE_BUILD_DIR}" - # sanity check to see if KERNEL_HEADERS_PATH is set and exists - [ -z "${KERNEL_HEADERS_PATH}" -o ! -e "${KERNEL_HEADERS_PATH}" ] && perror "KERNEL_HEADERS_PATH ('"${KERNEL_HEADERS_PATH}"') not found. Was the kernel module built?" + # sanity check to see if KERNEL_HEADERS_DIR is set and exists + [ -z "${KERNEL_HEADERS_DIR}" -o ! -e "${KERNEL_HEADERS_DIR}" ] && perror "KERNEL_HEADERS_DIR ('"${KERNEL_HEADERS_DIR}"') not found. Was the kernel module built?" # build in two steps, to be able to use mltk function while patching modules pinfo "Installing vmware per chroot..." @@ -49,11 +49,11 @@ build() { for PATCH in $(find "${MODULE_DIR}/patches/" -name "${SHORT}__*__*.patch"); do parse_patch_name "$PATCH" [ -z "${MIN_KERN}" -o -z "${MAX_KERN}" ] && perror "Could not parse patch filename" - if version_lt "$SYS_KERNEL" "$MIN_KERN" || version_gt "$SYS_KERNEL" "$MAX_KERN"; then - pinfo "*NOT* applying $PATCH (min=$MIN_KERN max=$MAX_KERN cmp=$SYS_KERNEL)" + if version_lt "$TARGET_KERNEL_SHORT" "$MIN_KERN" || version_gt "$TARGET_KERNEL_SHORT" "$MAX_KERN"; then + pinfo "*NOT* applying $PATCH (min=$MIN_KERN max=$MAX_KERN cmp=$TARGET_KERNEL_SHORT)" continue # Not suitable for our kernel fi - pinfo "Applying $PATCH (min=$MIN_KERN max=$MAX_KERN cmp=$SYS_KERNEL)" + pinfo "Applying $PATCH (min=$MIN_KERN max=$MAX_KERN cmp=$TARGET_KERNEL_SHORT)" [ ! -d "${SHORT}-only" ] && tar xf "$KMOD" [ ! -d "${SHORT}-only" ] && perror "untar of $KMOD failed." cd "${SHORT}-only" || perror "Where is ${SHORT}-only?" @@ -74,8 +74,8 @@ build() { # now build modules inside the chroot chroot_run "${MODULE_BUILD_DIR}" <<-EOF - vmware-modconfig --console --build-mod -k "${SYS_UTS_RELEASE}" vmnet $(which gcc) "${KERNEL_HEADERS_PATH}/include" vmplayer vmnet - vmware-modconfig --console --build-mod -k "${SYS_UTS_RELEASE}" vmmon $(which gcc) "${KERNEL_HEADERS_PATH}/include" vmplayer vmmon + vmware-modconfig --console --build-mod -k "${TARGET_KERNEL_LONG}" vmnet $(which gcc) "${KERNEL_HEADERS_DIR}/include" vmplayer vmnet + vmware-modconfig --console --build-mod -k "${TARGET_KERNEL_LONG}" vmmon $(which gcc) "${KERNEL_HEADERS_DIR}/include" vmplayer vmmon EOF # cleanup unneeded files @@ -97,7 +97,7 @@ post_copy() { date +'%Y.%m.%d' >"${TARGET_BUILD_DIR}/etc/arch-release" mkdir -p "$TARGET_BUILD_DIR/lib/modules/vmware/" - cp "${MODULE_BUILD_DIR}/lib/modules/$SYS_UTS_RELEASE/vmplayer/"* "$TARGET_BUILD_DIR/lib/modules/vmware/" || perror "Could not cp vmware modules to target!" + cp "${MODULE_BUILD_DIR}/lib/modules/$TARGET_KERNEL_LONG/vmplayer/"* "$TARGET_BUILD_DIR/lib/modules/vmware/" || perror "Could not cp vmware modules to target!" } parse_patch_name() { |
