From b7a021b2df67c6d08457df32f3ba1514897ac70b Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 4 Jul 2014 20:04:41 +0200 Subject: Try to clean up the mess with all the different kernel version variables everywhere --- remote/modules/kernel/module.build | 57 +++++++++++++++++--------------------- 1 file changed, 26 insertions(+), 31 deletions(-) (limited to 'remote/modules/kernel') 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." -- cgit v1.2.3-55-g7522