diff options
author | Simon Rettberg | 2014-07-04 20:04:41 +0200 |
---|---|---|
committer | Simon Rettberg | 2014-07-04 20:04:41 +0200 |
commit | b7a021b2df67c6d08457df32f3ba1514897ac70b (patch) | |
tree | f038199bdd92329808f1c54bf41d646d9dfe6fd3 /remote/modules/kernel-system | |
parent | [downloader.inc] Special case sourceforge: Allow setting a mirror in ./config (diff) | |
download | tm-scripts-b7a021b2df67c6d08457df32f3ba1514897ac70b.tar.gz tm-scripts-b7a021b2df67c6d08457df32f3ba1514897ac70b.tar.xz tm-scripts-b7a021b2df67c6d08457df32f3ba1514897ac70b.zip |
Try to clean up the mess with all the different kernel version variables everywhere
Diffstat (limited to 'remote/modules/kernel-system')
-rw-r--r-- | remote/modules/kernel-system/module.build | 92 | ||||
-rw-r--r-- | remote/modules/kernel-system/module.conf.ubuntu | 5 |
2 files changed, 33 insertions, 64 deletions
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} " + |