runners: introduce internal skip_error_info=yes for run_host_command_logged()

- doesn't show nor clear vars `if_error_find_files_sdcard` and `if_error_detail_message`
- used by `chroot_sdcard_apt_get()` which uses `run_host_command_logged()` multiple times, and the first would clear the important/last one
This commit is contained in:
Ricardo Pardini
2023-03-24 21:38:25 +01:00
committed by Igor Pečovnik
parent a77d5f3c70
commit 9a74b838ce

View File

@@ -86,11 +86,11 @@ function chroot_sdcard_apt_get() {
local_apt_deb_cache_prepare "before 'apt-get $*'" # sets LOCAL_APT_CACHE_INFO
if [[ "${LOCAL_APT_CACHE_INFO[USE]}" == "yes" ]]; then
# prepare and mount apt cache dir at /var/cache/apt/archives in the SDCARD.
run_host_command_logged mkdir -pv "${LOCAL_APT_CACHE_INFO[SDCARD_DEBS_DIR]}" "${LOCAL_APT_CACHE_INFO[SDCARD_LISTS_DIR]}"
skip_error_info="yes" run_host_command_logged mkdir -pv "${LOCAL_APT_CACHE_INFO[SDCARD_DEBS_DIR]}" "${LOCAL_APT_CACHE_INFO[SDCARD_LISTS_DIR]}"
display_alert "Mounting local apt deb cache dir" "${LOCAL_APT_CACHE_INFO[SDCARD_DEBS_DIR]}" "debug"
run_host_command_logged mount --bind "${LOCAL_APT_CACHE_INFO[HOST_DEBS_DIR]}" "${LOCAL_APT_CACHE_INFO[SDCARD_DEBS_DIR]}"
skip_error_info="yes" run_host_command_logged mount --bind "${LOCAL_APT_CACHE_INFO[HOST_DEBS_DIR]}" "${LOCAL_APT_CACHE_INFO[SDCARD_DEBS_DIR]}"
display_alert "Mounting local apt list cache dir" "${LOCAL_APT_CACHE_INFO[SDCARD_LISTS_DIR]}" "debug"
run_host_command_logged mount --bind "${LOCAL_APT_CACHE_INFO[HOST_LISTS_DIR]}" "${LOCAL_APT_CACHE_INFO[SDCARD_LISTS_DIR]}"
skip_error_info="yes" run_host_command_logged mount --bind "${LOCAL_APT_CACHE_INFO[HOST_LISTS_DIR]}" "${LOCAL_APT_CACHE_INFO[SDCARD_LISTS_DIR]}"
fi
local chroot_apt_result=1
@@ -211,10 +211,14 @@ function run_host_command_logged_raw() {
display_alert_skip_screen=1 display_alert "stacktrace for failed command" "exit code ${exit_code}:$*\n$(stack_color="${magenta_color:-}" show_caller_full)" "wrn"
# Obtain extra info about error, eg, log files produced, extra messages set by caller, etc.
logging_enrich_run_command_error_info
if [[ "${skip_error_info:-"no"}" != "yes" ]]; then
logging_enrich_run_command_error_info
fi
fi
logging_clear_run_command_error_info # clear the error info vars, always, otherwise they'll leak into the next invocation.
if [[ "${skip_error_info:-"no"}" != "yes" ]]; then
logging_clear_run_command_error_info # clear the error info vars, always, otherwise they'll leak into the next invocation.
fi
return ${exit_code} # exiting with the same error code as the original error
}
@@ -229,6 +233,7 @@ function logging_enrich_run_command_error_info() {
declare -a found_files=()
for path in "${if_error_find_files_sdcard[@]}"; do
display_alert "Searching for if_error_find_files_sdcard files" "${SDCARD}/${path}" "debug"
declare -a sdcard_files
# shellcheck disable=SC2086 # I wanna expand, thank you...
mapfile -t sdcard_files < <(find ${SDCARD}/${path} -type f)