From a59214f344567c037d5776879bcfc5fcc1d4d5f6 Mon Sep 17 00:00:00 2001 From: Jacob McDonnell Date: Sat, 25 Apr 2026 14:50:51 -0400 Subject: feat:Script to Build and Register Created a script that will build all the manpages and register them into an sqlite3 database. Each entry has the name, section, os, and path to the html fragment. --- .gitignore | 1 + build | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .gitignore create mode 100755 build diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..b8ab3223 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +man.db diff --git a/build b/build new file mode 100755 index 00000000..c7eb7fcb --- /dev/null +++ b/build @@ -0,0 +1,55 @@ +#!/usr/bin/env bash + +SUBDIRS=(static/openbsd) + +sqlite3 man.db <&2 + exit 1 +fi + +for SUBDIR in ${SUBDIRS[*]}; +do + make -j "$(nproc)" -C "$SUBDIR" + + if [[ $? != 0 ]]; + then + printf "Error: error building %s man pages.\n" "$SUBDIR" >&2 + exit 1 + fi + + HTML=$(find "$SUBDIR" -type f -name '*.html') + + for FILE in $HTML; + do + SECTION=$(basename "$FILE" | sed -E 's|.*\.([0-9])\..*|\1|') + NAME=$(basename "$FILE" | sed -E 's|(.*)\.[0-9]\.html|\1|') + OS=$(basename "$SUBDIR") + + if [[ -n "$(echo "$FILE" | grep "man$SECTION\.")" ]]; + then + NAME="$(echo "$FILE" | sed -E "s|.*man$SECTION\.(.*)/.*|\1|" ).$NAME" + fi + + echo "INSERT INTO manpages (os, name, section, path) VALUES ('"$OS"', '"$NAME"', '"$SECTION"', '"$FILE"');" + sqlite3 man.db \ + "INSERT INTO manpages (os, name, section, path) VALUES ('"$OS"', '"$NAME"', '"$SECTION"', '"$FILE"');" + + if [[ $? != 0 ]]; + then + printf "Error: error inserting ('%s', '%s', '%s', '%s').\n" "$OS" "$NAME" "$SECTION" "$FILE" >&2 + exit 1 + fi + done +done + -- cgit v1.2.3