From f75b9c110fdecb30ab9456340e2f67ddd9a15c9f Mon Sep 17 00:00:00 2001 From: Ricardo Pardini Date: Wed, 29 Mar 2023 13:16:09 +0200 Subject: [PATCH] aggregation: fix: don't eat value if empty during `bash_string_multiline()`; write end-of-file comment; show aggregation bash results if debugging --- lib/functions/configuration/aggregation.sh | 7 ++++++- lib/tools/aggregation.py | 1 + lib/tools/common/aggregation_utils.py | 7 +++---- 3 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/functions/configuration/aggregation.sh b/lib/functions/configuration/aggregation.sh index 4fcff95a2..7b26f8e3b 100644 --- a/lib/functions/configuration/aggregation.sh +++ b/lib/functions/configuration/aggregation.sh @@ -104,7 +104,12 @@ function aggregate_all_packages_python() { # "raw_command" is only for logging purposes. raw_command="[...shortened...] ${PYTHON3_INFO[BIN]} ${SRC}/lib/tools/aggregation.py" \ run_host_command_logged env -i "${aggregation_params_quoted[@]@Q}" "${PYTHON3_INFO[BIN]}" "${SRC}/lib/tools/aggregation.py" - #run_host_command_logged cat "${temp_file_for_aggregation}" + + if [[ "${SHOW_DEBUG}" == "yes" ]]; then + display_alert "Showing aggregation results" "below" "debug" + run_tool_batcat --file-name "aggregation_results/aggregation_results.sh" "${temp_file_for_aggregation}" + fi + # shellcheck disable=SC1090 source "${temp_file_for_aggregation}" # SOURCE IT! run_host_command_logged rm -f "${temp_file_for_aggregation}" diff --git a/lib/tools/aggregation.py b/lib/tools/aggregation.py index 821bf031e..5f3e96d78 100755 --- a/lib/tools/aggregation.py +++ b/lib/tools/aggregation.py @@ -214,6 +214,7 @@ with open(output_file, "w") as bash, SummarizedMarkdownWriter("aggregation.md", "AGGREGATED_DESKTOP_BSP_POSTINST", AGGREGATED_DESKTOP_BSP_POSTINST)) bash.write(util.prepare_bash_output_single_string( "AGGREGATED_DESKTOP_BSP_PREPARE", AGGREGATED_DESKTOP_BSP_PREPARE)) + bash.write("\n## End of aggregation output\n"); # 2) @TODO: Some removals... uninstall-inside-cache and such. (debsums case? also some gnome stuff) diff --git a/lib/tools/common/aggregation_utils.py b/lib/tools/common/aggregation_utils.py index 5dceb6e00..8244e91f8 100755 --- a/lib/tools/common/aggregation_utils.py +++ b/lib/tools/common/aggregation_utils.py @@ -318,14 +318,13 @@ def prepare_bash_output_single_string(output_array_name, merged_list): "contents"] + "\n" + "### END Source: " + refs_str + "\n\n") values_list_bash = "\n".join(values_list) + if (len(values_list_bash) == 0): + values_list_bash = "### NO sources found during aggregation.\n" return bash_string_multiline(output_array_name, values_list_bash) def bash_string_multiline(var_name, contents): - return f"declare -g {var_name}" + "\n" + ( - f"{var_name}=\"$(cat <<-'EOD_{var_name}_EOD'\n" + - f"{contents}\nEOD_{var_name}_EOD\n)\"\n" + "\n" - ) + f"declare -r -g {var_name}" + "\n" + return f"declare -g {var_name}\n{var_name}=\"$(cat <<-'EOD_{var_name}_EOD'\n{contents}\nEOD_{var_name}_EOD\n)\"\n\n" def encode_source_base_path_extra(contents_dict):