From d2fe43f7a2b9f214c3ce7688f449974b40eb4641 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Sun, 2 Mar 2025 02:49:32 -0500 Subject: Add OAP generation script Signed-off-by: Ian Moffett --- genoaps.sh | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 genoaps.sh (limited to 'genoaps.sh') diff --git a/genoaps.sh b/genoaps.sh new file mode 100644 index 0000000..50fff04 --- /dev/null +++ b/genoaps.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +set -e + +KRAMDOWN_DIR=kd +XML_RESDIR=xmlgen +OAP_RESDIR=oapgen +OAPS=$(find $KRAMDOWN_DIR -name "*.md") + +cleanup() { + echo "genoaps: Cleaning up..." + echo "genoaps: Removing artifacts..." + rm -rfv $XML_RESDIR + rm -rfv $OAP_RESDIR +} + +convert_all() { + for oap in $OAPS + do + output="${oap%.md}.txt" + + echo "Preparing $oap..." + kdrfc $oap 1>/dev/null || cleanup + + # Clean up output + tr -d '\000-\011\013\014\016-\037' <$output | \ + sed '1,/./{/^$/d;}' | tee $output >/dev/null + + mv $output $OAP_RESDIR/$(basename "${output%.txt}") + mv $KRAMDOWN_DIR/*.xml $XML_RESDIR + done +} + + +if [[ "$1" == "--clean" ]] +then + cleanup + exit 0 +fi + +mkdir -p $XML_RESDIR +mkdir -p $OAP_RESDIR +convert_all +echo "** Done! OAPs generated in the $OAP_RESDIR directory **" -- cgit v1.2.3