From c2362050ff4d92705e50a79906d5e62a7954e2df Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 8 Jul 2013 14:37:38 +0200 Subject: [kernel] remember last built version and if new kernel is detected, ask what to do. WARNING: KVERSION file will be missing, write the old (uname -r) under remote/modules/ksrc/KVERSION to be safe :) --- remote/setup_target | 54 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 37 insertions(+), 17 deletions(-) (limited to 'remote/setup_target') diff --git a/remote/setup_target b/remote/setup_target index 1638f392..f5df66ad 100755 --- a/remote/setup_target +++ b/remote/setup_target @@ -227,6 +227,30 @@ generate_target() { pinfo "Activated modules in '${TARGET}':" pinfo "\t$(echo ${MODULES})" + # we need a bit of special logic for kernel specifically + # to check if the built version is corresponding to the + # current kernel version. If not we had a kernel update + # and need to ask the user what to do + if [[ "$MODULES" == *kernel* ]]; then + # if so, check what kernels have been built + if [ -e "${MODULES_DIR}/kernel/ksrc/KVERSION" ]; then + local BUILT_KERNEL_VERSION=$(cat "${MODULES_DIR}/kernel/ksrc/KVERSION") + if [[ "${BUILT_KERNEL_VERSION}" != "${KERNEL_CURRENT_VERSION}" ]]; then + pinfo "The built kernel (${BUILT_KERNEL_VERSION}) is older than the running one (${KERNEL_CURRENT_VERSION})!" + pinfo "Do you want to clean the old kernel and re-build for the new version? (Y/n)" + read USER_INPUT + if [ "x$USER_INPUT" == "xy" -o "x$USER_INPUT" == "xY" -o "x$USER_INPUT" == "x" ]; then + clean_kernel_module --force + # cleaning the module is enough as it forces to rebuild. + fi + fi + else + # KVERSION is not found. + pdebug "KVERSION not found under remote/modules/kernel/ksrc/KVERSION" + pdebug "Ignoring. If errors arise, either write your KVERSION manually or clean the kernel." + fi + fi + # copy basic libs pinfo "Copying libc and ld-linux used by ${SHELL}" tarcopy "$(list_basic_libs)" "${TARGET_BUILD_DIR}" @@ -255,11 +279,6 @@ process_module() { pinfo ">>>>>>>>>>>>>>>>> Processing module [ $MODULE ]" TOOL_STR="[${MODULE}]" if [ -d "${MODULE_DIR}" ]; then - - #[ "x$DEBUG" != "x1" ] \ - # && echo "Logging to ${TOOL_DIR}/${TOOL}/stage32.log" \ - # && exec 6>&1 > ${TOOL_DIR}/${TOOL}/stage32.log - # TODO: Make above work with the new logging system (add function to logging.inc to switch logfile) cd "${MODULE_DIR}" || perror "Module dir '${MODULE_DIR}' seems to exist, but cd to it failed." pinfo "## Reading config" read_config @@ -299,10 +318,8 @@ process_module() { copy_static_data pinfo "## Post copy" post_copy - # reset pipes - #[ "x$DEBUG" != "x1" ] && exec 1>&6 6>&- - # TODO - calc_size #sets MODULE_BUILD_SIZE + # set MODULE_BUILD_SIZE + calc_size pinfo "Module completed. Total size: ${MODULE_BUILD_SIZE}" else pwarning "Module directory for '$MODULE' not found." @@ -310,10 +327,8 @@ process_module() { } post_process_target() { - local TOOL_STR="$TOOL_STR post_process_target:" - - #move systemd files from /lib to /etc/lib + # move systemd files from /lib to /etc/lib pinfo "move systemd files from /lib/systemd to /etc/systemd" if [ -d "${TARGET_BUILD_DIR}/lib/systemd" ]; then cd "${TARGET_BUILD_DIR}/lib" @@ -404,12 +419,17 @@ clean_module() { } clean_kernel_module() { + local CLEAN=0 + if [ "x$1" == "x--force" ]; then + CLEAN=1 + else + pinfo "It will take a long time to rebuild, are you sure? [y/N]" + read USER_INPUT + [ "x$USER_INPUT" == "xy" ] && CLEAN=1 + fi + pinfo "Cleaning kernel module (including sources and compiled stuff)." - pinfo "It will take a long time to rebuild, are you sure? [y/N]" - read USER_INPUT - if [ "x$USER_INPUT" == "xy" ]; then - pinfo "Confirmed, going on..." - # clean kernel module + if [[ $CLEAN == 1 ]]; then cd "${TARGET_DIR}/kernel" || perror "Could not cd to ${TARGET_DIR}/kernel" if [ -e build ]; then rm -rf build || perror "Could not delete ${TARGET_DIR}/kernel/build" -- cgit v1.2.3-55-g7522 From 3bc8241149d0a2170753d64b85510bc22af3805a Mon Sep 17 00:00:00 2001 From: Jonathan Bauer Date: Mon, 8 Jul 2013 14:44:28 +0200 Subject: AUTO_UPDATE_KERNEL flag to rebuild kernel on version update or not --- mltk | 5 +++++ remote/setup_target | 8 ++------ 2 files changed, 7 insertions(+), 6 deletions(-) (limited to 'remote/setup_target') diff --git a/mltk b/mltk index 8db16566..1e554824 100755 --- a/mltk +++ b/mltk @@ -27,10 +27,15 @@ for i in $DEVTOOLS; do which "$i" 2>/dev/null 1>&2 || { echo "Essential development tool $i not found - exiting."; exit 1; } done +# AUTO_UPDATE_KERNEL flag to rebuild kernel if a new version is detected +AUTO_UPDATE_KERNEL=1 + # Make apt-get install non-interactive when it comes to postinstall questions # ie. kdm asking which dm you want to set as default export DEBIAN_FRONTEND=noninteractive + + qnd_exit() { unset_quiet kill "$MLTK_PID" diff --git a/remote/setup_target b/remote/setup_target index f5df66ad..804f43bc 100755 --- a/remote/setup_target +++ b/remote/setup_target @@ -237,12 +237,8 @@ generate_target() { local BUILT_KERNEL_VERSION=$(cat "${MODULES_DIR}/kernel/ksrc/KVERSION") if [[ "${BUILT_KERNEL_VERSION}" != "${KERNEL_CURRENT_VERSION}" ]]; then pinfo "The built kernel (${BUILT_KERNEL_VERSION}) is older than the running one (${KERNEL_CURRENT_VERSION})!" - pinfo "Do you want to clean the old kernel and re-build for the new version? (Y/n)" - read USER_INPUT - if [ "x$USER_INPUT" == "xy" -o "x$USER_INPUT" == "xY" -o "x$USER_INPUT" == "x" ]; then - clean_kernel_module --force - # cleaning the module is enough as it forces to rebuild. - fi + # cleaning the module is enough as it forces to rebuild. + [[ "${AUTO_UPDATE_KERNEL}" == 1 ]] && pinfo "Auto-Udpate Kernel..." && clean_kernel_module --force fi else # KVERSION is not found. -- cgit v1.2.3-55-g7522