From f1f0993cf9058ae4e995ffc9578647cbb91a6935 Mon Sep 17 00:00:00 2001 From: Landon Curt Noll Date: Sun, 18 May 2025 02:28:16 -0700 Subject: [PATCH] complete bin/cvt-submission.sh Successfully tested `bin/cvt-submission.sh` on a new entry in a new year that was generated from a submission entry.number directory via `sbin/post-collect.sh` from the submit tools. Changed `bin/cvt-submission.sh` prompts to use "[Y,n]" and to default to yes. The `bin/cvt-submission.sh` processes and appends YYYY/dir to `.allyear`. Improved 215 error message and exit code from `bin/subst.entry-navbar.awk`. Changed `bin/cvt-submission.sh` VERSION from "2.0.3 2025-05-18" to "2.0.4 2025-05-18". Changed `bin/output-index-author.sh` VERSION from "2.0.0 2025-03-13" to "2.0.1 2025-05-18". Changed `bin/output-index-inventory.sh` VERSION from "2.0.0 2025-03-13" to "2.0.1 2025-05-18". Changed `bin/output-index-inventory.sh` VERSION from "2.0.1 2025-05-17" to "2.0.2 2025-05-18". Changed `bin/subst.entry-index.sh` VERSION from "2.0.1 2025-05-17" to "2.0.2 2025-05-18". Changed `bin/subst.entry-navbar.awk` VERSION from "1.3.1 2025-05-17" to "1.3.2 2025-05-18". Update sitemap. Tested the above via `make update` on macOS. --- bin/cvt-submission.sh | 195 +++++++++++++++++++++++++--------- bin/output-index-author.sh | 6 +- bin/output-index-inventory.sh | 6 +- bin/subst.entry-index.sh | 4 +- bin/subst.entry-navbar.awk | 10 +- sitemap.xml | 14 +-- 6 files changed, 169 insertions(+), 66 deletions(-) diff --git a/bin/cvt-submission.sh b/bin/cvt-submission.sh index 7e0fdae1c..abe4cfc73 100755 --- a/bin/cvt-submission.sh +++ b/bin/cvt-submission.sh @@ -124,7 +124,7 @@ export LC_ALL="C" # set variables referenced in the usage message # -export VERSION="2.0.2 2025-05-17" +export VERSION="2.0.4 2025-05-18" NAME=$(basename "$0") export NAME export V_FLAG=0 @@ -328,9 +328,9 @@ function prompt_string echo echo "Verify decoded $ITEM_NAME: $DECODED" 1>&2 echo - echo -n 'Is that correct? [y,N]: ' + echo -n 'Is that correct? [Y,n]: ' read -r Y_OR_N - if [[ $Y_OR_N == y || $Y_OR_N == Y || $Y_OR_N == yes || $Y_OR_N == YES || $Y_OR_N == Yes ]]; then + if [[ -z $Y_OR_N || $Y_OR_N == y || $Y_OR_N == Y || $Y_OR_N == yes || $Y_OR_N == YES || $Y_OR_N == Yes ]]; then break fi echo @@ -419,9 +419,9 @@ function prompt_integer echo echo "Verify decoded $ITEM_NAME: $DECODED" 1>&2 echo - echo -n 'Is that correct? [y,N]: ' + echo -n 'Is that correct? [Y,n]: ' read -r Y_OR_N - if [[ $Y_OR_N == y || $Y_OR_N == Y || $Y_OR_N == yes || $Y_OR_N == YES || $Y_OR_N == Yes ]]; then + if [[ -z $Y_OR_N || $Y_OR_N == y || $Y_OR_N == Y || $Y_OR_N == yes || $Y_OR_N == YES || $Y_OR_N == Yes ]]; then break fi echo @@ -901,6 +901,7 @@ if [[ ! -d $BIN_PATH ]]; then fi export BIN_DIR="bin" + # cd to topdir # if [[ ! -e $TOPDIR ]]; then @@ -946,6 +947,27 @@ if [[ ! -s $TOP_FILE ]]; then fi +# verify we have a non-empty readable .allyear file +# +export ALLYEAR=".allyear" +if [[ ! -e $ALLYEAR ]]; then + echo "$0: ERROR: .allyear does not exist: $ALLYEAR" 1>&2 + exit 6 +fi +if [[ ! -f $ALLYEAR ]]; then + echo "$0: ERROR: .allyear is not a regular file: $ALLYEAR" 1>&2 + exit 6 +fi +if [[ ! -r $ALLYEAR ]]; then + echo "$0: ERROR: .allyear is not a readable file: $ALLYEAR" 1>&2 + exit 6 +fi +if [[ ! -s $ALLYEAR ]]; then + echo "$0: ERROR: .allyear is not a non-empty writable file: $ALLYEAR" 1>&2 + exit 6 +fi + + # verify that the bin/md2html.sh tool is executable # export MD2HTML_SH="$BIN_DIR/md2html.sh" @@ -1053,6 +1075,7 @@ export TAR_BZ2="$YYYY_DIR/$ENTRY_ID.tar.bz2" export ENTRY_JSON="$YYYY_DIR/.entry.json" export DOT_GITIGNORE="$YYYY_DIR/.gitignore" export TRY_SH="$YYYY_DIR/try.sh" +export TRY_ALT_SH="$YYYY_DIR/try.alt.sh" export DOT_PATH="$YYYY_DIR/.path" export README_MD="$YYYY_DIR/README.md" export INDEX_HTML="$YYYY_DIR/index.html" @@ -1120,6 +1143,7 @@ if [[ $V_FLAG -ge 3 ]]; then echo "$0: debug[3]: REPO_NAME=$REPO_NAME" 1>&2 echo "$0: debug[3]: CD_FAILED=$CD_FAILED" 1>&2 echo "$0: debug[3]: TOP_FILE=$TOP_FILE" 1>&2 + echo "$0: debug[3]: ALLYEAR=$ALLYEAR" 1>&2 echo "$0: debug[3]: BIN_PATH=$BIN_PATH" 1>&2 echo "$0: debug[3]: BIN_DIR=$BIN_DIR" 1>&2 echo "$0: debug[3]: MD2HTML_SH=$MD2HTML_SH" 1>&2 @@ -1137,6 +1161,8 @@ if [[ $V_FLAG -ge 3 ]]; then echo "$0: debug[3]: TAR_BZ2=$TAR_BZ2" 1>&2 echo "$0: debug[3]: ENTRY_JSON=$ENTRY_JSON" 1>&2 echo "$0: debug[3]: DOT_GITIGNORE=$DOT_GITIGNORE" 1>&2 + echo "$0: debug[3]: TRY_SH=$TRY_SH" 1>&2 + echo "$0: debug[3]: TRY_ALT_SH=$TRY_ALT_SH" 1>&2 echo "$0: debug[3]: DOT_PATH=$DOT_PATH" 1>&2 echo "$0: debug[3]: README_MD=$README_MD" 1>&2 echo "$0: debug[3]: INDEX_HTML=$INDEX_HTML" 1>&2 @@ -1183,6 +1209,7 @@ if [[ ! -f $TEMPLATE_TRY_SH ]]; then exit 6 fi + # firewall - verify chkentry tool # if [[ ! -e $CHKENTRY_TOOL ]]; then @@ -2045,6 +2072,43 @@ if [[ -z $NOOP ]]; then exit 51 fi + # if try.sh does not exist, copy example over, otherwise just update the manifest + # + if [[ ! -f $TRY_SH ]]; then + if [[ $V_FLAG -ge 3 ]]; then + echo "$0: debug[3]: about to run: cp -f -p -v $TEMPLATE_TRY_SH $TRY_SH" 1>&2 + cp -f -p -v "$TEMPLATE_TRY_SH" "$TRY_SH" + status="$?" + if [[ $status -ne 0 ]]; then + echo "$0: ERROR: cp -f -p -v $TEMPLATE_TRY_SH $TRY_SH failed," \ + "error code: $status" 1>&2 + exit 52 + fi + else + cp -f -p "$TEMPLATE_TRY_SH" "$TRY_SH" + status="$?" + if [[ $status -ne 0 ]]; then + echo "$0: ERROR: cp -f -p $TEMPLATE_TRY_SH $TRY_SH failed," \ + "error code: $status" 1>&2 + exit 53 + fi + fi + fi + + # write manifest csv line for try.sh + # + ((++count)) + manifest_csv try.sh 100 true shellscript true "script to try entry" \ + >> "$TMP_MANIFEST_CSV" + + # write manifest csv line for try.alt.sh if it exists + # + if [[ -f $TRY_ALT_SH ]]; then + ((++count)) + manifest_csv try.alt.sh 100 true shellscript true "script to try alternate code" \ + >> "$TMP_MANIFEST_CSV" + fi + # perform some validation checks on the extra_file set # for EXTRA_FILE in $EXTRA_FILE_SET; do @@ -2054,7 +2118,7 @@ if [[ -z $NOOP ]]; then case "$EXTRA_FILE" in prog.c|Makefile|prog.orig.c|index.html|README.md|remarks.md|\.*) echo "$0: ERROR: invalid extra_file filename: $EXTRA_FILE" 1>&2 - exit 52 + exit 54 ;; *) ;; esac @@ -2063,11 +2127,11 @@ if [[ -z $NOOP ]]; then # if [[ ! -e $YYYY_DIR/$EXTRA_FILE ]]; then echo "$0: ERROR: manifest file for extra_file does not exist: $YYYY_DIR/$EXTRA_FILE" 1>&2 - exit 53 + exit 55 fi if [[ ! -f $YYYY_DIR/$EXTRA_FILE ]]; then echo "$0: ERROR: manifest file for extra_file is not a file: $YYYY_DIR/$EXTRA_FILE" 1>&2 - exit 54 + exit 56 fi done @@ -2150,6 +2214,10 @@ if [[ -z $NOOP ]]; then # process extra_files that are neither markdown nor HTML # + export BASENAME_TRY_SH + BASENAME_TRY_SH=$(basename "$TRY_SH") + export BASENAME_TRY_ALT_SH + BASENAME_TRY_ALT_SH=$(basename "$TRY_ALT_SH") for EXTRA_FILE in $EXTRA_FILE_SET; do # ignore HTML files because we processed them above @@ -2158,6 +2226,24 @@ if [[ -z $NOOP ]]; then continue fi + # ignore prog.alt.c because we processed it above + # + if [[ $EXTRA_FILE == "$ALT_C" ]]; then + continue + fi + + # ignore try.sh because we processed it above + # + if [[ $EXTRA_FILE == "$BASENAME_TRY_SH" ]]; then + continue + fi + + # ignore try.alt.sh because we processed it above + # + if [[ $EXTRA_FILE == "$BASENAME_TRY_ALT_SH" ]]; then + continue + fi + # prompt for inventory_order # VALUE= @@ -2220,7 +2306,7 @@ if [[ -z $NOOP ]]; then if [[ $status -ne 0 ]]; then echo "$0: ERROR: cp -f -p -v $TEMPLATE_GITIGNORE $DOT_GITIGNORE failed," \ "error code: $status" 1>&2 - exit 55 + exit 57 fi else cp -f -p "$TEMPLATE_GITIGNORE" "$DOT_GITIGNORE" @@ -2228,7 +2314,7 @@ if [[ -z $NOOP ]]; then if [[ $status -ne 0 ]]; then echo "$0: ERROR: cp -f -p $TEMPLATE_GITIGNORE $DOT_GITIGNORE failed," \ "error code: $status" 1>&2 - exit 56 + exit 58 fi fi fi @@ -2239,37 +2325,6 @@ if [[ -z $NOOP ]]; then manifest_csv .gitignore 4000000000 true gitignore true "list of files that should not be committed under git" \ >> "$TMP_MANIFEST_CSV" - # if try.sh does not exist, copy example over, otherwise just update - # manifest - # - if [[ ! -f $TRY_SH ]]; then - if [[ $V_FLAG -ge 3 ]]; then - echo "$0: debug[3]: about to run: cp -f -p -v $TEMPLATE_TRY_SH $TRY_SH" 1>&2 - cp -f -p -v "$TEMPLATE_TRY_SH" "$TRY_SH" - status="$?" - if [[ $status -ne 0 ]]; then - echo "$0: ERROR: cp -f -p -v $TEMPLATE_TRY_SH $TRY_SH failed," \ - "error code: $status" 1>&2 - exit 55 - fi - else - cp -f -p "$TEMPLATE_TRY_SH" "$TRY_SH" - status="$?" - if [[ $status -ne 0 ]]; then - echo "$0: ERROR: cp -f -p $TEMPLATE_TRY_SH $TRY_SH failed," \ - "error code: $status" 1>&2 - exit 56 - fi - fi - fi - - # write manifest csv line for try.sh - # - ((++count)) - manifest_csv try.sh 100 true shellscript true "script to try entry" \ - >> "$TMP_MANIFEST_CSV" - - # form .path if needed # if [[ ! -f $DOT_PATH ]]; then @@ -2319,7 +2374,7 @@ if [[ -z $NOOP ]]; then if [[ $status -ne 0 ]]; then echo "$0: ERROR: LC_ALL=C sort -t, -k2n -k1,1 -k3,6 $TMP_MANIFEST_CSV -o $TMP_MANIFEST_CSV failed," \ "error code: $status" 1>&2 - exit 57 + exit 59 elif [[ $V_FLAG -ge 3 ]]; then echo "$0: debug[3]: sorted temporary manifest csv file: $TMP_MANIFEST_CSV" 1>&2 fi @@ -2362,7 +2417,7 @@ if [[ -z $NOOP ]]; then if [[ $status -ne 0 ]]; then echo "$0: ERROR: $JPARSE_TOOL -q -- $TMP_ENTRY_JSON filed," \ "error code: $status" 1>&2 - exit 58 + exit 60 elif [[ $V_FLAG -ge 3 ]]; then echo "$0: debug[3]: valid JSON: $TMP_ENTRY_JSON" 1>&2 fi @@ -2394,13 +2449,13 @@ if [[ -z $NOOP ]]; then if [[ $status -ne 0 ]]; then echo "$0: ERROR: mv -f -- $TMP_ENTRY_JSON $ENTRY_JSON filed," \ "error code: $status" 1>&2 - exit 59 + exit 61 elif [[ $V_FLAG -ge 1 ]]; then echo "$0: debug[1]: updated .entry.json: $ENTRY_JSON" 1>&2 fi if [[ ! -s $ENTRY_JSON ]]; then echo "$0: ERROR: not a non-empty .entry.json: $ENTRY_JSON" 1>&2 - exit 60 + exit 62 fi fi @@ -2434,7 +2489,7 @@ for EXTRA_FILE in $EXTRA_FILE_SET; do if [[ $status -ne 0 ]]; then echo "$0: ERROR: $OTHERMD2HTML_SH -v $V_FLAG -- $YYYY_DIR/$EXTRA_FILE filed," \ "error code: $status" 1>&2 - exit 61 + exit 63 fi elif [[ $V_FLAG -ge 3 ]]; then echo "$0: debug[3]: -n disabled forming HTML: $YYYY_DIR/$HTML_FILE" 1>&2 @@ -2449,6 +2504,50 @@ for EXTRA_FILE in $EXTRA_FILE_SET; do done +# verify that YYYY_DIR is in .allyear +# +# We need to be sure that YYYY_DIR is in .allyear as tools such as bin/subst.entry-navbar.awk +# use the contents of that file to generate the navigation bar in the index.html web page. +# +grep -q "^$YYYY_DIR$" "$ALLYEAR" >/dev/null 2>&1 +status="$?" +if [[ $status -ne 0 ]]; then + + if [[ -z $NOOP ]]; then + + # make .allyear writable + # + chmod +w "$ALLYEAR" + status="$?" + if [[ $status -ne 0 ]]; then + echo "$0: ERROR: chmod +w $ALLYEAR filed," \ + "error code: $status" 1>&2 + exit 64 + fi + + # append YYYY_DIR to .allyear + # + echo "$YYYY_DIR" >> "$ALLYEAR" + + # sort .allyear + # + sort -f -d -u "$ALLYEAR" -o "$ALLYEAR" + status="$?" + if [[ $status -ne 0 ]]; then + echo "$0: ERROR: sort -f -d -u $ALLYEAR -o $ALLYEAR filed," \ + "error code: $status" 1>&2 + exit 65 + fi + + elif [[ $V_FLAG -ge 1 ]]; then + echo "$0: debug[3]: -n disabled adding YYYY_DIR: $YYYY_DIR to .allyear: $ALLYEAR" 1>&2 + fi + +elif [[ $V_FLAG -ge 3 ]]; then + echo "$0: debug[3]: YYYY_DIR: $YYYY_DIR is already in .allyear: $ALLYEAR" 1>&2 +fi + + # form index.html if needed # if [[ -z $NOOP ]]; then @@ -2462,7 +2561,7 @@ if [[ -z $NOOP ]]; then if [[ $status -ne 0 ]]; then echo "$0: ERROR: $MD2HTML_SH -v $V_FLAG -- $README_MD $INDEX_HTML filed," \ "error code: $status" 1>&2 - exit 62 + exit 66 fi fi @@ -2486,7 +2585,7 @@ if [[ $status -ne 0 ]]; then echo "$0: ERROR: rm -f -v -- $INFO_JSON $AUTH_JSON $AUTH_JSON.xz $REMARKS_MD $YYYY_DIR/.prev" \ "$YYYY_DIR/.submit.sh $YYYY_DIR/.txz $YYYY_DIR/.num.sh $YYYY_DIR/.orig filed," \ "error code: $status" 1>&2 - exit 63 + exit 65 fi diff --git a/bin/output-index-author.sh b/bin/output-index-author.sh index 1965518b8..ba825d300 100755 --- a/bin/output-index-author.sh +++ b/bin/output-index-author.sh @@ -122,7 +122,7 @@ export LC_ALL="C" # set variables referenced in the usage message # -export VERSION="2.0.0 2025-03-13" +export VERSION="2.0.1 2025-05-18" NAME=$(basename "$0") export NAME export V_FLAG=0 @@ -640,8 +640,8 @@ if [[ ! -d $YEAR_DIR ]]; then fi export ENTRY_ID="${YEAR_DIR}_${ENTRY_DIR}" export DOT_YEAR="$YEAR_DIR/.year" -if [[ ! -s $DOT_YEAR ]]; then - echo "$0: ERROR: not a non-empty file: $DOT_YEAR" 1>&2 +if [[ ! -f $DOT_YEAR ]]; then + echo "$0: ERROR: not a file: $DOT_YEAR" 1>&2 exit 6 fi # Now that we have moved to topdir, form and verify YYYY_DIR is a writable directory diff --git a/bin/output-index-inventory.sh b/bin/output-index-inventory.sh index f43902c0f..b4b15a380 100755 --- a/bin/output-index-inventory.sh +++ b/bin/output-index-inventory.sh @@ -134,7 +134,7 @@ export LC_ALL="C" # set variables referenced in the usage message # -export VERSION="2.0.0 2025-03-13" +export VERSION="2.0.1 2025-05-18" NAME=$(basename "$0") export NAME export V_FLAG=0 @@ -417,8 +417,8 @@ if [[ ! -d $YEAR_DIR ]]; then fi export ENTRY_ID="${YEAR_DIR}_${ENTRY_DIR}" export DOT_YEAR="$YEAR_DIR/.year" -if [[ ! -s $DOT_YEAR ]]; then - echo "$0: ERROR: not a non-empty file: $DOT_YEAR" 1>&2 +if [[ ! -f $DOT_YEAR ]]; then + echo "$0: ERROR: not a file: $DOT_YEAR" 1>&2 exit 6 fi # Now that we have moved to topdir, form and verify YYYY_DIR is a writable directory diff --git a/bin/subst.entry-index.sh b/bin/subst.entry-index.sh index 0be259471..1ac14f6c2 100755 --- a/bin/subst.entry-index.sh +++ b/bin/subst.entry-index.sh @@ -136,7 +136,7 @@ export LC_ALL="C" # set variables referenced in the usage message # -export VERSION="2.0.1 2025-05-17" +export VERSION="2.0.2 2025-05-18" NAME=$(basename "$0") export NAME export V_FLAG=0 @@ -735,7 +735,7 @@ echo "HEADER_3=$ABSTRACT" awk -v entry_path="$YYYY_DIR" -f "$ENTRY_NAVBAR_AWK" "$DOT_ALLYEAR" status="$?" if [[ $status -ne 0 ]]; then - echo "$0: ERROR: subst.entry-navbar.awk failed, error: $status" 1>&2 + echo "$0: ERROR: awk -v entry_path=$YYYY_DIR -f $ENTRY_NAVBAR_AWK $DOT_ALLYEAR failed, error: $status" 1>&2 exit 1 fi diff --git a/bin/subst.entry-navbar.awk b/bin/subst.entry-navbar.awk index f8e212eea..09783909d 100755 --- a/bin/subst.entry-navbar.awk +++ b/bin/subst.entry-navbar.awk @@ -13,6 +13,10 @@ # # awk -v entry_path=YYYY/dir -f bin/subst.entry-navbar.awk YYYY/.year # +# usage: +# +# awk -v entry_path=YYYY/dir -f bin/subst.entry-navbar.awk .allyear +# # where: # # YYYY IOCCC year or mock @@ -22,7 +26,7 @@ BEGIN { # setup # - VERSION="1.3.1 2025-05-17" + VERSION="1.3.2 2025-05-18" NAME = "subst.entry-navbar.awk" process_next_line = 0; # 1 ==> we found our entry_path, now process the next line found_entry_path = 0; # 1 ==> we found our entry_path @@ -179,10 +183,10 @@ END { if (!found_entry_path) { # ERROR: entry_path was not found print "-e"; - print "'" NAME ": did not find:", entry_path "'"; + print "'" NAME ": did not find in:", ARGV[1], "entry_path:", entry_path "'"; print "-E"; print "215"; - exit + exit 215; } else if (process_next_line) { # no next line entry_path is the last line diff --git a/sitemap.xml b/sitemap.xml index c528f3df8..bc23ffd27 100644 --- a/sitemap.xml +++ b/sitemap.xml @@ -15226,7 +15226,7 @@ https://www.ioccc.org/bin/cvt-submission.sh - 2025-05-18T06:47:21+00:00 + 2025-05-18T08:57:00+00:00 https://www.ioccc.org/bin/entry2csv.sh @@ -15334,11 +15334,11 @@ https://www.ioccc.org/bin/output-index-author.sh - 2025-04-16T20:59:19+00:00 + 2025-05-18T08:48:13+00:00 https://www.ioccc.org/bin/output-index-inventory.sh - 2025-04-16T20:59:19+00:00 + 2025-05-18T08:48:44+00:00 https://www.ioccc.org/bin/output-year-index.sh @@ -15382,11 +15382,11 @@ https://www.ioccc.org/bin/subst.entry-index.sh - 2025-05-18T06:53:55+00:00 + 2025-05-18T09:01:17+00:00 https://www.ioccc.org/bin/subst.entry-navbar.awk - 2025-05-18T05:47:19+00:00 + 2025-05-18T09:01:24+00:00 https://www.ioccc.org/bin/subst.year-index.sh @@ -15486,7 +15486,7 @@ https://www.ioccc.org/Makefile - 2025-05-18T06:31:07+00:00 + 2025-05-18T08:54:49+00:00 https://www.ioccc.org/markdown.html @@ -15598,7 +15598,7 @@ https://www.ioccc.org/status.html - 2025-05-18T06:51:52+00:00 + 2025-05-18T09:22:37+00:00 https://www.ioccc.org/status.json