From 83e8568dcf72531409f6bfe20d9a2c05f4d47a62 Mon Sep 17 00:00:00 2001 From: Gilles Peskine Date: Mon, 15 Sep 2025 15:15:28 +0200 Subject: [PATCH] New script to save historical config options information Signed-off-by: Gilles Peskine --- scripts/save_config_history.sh | 81 ++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100755 scripts/save_config_history.sh diff --git a/scripts/save_config_history.sh b/scripts/save_config_history.sh new file mode 100755 index 000000000..b610c9e4b --- /dev/null +++ b/scripts/save_config_history.sh @@ -0,0 +1,81 @@ +#!/bin/sh + +usage () { + cat <&2; exit 120;; + esac +done + +if [ $# -ne 2 ]; then + echo >&2 "This script requires exactly two non-option arguments: COMMIT VERSION" + usage >&2 + exit 120 +fi +commit=$1 +version=$2 + +# Assert that the git commit exists +git -C "$project_root" cat-file -e "${commit}^{commit}" + +product=mbedtls +if git -C "$project_root" merge-base --is-ancestor 0679e3a841c3317dc1f4a0faacc350bc91662b04 "$commit"; then + product=tfpsacrypto +else + product=mbedtls +fi + +temp_file=$(mktemp) +trap 'rm -f "$temp_file"' EXIT INT TERM + +collect_macros () { + output_file="$history_dir/config-$1-$product-$version.txt" + shift + : >"$temp_file" + for header in "$@"; do + git -C "$project_root" show "$commit:$header" >>"$temp_file" + done + sed -n 's![/ ]*# *define *\([A-Z_a-z][0-9A-Z_a-z]*\).*!\1!p' <"$temp_file" | + sort -u >"$output_file" + if [ ! -s "$output_file" ]; then + echo >&2 "$0: Failed to find any config option" + exit 1 + fi +} + + +collect_macros options $(git -C "$project_root" ls-tree -r --name-only "$commit" \ + include/mbedtls/mbedtls_config.h include/psa/crypto_config.h) +collect_macros adjust $(git -C "$project_root" ls-tree -r --name-only "$commit" | + grep '_adjust.*\.h$')