From eb3ae482789ef92376d0cf30c0b828a426b40e22 Mon Sep 17 00:00:00 2001 From: Alexey Neyman Date: Wed, 25 Jan 2017 15:45:37 -0800 Subject: Fix log saving/restoring after the CT_Log{Enable,Disable} changes. Signed-off-by: Alexey Neyman diff --git a/scripts/crosstool-NG.sh.in b/scripts/crosstool-NG.sh.in index eeb7800..4aa3975 100644 --- a/scripts/crosstool-NG.sh.in +++ b/scripts/crosstool-NG.sh.in @@ -22,8 +22,8 @@ # Read the sample settings CT_LoadConfig -# Yes! We can do full logging from now on! -CT_LogEnable +# Yes! We can do full logging from now on! Clean any old log file content. +CT_LogEnable clean=yes # Check running as root if [ -z "${CT_ALLOW_BUILD_AS_ROOT_SURE}" ]; then diff --git a/scripts/functions b/scripts/functions index 9aa4fc7..4e2d67f 100644 --- a/scripts/functions +++ b/scripts/functions @@ -152,7 +152,7 @@ CT_OnError() { CT_STEP_COUNT=1 # To have a zero-indentation CT_DoLog ERROR ">>" if [ "${CT_LOG_TO_FILE}" = "y" ]; then - CT_DoLog ERROR ">> For more info on this error, look at the file: '${tmp_log_file#${CT_TOP_DIR}/}'" + CT_DoLog ERROR ">> For more info on this error, look at the file: '${CT_BUILD_LOG#${CT_TOP_DIR}/}'" fi CT_DoLog ERROR ">> There is a list of known issues, some with workarounds, in:" CT_DoLog ERROR ">> '${CT_DOC_DIR#${CT_TOP_DIR}/}/B - Known issues.txt'" @@ -186,10 +186,16 @@ set +o hashall # FIXME: it doesn't look like anyone is overriding stdin/stderr. Do we need # to save/restore them? CT_LogEnable() { + local clean=no + local arg + + for arg in "$@"; do eval "$arg"; done exec 6>&1 7>&2 8<&0 CT_BUILD_LOG="${CT_TOP_DIR}/build.log" CT_LOG_ENABLED=y - rm -f "${CT_BUILD_LOG}" + if [ "$clean" = "yes" ]; then + rm -f "${CT_BUILD_LOG}" + fi exec >>"${CT_BUILD_LOG}" } @@ -1558,12 +1564,12 @@ CT_DoSaveState() { CT_DoTarballIfExists "${CT_PREFIX_DIR}" "${state_dir}/prefix_dir" --exclude '*.log' CT_DoLog STATE " Saving log file" - exec >/dev/null + CT_LogDisable case "${CT_DEBUG_CT_SAVE_STEPS_GZIP}" in - y) gzip -3 -c "${tmp_log_file}" >"${state_dir}/log.gz";; - *) cat "${tmp_log_file}" >"${state_dir}/log";; + y) gzip -3 -c "${CT_BUILD_LOG}" >"${state_dir}/log.gz";; + *) cat "${CT_BUILD_LOG}" >"${state_dir}/log";; esac - exec >>"${tmp_log_file}" + CT_LogEnable } # This function restores a previously saved state @@ -1576,11 +1582,6 @@ CT_DoLoadState(){ CT_TestOrAbort "The previous build did not reach the point where it could be restarted at '${CT_RESTART}'" -d "${state_dir}" - # We need to do something special with the log file! - if [ "${CT_LOG_TO_FILE}" = "y" ]; then - exec >"${state_dir}/tail.log" - fi - CT_DoLog INFO "Restoring state at step '${state_name}', as requested." CT_DoExtractTarballIfExists "${state_dir}/prefix_dir" "${CT_PREFIX_DIR}" @@ -1597,14 +1598,15 @@ CT_DoLoadState(){ unset old_stop old_restart CT_DoLog STATE " Restoring log file" - exec >/dev/null + CT_LogDisable + mv "${CT_BUILD_LOG}" "${CT_BUILD_LOG}.tail" case "${CT_DEBUG_CT_SAVE_STEPS_GZIP}" in - y) gzip -dc "${state_dir}/log.gz" >"${tmp_log_file}";; - *) cat "${state_dir}/log" >"${tmp_log_file}";; + y) gzip -dc "${state_dir}/log.gz" >"${CT_BUILD_LOG}";; + *) cat "${state_dir}/log" >"${CT_BUILD_LOG}";; esac - cat "${state_dir}/tail.log" >>"${tmp_log_file}" - exec >>"${tmp_log_file}" - rm -f "${state_dir}/tail.log" + cat "${CT_BUILD_LOG}.tail" >>"${CT_BUILD_LOG}" + CT_LogEnable + rm -f "${CT_BUILD_LOG}.tail" } # This function sets a kconfig option to a specific value in a .config file -- cgit v0.10.2-6-g49f6