use yet even more bin/jval-wrapper.sh instead of direct grep of JSON files

We use the `bin/jval-wrapper.sh` tool to obtain information from JSON
files instead of attempting using a "GROSS HACK" that involved using
`grep(1)` (and friends) as those "GROSS HACK"s assumed that the layout of
the JSON was canonical.  The `bin/jval-wrapper.sh` tool is able to deal
with various layouts of JSON including non-canonical layouts.  Moreover,
by using the `bin/jval-wrapper.sh` tool we greatly reduce the places in
bin tools that contain "GROSS HACK"s.

Adjusted `bin/gen-status.sh` to use `bin/jval-wrapper.sh`.

Changed `bin/gen-status.sh` VERSION from "1.5.8 2024-08-05"
to "1.6 2024-08-17".

Performed `make gen_status` to test the above under macOS.

Adjusted `bin/gen-years.sh` to use `bin/jval-wrapper.sh`.

Changed `bin/gen-years.sh` VERSION from "1.3.7 2024-08-05"
to "1.4 2024-08-17".

Performed `make gen_years` to test the above under macOS.

Adjusted `bin/output-index-author.sh` to use `bin/jval-wrapper.sh`.

Changed `bin/output-index-author.sh` VERSION from "1.7.3 2024-08-05"
to "1.8 2024-08-17".

Performed `make entry_index` to test the above under macOS.

Added `make quick_year_index` to generate year level index.html files
when year level `YYYY/README.md` is newer.

The `make quick_www` calls `quick_year_index` instead of `make gen_year_index`.

The `bin` directory is now sat as `BIN_PATH=$TOPDIR/bin`, where
`$TOPDIR` is determined by top of the git repo (as determined by
the command: `git rev-parse --is-inside-work-tree`) and potentially
modified by `-d topdir`.  After `cd $TOPDIR`, we set `BIN_DIR=bin`.

All tools from this repo are now assumed to under "$BIN_DIR".  Removed
command like options such as `-T md2html.sh`, and `-p tool` that used
to be able to change the location of a `bin` tool.

Changed `bin/gen-authors.sh` VERSION from "1.11 2024-08-13"
to "1.12 2024-08-18".

Changed `bin/gen-location.sh` VERSION from "1.5 2024-08-17"
to "1.6 2024-08-18".

Changed `bin/readme2index.sh` VERSION from "1.2.7 2024-08-05"
to "1.3 2024-08-17".

Modified `bin/all-run.sh` to use the `bin` directory mechanism.
Modified `bin/all-years.sh` to use the `bin` directory mechanism.
Modified `bin/gen-other-html.sh` to use the `bin` directory mechanism.
Modified `bin/gen-year-index.sh` to use the `bin` directory mechanism.
Modified `bin/md2html.sh` to use the `bin` directory mechanism.
Modified `bin/quick-readme2index.sh` to use the `bin` directory mechanism.
Modified `bin/readme2index.sh` to use the `bin` directory mechanism.

Changed `bin/all-run.sh` VERSION from "1.3.6 2024-08-05"
to "1.4 2024-08-17".

Changed `bin/all-years.sh` VERSION from "1.0.5 2024-08-05"
to "1.1 2024-08-17".

Changed `bin/gen-other-html.sh` VERSION from "1.3 2024-08-11"
to "1.4 2024-08-17".

Changed `bin/gen-year-index.sh` VERSION from "1.1.2 2024-08-05"
to "1.2 2024-08-17".

Changed `bin/quick-readme2index.sh` VERSION from "1.1.7 2024-08-05"
to "1.2 2024-08-17".

Changed `bin/md2html.sh` VERSION from "1.5.5 2024-08-05"
to "1.6 2024-08-17".

Added some whitespace in the form of empty lines to tools.

Made checks for tools under `bin` directory more consistent.

When using `-Q` (quick mode) and the prerequisite files are newer,
we force the target to be touched so that a later run will not
have to build the target HTML file.

Performed `make quick_www` to test the above under macOS.

Performed `make www` to test the above under macOS.
This commit is contained in:
Landon Curt Noll committed 2024-08-18 02:10:25 -07:00
1 parent f159369a0a
commit 0e5864b8b0
39 files changed
+1694 -795

No files matched your search

+42 -15
View File
@@ -26,6 +26,7 @@
#
# Share and enjoy! :-)
# firewall - run only with a bash that is version 5.1.8 or later
#
# The "/usr/bin/env bash" command must result in using a bash that
@@ -82,6 +83,7 @@ shopt -u nocaseglob # disable strict case matching
shopt -u extglob # enable extended globbing patterns
shopt -s globstar # enable ** to match all files and zero or more directories and subdirectories
# set variables referenced in the usage message
#
export VERSION="1.3.14 2024-08-19"
@@ -194,6 +196,7 @@ function output_modtime
return 0
}
# set usage message
#
export USAGE="usage: $0 [-h] [-v level] [-V] [-d topdir] [-n] [-N]
@@ -228,12 +231,14 @@ Exit codes:
$NAME version: $VERSION"
# setup
#
export NOOP=
export DO_NOT_PROCESS=
export EXIT_CODE="0"
# parse command line
#
while getopts :hv:Vd:nNw:W flag; do
@@ -273,7 +278,7 @@ while getopts :hv:Vd:nNw:W flag; do
;;
esac
done
#
# parse the command line arguments
#
if [[ $V_FLAG -ge 3 ]]; then
@@ -289,7 +294,7 @@ if [[ $# -ne 0 ]]; then
echo "$0: ERROR: expected 0 args, found: $#" 1>&2
exit 3
fi
#
# verify that we have a topdir directory
#
@@ -311,6 +316,7 @@ if [[ ! -d $TOPDIR ]]; then
exit 6
fi
# cd to topdir
#
if [[ ! -e $TOPDIR ]]; then
@@ -334,6 +340,7 @@ if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: now in directory: $(/bin/pwd)" 1>&2
fi
# verify that we have an archive/historic subdirectory
#
export ARCHIVE_HISTORIC_PATH="$TOPDIR/archive/historic"
@@ -343,6 +350,7 @@ if [[ ! -d $ARCHIVE_HISTORIC_PATH ]]; then
fi
export ARCHIVE_HISTORIC_DIR="archive/historic"
# verify that we have an author subdirectory
#
export AUTHOR_PATH="$TOPDIR/author"
@@ -352,6 +360,7 @@ if [[ ! -d $AUTHOR_PATH ]]; then
fi
export AUTHOR_DIR="author"
# verify that we have a bin subdirectory
#
export BIN_PATH="$TOPDIR/bin"
@@ -361,18 +370,6 @@ if [[ ! -d $BIN_PATH ]]; then
fi
export BIN_DIR="bin"
# verify that we have an inc subdirectory
#
export INC_PATH="$TOPDIR/inc"
if [[ ! -d $INC_PATH ]]; then
echo "$0: ERROR: inc is not a directory under topdir: $INC_PATH" 1>&2
exit 6
fi
export INC_DIR="inc"
# determine the name of sitemap
#
export SITEMAP="sitemap.xml"
# verify we have our awk tool
#
@@ -394,6 +391,22 @@ if [[ ! -s $FILELIST_ENTRY_JSON_AWK ]]; then
exit 5
fi
# verify that we have an inc subdirectory
#
export INC_PATH="$TOPDIR/inc"
if [[ ! -d $INC_PATH ]]; then
echo "$0: ERROR: inc is not a directory under topdir: $INC_PATH" 1>&2
exit 6
fi
export INC_DIR="inc"
# determine the name of sitemap
#
export SITEMAP="sitemap.xml"
# verify we have a non-empty readable .top file
#
export TOP_FILE=".top"
@@ -414,6 +427,7 @@ if [[ ! -s $TOP_FILE ]]; then
exit 6
fi
# determine how we can determine the file modification time in W3C Datetime format:
#
# https://www.w3.org/TR/NOTE-datetime
@@ -471,6 +485,7 @@ else
fi
fi
# parameter debugging
#
if [[ $V_FLAG -ge 3 ]]; then
@@ -498,12 +513,13 @@ if [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2
echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2
echo "$0: debug[3]: INC_PATH=$INC_PATH" 1>&2
echo "$0: debug[3]: FILELIST_ENTRY_JSON_AWK=$FILELIST_ENTRY_JSON_AWK" 1>&2
echo "$0: debug[3]: INC_DIR=$INC_DIR" 1>&2
echo "$0: debug[3]: SITEMAP=$SITEMAP" 1>&2
echo "$0: debug[3]: FILELIST_ENTRY_JSON_AWK=$FILELIST_ENTRY_JSON_AWK" 1>&2
echo "$0: debug[3]: TOP_FILE=$TOP_FILE" 1>&2
fi
# If -N, time to exit
#
if [[ -n $DO_NOT_PROCESS ]]; then
@@ -513,6 +529,7 @@ if [[ -n $DO_NOT_PROCESS ]]; then
exit 0
fi
# create a temporary file manifest list
#
export TMP_MANIFEST_LIST=".tmp.$NAME.MANIFEST_LIST.$$.tmp"
@@ -531,6 +548,7 @@ if [[ ! -e $TMP_MANIFEST_LIST ]]; then
exit 11
fi
# create a temporary exit code
#
# It is a pain to set the EXIT_CODE deep inside a loop, so we write the EXIT_CODE into a file
@@ -552,6 +570,7 @@ if [[ ! -e $TMP_EXIT_CODE ]]; then
exit 15
fi
# create a temporary sitemap
#
export TMP_SITEMAP=".tmp.$NAME.SITEMAP.$$.tmp"
@@ -570,6 +589,7 @@ if [[ ! -e $TMP_SITEMAP ]]; then
exit 17
fi
# add top level files to the file manifest list
#
# We do not (yet?) include these files:
@@ -611,10 +631,12 @@ winners.html
years.html
EOF0
# add files from selected sub-directories
#
find "$ARCHIVE_HISTORIC_DIR" "$AUTHOR_DIR" "$BIN_DIR" "$INC_DIR" -type f -print >> "$TMP_MANIFEST_LIST"
# generate sorted list of entry files from the full IOCCC manifest
#
# We also include the YYYY/.filelist contents.
@@ -796,6 +818,7 @@ if [[ $EXIT_CODE -ne 0 ]]; then
exit "$EXIT_CODE"
fi
# sort the manifest list
#
LC_ALL=C sort -d "$TMP_MANIFEST_LIST" -o "$TMP_MANIFEST_LIST"
@@ -805,6 +828,7 @@ if [[ $status -ne 0 ]]; then
exit 1
fi
# verify that the manifest list contains only readable files
#
for FILE in $(< "$TMP_MANIFEST_LIST"); do
@@ -844,6 +868,7 @@ if [[ $EXIT_CODE -ne 0 ]]; then
exit "$EXIT_CODE"
fi
# form the sitemap
#
if [[ -z $NOOP ]]; then
@@ -897,6 +922,7 @@ if [[ -z $EXIT_CODE ]]; then
exit 19
fi
# move the sitemap in place only if different
#
if [[ -z $NOOP ]]; then
@@ -938,6 +964,7 @@ elif [[ $V_FLAG -ge 3 ]]; then
echo "$0: debug[3]: because of -n, temporary file manifest list was not formed: $TMP_MANIFEST_LIST" 1>&2
fi
# All Done!!! All Done!!! -- Jessica Noll, Age 2
#
if [[ -z $NOOP ]]; then