alexkarle.com

Source for alexkarle.com
git clone git://git.alexkarle.com/alexkarle.com.git
Log | Files | Refs | README | LICENSE

commit d849b56b7fd059c46f087dec13e47725408f5ac8 (patch)
parent 4737d3c4ccad1a0081d503b876ea6335953d801e
Author: Alex Karle <alex@alexkarle.com>
Date:   Tue, 14 Sep 2021 23:10:13 -0400

build: Move generated sed link fixer to its own script

I was a bit uneasy about eval'ing the output of awk as a sed command. I
mean, it was clever, and I'm _effectively_ still doing the same thing,
but it feels a bit cleaner to generate a standalone script in bin/ that
can be used in all places necessary!

Diffstat:
M.gitignore | 6++++++
MMakefile | 11+++++++++--
Mbin/genatom.sh | 6++++--
Mbin/genpost.sh | 6++++--
4 files changed, 23 insertions(+), 6 deletions(-)

diff --git a/.gitignore b/.gitignore @@ -13,5 +13,11 @@ jam-tuesday/greatest-hits # text files (gopher, text.alexkarle.com) text/ +# html files (www.alexkarle.com) +html/ + # obj directory on OpenBSD for out-of-tree builds obj/ + +# Generated sed command to touch up out-of-base Xr references +bin/fixlinks diff --git a/Makefile b/Makefile @@ -35,7 +35,7 @@ obj: .PHONY: clean clean: - rm -f *.ts + rm -f *.ts bin/fixlinks rm -rf text html obj #---------------------------------------------------------- @@ -81,7 +81,14 @@ text/LICENSE: LICENSE # The most egregious hack here is the live renaming of the files via # grepping through the ORDER file so that text.alexkarle.com presents # the files in a reasonable order for viewing -$(TS): bin/genpost.sh +$(TS): bin/genpost.sh bin/fixlinks + +bin/fixlinks: LINKS + mkdir -p bin + printf "#!/bin/sh\n# GENERATED DO NOT EDIT\nsed" > $@ + awk '{ printf " \\\n -e s#https://man.openbsd.org/%s#%s#g", $$1, $$2 } END { printf "\n" }' $(DIR)/LINKS >> $@ + chmod +x $@ + .SUFFIXES: .7 .ts .7.ts: diff --git a/bin/genatom.sh b/bin/genatom.sh @@ -4,6 +4,9 @@ set -e REPO=$(dirname "$(dirname "$0")") +# Find fixlinks in either bin or the out-of-tree obj build +PATH="$REPO/bin:$REPO/obj/bin:$PATH" + # All posts are a item (.It) in the list, and linked via .Xr POSTS=$(sed '/SEE ALSO/q' "$REPO/blog.7" | grep -A1 '\.It' | grep '\.Xr' | sed 's/^\.Xr \([^ ]*\) 7/\1/') # Assume dates are 1-1 @@ -40,8 +43,7 @@ ENTRY # Print fragment (no need for escapes -- in CDATA mandoc -Thtml -O'fragment,man=%N.html;https://man.openbsd.org/%N.%S' "$REPO/$p.7" \ | sed '/<td class="head-vol">Miscellaneous Information Manual<\/td>/d' \ - | eval \ - "sed $(awk '{ printf " \\\n -e s#https://man.openbsd.org/%s#%s#g", $1, $2 } END { printf "\n" }' "$REPO/LINKS")" + | fixlinks cat <<EOENTRY ]]> </content> diff --git a/bin/genpost.sh b/bin/genpost.sh @@ -5,6 +5,9 @@ REPO=$(dirname "$(dirname "$0")") # cd into $REPO so that the includes work! cd $REPO +# Find fixlinks in either bin or the out-of-tree obj build +PATH="$REPO/bin:$REPO/obj/bin:$PATH" + # Command Explained # ----------------- # man=%N.html;man.openbsd.org -- look for files in CWD for .Xr, then link to openbsd.org @@ -22,5 +25,4 @@ mandoc -Thtml -O 'man=%N.html;https://man.openbsd.org/%N.%S,style=style.css' \ -e 's#</body>#<p class="foot-license">\ © 2019-2021 Alex Karle | <a href="/">Home</a> | <a href="/license.html">License</a>\ </p>\ -&#' | eval \ - "sed $(awk '{ printf " \\\n -e s#https://man.openbsd.org/%s#%s#g", $1, $2 } END { printf "\n" }' LINKS)" +&#' | fixlinks