From cd52718534181dacc475b078d38aad2fccf87959 Mon Sep 17 00:00:00 2001 From: Pierre Pronchery Date: Thu, 19 Nov 2020 03:14:57 +0100 Subject: [PATCH] Import the newer scripts from DeforaOS configure --- po/gettext.sh | 21 ++++++---- tests/clint.sh | 3 ++ tests/fixme.sh | 111 +++++++++++++++++++++++++++++++++++-------------- 3 files changed, 97 insertions(+), 38 deletions(-) diff --git a/po/gettext.sh b/po/gettext.sh index c3ae919..d1b91a2 100755 --- a/po/gettext.sh +++ b/po/gettext.sh @@ -1,6 +1,6 @@ #!/bin/sh #$Id$ -#Copyright (c) 2010-2014 Pierre Pronchery +#Copyright (c) 2010-2020 Pierre Pronchery # #Redistribution and use in source and binary forms, with or without #modification, are permitted provided that the following conditions are met: @@ -25,10 +25,11 @@ #variables +CONFIGSH="${0%/gettext.sh}/../config.sh" PREFIX="/usr/local" -[ -f "../config.sh" ] && . "../config.sh" LOCALEDIR="$PREFIX/share/locale" POTFILES="POTFILES" +PROGNAME="gettext.sh" #executables DEBUG="_debug" INSTALL="install -m 0644" @@ -39,12 +40,14 @@ MSGMERGE="msgmerge" RM="rm -f" XGETTEXT="xgettext --force-po" +[ -f "$CONFIGSH" ] && . "$CONFIGSH" + #functions #debug _debug() { - echo "$@" 1>&2 + echo "$@" 1>&3 "$@" } @@ -52,7 +55,7 @@ _debug() #error _error() { - echo "gettext.sh: $@" 1>&2 + echo "$PROGNAME: $@" 1>&2 return 2 } @@ -60,7 +63,7 @@ _error() #usage _usage() { - echo "Usage: gettext.sh [-c|-i|-u][-P prefix] target..." 1>&2 + echo "Usage: $PROGNAME [-c|-i|-u][-P prefix] target..." 1>&2 return 1 } @@ -111,7 +114,7 @@ _gettext_pot() clean=0 install=0 uninstall=0 -while getopts "ciuP:" name; do +while getopts "ciO:uP:" name; do case "$name" in c) clean=1 @@ -120,6 +123,9 @@ while getopts "ciuP:" name; do uninstall=0 install=1 ;; + O) + export "${OPTARG%%=*}"="${OPTARG#*=}" + ;; u) install=0 uninstall=1 @@ -134,7 +140,7 @@ while getopts "ciuP:" name; do esac done shift $(($OPTIND - 1)) -if [ $# -eq 0 ]; then +if [ $# -lt 1 ]; then _usage exit $? fi @@ -146,6 +152,7 @@ if [ -z "$PACKAGE" ]; then fi LOCALEDIR="$PREFIX/share/locale" +exec 3>&1 while [ $# -gt 0 ]; do target="$1" source="${target#$OBJDIR}" diff --git a/tests/clint.sh b/tests/clint.sh index 1bf833f..a7d22ba 100755 --- a/tests/clint.sh +++ b/tests/clint.sh @@ -25,6 +25,7 @@ #variables +CONFIGSH="${0%/clint.sh}/../config.sh" CFLAGS= CPPFLAGS= PROGNAME="clint.sh" @@ -39,6 +40,8 @@ MKDIR="mkdir -p" SORT="sort -n" TR="tr" +[ -f "$CONFIGSH" ] && . "$CONFIGSH" + #functions #clint diff --git a/tests/fixme.sh b/tests/fixme.sh index 1db1787..84319cf 100755 --- a/tests/fixme.sh +++ b/tests/fixme.sh @@ -25,17 +25,23 @@ #variables +CONFIGSH="${0%/fixme.sh}/../config.sh" PROGNAME="fixme.sh" PROJECTCONF="../project.conf" +REGEXP_ERROR="FIXME" +REGEXP_WARNING="\\(TODO\|XXX\\)" #executables DATE="date" DEBUG="_debug" FIND="find" GREP="grep" +HEAD="head" MKDIR="mkdir -p" SORT="sort -n" TR="tr" +[ -f "$CONFIGSH" ] && . "$CONFIGSH" + #functions #fixme @@ -64,24 +70,7 @@ _fixme() for subdir in $subdirs; do [ -d "../$subdir" ] || continue for filename in $($FIND "../$subdir" -type f | $SORT); do - callback= - ext=${filename##*/} - ext=${ext%.in} - ext=${ext##*.} - case "$ext" in - asm|S) - callback="_fixme_asm" - ;; - c|cc|cpp|cxx|h|js) - callback="_fixme_c" - ;; - conf|sh) - callback="_fixme_sh" - ;; - htm|html|xml) - callback="_fixme_xml" - ;; - esac + callback=$(_fixme_callback "$filename") [ -n "$callback" ] || continue ($callback "$filename") 2>&1 if [ $? -ne 0 ]; then @@ -93,54 +82,114 @@ _fixme() return $res } -_fixme_asm() +_fixme_callback() +{ + filename="$1" + ext=${filename##*/} + ext=${ext%.in} + ext=${ext##*.} + callback= + + case "$ext" in + asm|S) + echo "_fixme_callback_asm" + return 0 + ;; + c|cc|cpp|cxx|h|js|v) + echo "_fixme_callback_c" + return 0 + ;; + conf|sh) + echo "_fixme_callback_sh" + return 0 + ;; + py) + echo "_fixme_callback_python" + return 0 + ;; + htm|html|xml|xsl) + echo "_fixme_callback_xml" + return 0 + ;; + esac + case $($HEAD -n 1 "$filename") in + "#!/bin/sh"*|"#! /bin/sh"*|\ + "#!/usr/bin/env bash"*|"#! /usr/bin/env bash"*) + echo "_fixme_callback_sh" + return 0 + ;; + "#!/usr/bin/env python"*|"#! /usr/bin/env python"*) + echo "_fixme_callback_python" + return 0 + ;; + "