25 lines
1.2 KiB
Bash
Executable File
25 lines
1.2 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Build normalized diagnostic artifacts and source-faithful PDFs in bulk.
|
|
set -euo pipefail
|
|
cd "$(dirname "${BASH_SOURCE[0]}")/.."
|
|
[[ $# -ge 4 && $# -le 6 ]] || {
|
|
echo "Usage: $0 CAPTURE_DIR EVIDENCE_ROOT NEW_OUTPUT_ROOT REFERENCE_TIME [AUTHOR] [THEME]" >&2
|
|
exit 2
|
|
}
|
|
capture_dir=$(realpath "$1") evidence_root=$(realpath "$2") output_root=$3 reference_time=$4
|
|
author=${5:-${DIAGNOSTICS_AUTHOR:-Beffroi}} theme=${6:-${DIAGNOSTICS_THEME:-default}}
|
|
[[ ! -e "$output_root" ]] || { echo "$output_root: output root exists" >&2; exit 1; }
|
|
mkdir -p "$output_root/diagnostics" "$output_root/pdfs"
|
|
reports/plugins/diagnostics/analyse-all.sh "$capture_dir" --evidence-root "$evidence_root" \
|
|
--output-dir "$output_root/diagnostics" --reference-time "$reference_time" \
|
|
--producer-version "$(git -C reports rev-parse HEAD)"
|
|
count=0
|
|
while IFS= read -r -d '' capture; do
|
|
relative=${capture#"$capture_dir/"}
|
|
output="$output_root/pdfs/${relative%.json}.pdf"
|
|
mkdir -p "$(dirname "$output")"
|
|
reports/plugins/diagnostics/render.sh "$capture" --output "$output" --author "$author" --theme "$theme"
|
|
((count+=1))
|
|
done < <(find "$capture_dir" -type f -name '*.json' -print0 | sort -z)
|
|
echo "Created $count diagnostic artifacts and PDFs under $output_root"
|