From: Karel Zak Date: Wed, 22 Jan 2025 15:03:50 +0000 (+0100) Subject: po-man: improve translation and install scripts X-Git-Tag: v2.42-start~47^2~8 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=86be21cfc9b2680b2751a43084454cb037673141;p=thirdparty%2Futil-linux.git po-man: improve translation and install scripts install-translations.sh: * add uninstall mode * add --install and --uninstall options * remove $DESTDIR, it has to be used in --mandir argument translate.sh: * add --progress to print info * print info about missing man pages translation settings Signed-off-by: Karel Zak --- diff --git a/po-man/install-translations.sh b/po-man/install-translations.sh index 9969d0e00..aa31ca0b0 100755 --- a/po-man/install-translations.sh +++ b/po-man/install-translations.sh @@ -6,7 +6,7 @@ function usage() cat << HEREDOC Usage: - $PROGRAM --mandir --mansrcdir [...] + $PROGRAM --install|--uninstall --mandir --mansrcdir [...] Install translated man pages. @@ -17,14 +17,14 @@ Install translated man pages. Environment Variables: MESON_INSTALL_PREFIX install destination prefix directory - DESTDIR install destination directory HEREDOC } -DESTDIR="${DESTDIR:-''}" +MESON_INSTALL_PREFIX="${MESON_INSTALL_PREFIX:-''}" MANPAGES=() PROGRAM=$(basename "$0") +MYCMD="install" while [[ $# -gt 0 ]]; do case $1 in @@ -42,6 +42,14 @@ while [[ $# -gt 0 ]]; do shift shift ;; + --install) + MYCMD="install" + shift + ;; + --uninstall) + MYCMD="uninstall" + shift + ;; --*|-*) echo "Unknown option $1" usage @@ -68,10 +76,16 @@ for LOCALEDIR in "$MANSRCDIR"/*/; do SECTION="${MANPAGE##*.}" PAGE="$LOCALEDIR/man$SECTION/$MANPAGE" if [ -f "$PAGE" ]; then - if [ -z ${MESON_INSTALL_QUIET+x} ]; then - echo "Installing $PAGE to $DESTDIR/$MESON_INSTALL_PREFIX/$MANDIR/$LOCALE/man$SECTION" - fi - install -D --mode=0644 --target-directory="$DESTDIR/$MESON_INSTALL_PREFIX/$MANDIR/$LOCALE/man$SECTION" "$PAGE" + + if [ "$MYCMD" = "install" ]; then + if [ -z ${MESON_INSTALL_QUIET+x} ]; then + echo "Installing $PAGE to $MESON_INSTALL_PREFIX/$MANDIR/$LOCALE/man$SECTION" + fi + install -D --mode=0644 --target-directory="$DESTDIR/$MESON_INSTALL_PREFIX/$MANDIR/$LOCALE/man$SECTION" "$PAGE" + + elif [ "$MYCMD" = "uninstall" ]; then + rm -f "$DESTDIR/$MESON_INSTALL_PREFIX/$MANDIR/$LOCALE/man$SECTION/$PAGE" + fi fi done done diff --git a/po-man/translate.sh b/po-man/translate.sh index 16cece5fb..426e6bfb2 100755 --- a/po-man/translate.sh +++ b/po-man/translate.sh @@ -11,6 +11,7 @@ Translate Asciidoc man page source files and generate man pages. Options: --help show this help message and exit + --progress report the current progress --srcdir directory containing the asciidoc files to translate --destdir directory in which to place the translated asciidoc files and man pages --asciidoctor-load-path value for the --load-path option passed to the Asciidoctor command @@ -22,6 +23,7 @@ HEREDOC } PROGRAM=$(basename "$0") +PROGRESS=false while [[ $# -gt 0 ]]; do case $1 in @@ -54,6 +56,10 @@ while [[ $# -gt 0 ]]; do shift shift ;; + --progress) + PROGRESS=true + shift + ;; --util-linux-version) UTIL_LINUX_VERSION="$2" shift @@ -84,7 +90,8 @@ MANADOCS=() PO4A_TRANSLATE_ONLY_FLAGS=() for LOCALE in "${LOCALES[@]}"; do for ADOC in "${ADOCS[@]}"; do - if [[ ! " ${PO4ACFG_TRANSLATIONS[*]} " =~ [[:space:]]${ADOC}[[:space:]] ]]; then + if [[ ! " ${PO4ACFG_TRANSLATIONS[*]} " =~ .*${ADOC}[[:space:]] ]]; then + echo "Ignore $ADOC" continue fi PO4A_TRANSLATE_ONLY_FLAGS+=("--translate-only") @@ -109,6 +116,8 @@ if echo "0.72" "$PO4A_VERSION" | sort --check --version-sort; then PO4A_TRANSLATE_ONLY_FLAGS=("--no-update") fi +[ "$PROGRESS" = true ] && echo "po4a: generate man-pages translations" + DISCARDED_TRANSLATIONS=() output=$(po4a --srcdir "$SRCDIR" --destdir "$DESTDIR" "${PO4A_TRANSLATE_ONLY_FLAGS[@]}" "$PO4ACFG") while IFS= read -r line; do @@ -136,6 +145,10 @@ for ADOC in "${TRANSLATED_MANADOCS[@]}"; do LOCALE=$(basename "$(dirname "$ADOC")") PAGE="${ADOC%.*}" SECTION="${PAGE##*.}" + if [ "$PROGRESS" = true ]; then + PAGENAME=$(basename $PAGE) + echo " GEN " $LOCALE ": " $PAGENAME + fi asciidoctor \ --backend manpage \ --attribute VERSION="$UTIL_LINUX_VERSION" \