diff options
Diffstat (limited to 'aux')
-rwxr-xr-x | aux/workflow/assert-changelog.sh | 3 | ||||
-rwxr-xr-x | aux/workflow/assert-readme.sh | 3 | ||||
-rwxr-xr-x | aux/workflow/l10n.sh | 44 | ||||
-rwxr-xr-x | aux/workflow/manpages.sh | 114 |
4 files changed, 109 insertions, 55 deletions
diff --git a/aux/workflow/assert-changelog.sh b/aux/workflow/assert-changelog.sh index 61cd916..e2cd926 100755 --- a/aux/workflow/assert-changelog.sh +++ b/aux/workflow/assert-changelog.sh @@ -33,8 +33,7 @@ for VVERSION in $(git tag); do done # "$@" represents a list of tags to be also included in the verification. -# shellcheck disable=2068 -for VVERSION in $@; do +for VVERSION in "$@"; do DATE="$(date '+%Y-%m-%d')" assert "$DATE" "$VVERSION" done diff --git a/aux/workflow/assert-readme.sh b/aux/workflow/assert-readme.sh index e256fcf..8fcf188 100755 --- a/aux/workflow/assert-readme.sh +++ b/aux/workflow/assert-readme.sh @@ -50,8 +50,7 @@ for VVERSION in $(git tag); do done # "$@" represents a list of tags to be also included in the verification. -# shellcheck disable=2068 -for VVERSION in $@; do +for VVERSION in "$@"; do if ! git tag | grep -qF "$VVERSION"; then DATE="$(date '+%Y-%m-%d')" add_release "$DATE" "$VVERSION" diff --git a/aux/workflow/l10n.sh b/aux/workflow/l10n.sh new file mode 100755 index 0000000..81a7d02 --- /dev/null +++ b/aux/workflow/l10n.sh @@ -0,0 +1,44 @@ +#!/bin/sh +set -eu + +LANGS= +while getopts 'l:' flag; do + case "$flag" in + l) + LANGS="$OPTARG" + ;; + *) + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) +if [ -z "$LANGS" ]; then + echo "Missing LANG" >&2 + exit 2 +fi + +for f in $(find $@ -not -name '*.en.*'); do + case "$f" in + *.en.[1-9].in) + manpage "$f" + ;; + *) + echo "Unsupported file format: $f" >&2 + exit 2 + ;; + esac +done + +manpage() { + from_f="$1" + for l in $LANGS; do + to_f="$(echo "$from_f" | sed "s/\.en\./.$l./")" + po4a-updatepo -f man -m "$from_f" -p "po/$l.po" + OUT="$(po4a-translate -f man -m "$from_f" -p "po/$l.po" -l "$to_f" -k 0 -v 2>&1)" + echo "$OUT" >&2 + if ! echo "$OUT" | grep -qF ' is 100% translated ('; then + printf '\n\tWARNING!\n Missing translations for %s\n\n' "$to_f" >&2 + fi + done +} diff --git a/aux/workflow/manpages.sh b/aux/workflow/manpages.sh index fd88d95..7332d8f 100755 --- a/aux/workflow/manpages.sh +++ b/aux/workflow/manpages.sh @@ -1,55 +1,67 @@ #!/bin/sh set -eu -LANGS="$1" -OP="$2" -PREFIX="${3:-}" +while getopts 'iuHo:p:' flag; do + case "$flag" in + i) + ACTION=install + ;; + u) + ACTION=uninstall + ;; + H) + ACTION=html + ;; + o) + OUTDIR="$OPTARG" + ;; + p) + MANPREFIX="$OPTARG" + ;; + *) + exit 2 + ;; + esac +done +shift $((OPTIND - 1)) -if [ "$OP" = '--update' ]; then - for f in doc/*.en.[1-9]; do - for lang in $LANGS; do - to="$(echo "$f" | sed "s|\.en\.|.$lang.|")" - po4a-updatepo -f man -m "$f" -p "po/$lang.po" - printf 'Translating %s...\n' "$to" >&2 - OUT="$(po4a-translate -f man -m "$f" -p "po/$lang.po" -l "$to" -k 0 -v 2>&1)" - echo "$OUT" >&2 - if ! echo "$OUT" | grep -qF ' is 100% translated ('; then - printf "\n WARNING!\n Missing translations for %s\n\n" "$to" >&2 - fi - done - done -else - shift 4 ||: # remove up to '--' - for f in doc/*.en.[1-9]; do - n="${f##*.}" - fileto_name="$(basename "${f%.en.$n}").$n" - for lang in $LANGS en; do - filefrom_name="${f%.en.$n}.$lang.$n" - mandir_name="$PREFIX/$lang/man$n" - htmldir_name="public/$lang/" - case "$OP" in - --install) - mkdir -p "$mandir_name" - # shellcheck disable=2068 - $@ < "$filefrom_name" > "$mandir_name/$fileto_name" - mkdir -p "$PREFIX/man$n" - ln -fs "../en/man$n/$fileto_name" "$PREFIX/man$n/$fileto_name" - ;; - --uninstall) - rm -f \ - "$PREFIX/$lang/man$n/$fileto_name" \ - "$PREFIX/man$n/$fileto_name" - ;; - --html) - mkdir -p "$htmldir_name" - # shellcheck disable=2068 - $@ < "$filefrom_name" | pandoc -s -r man -w html > "public/$lang/$fileto_name.html" - ;; - *) - echo "Unsupported operation: $OP" - exit 2 - ;; - esac - done - done -fi +assert() { + if [ -z "$1" ]; then + echo "Missing $2 argument" >&2 + exit 2 + fi +} + +assert "${ACTION:-}" ACTION + +for f in "$@"; do + l="$(echo "$f" | awk -F. '{print $(NF-1)}')" + n="$(echo "$f" | awk -F. '{print $NF}')" + en="$(echo "$f" | sed "s/\.$l\./.en./")" + case "$ACTION" in + html) + assert "${OUTDIR:-}" OUTDIR + to_name="$(basename "${f%.$l.$n}.html")" + mkdir -p "$OUTDIR/$l" + pandoc -s -r man -w html --metadata "lang=$l" < "$f" > "$OUTDIR/$l/$to_name" + ;; + install) + assert "${MANPREFIX:-}" MANPREFIX + to_name="$(basename "${f%.$l.$n}.$n")" + mkdir -p "$MANPREFIX/$l/man$n" "$MANPREFIX/man$n" + cp "$f" "$MANPREFIX/$l/man$n/$to_name" + ln -fs "../en/man$n/$to_name" "$MANPREFIX/man$n/$to_name" + ;; + uninstall) + assert "${MANPREFIX:-}" MANPREFIX + to_name="$(basename "${f%.$l.$n}.$n")" + rm -f \ + "$MANPREFIX/$l/man$n/$to_name" \ + "$MANPREFIX/man$n/$to_name" + ;; + *) + echo "Bad ACTION: $ACTION" + exit 1 + ;; + esac +done |