Skip to content

Commit 85987df

Browse files
authored
Merge d8f9bbe into 90c3514
2 parents 90c3514 + d8f9bbe commit 85987df

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+470
-337
lines changed

Makefile.am

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -702,8 +702,8 @@ SET_PARMAKES_OPT = \
702702
case " $(MAKEFLAGS) $(AM_MAKEFLAGS)" in \
703703
*"j"*) ;; \
704704
*) \
705-
if ! [ "$${MAXPARMAKES-}" -gt 1 ] 2>/dev/null ; then \
706-
MAXPARMAKES=8 ; \
705+
if [ "$${MAXPARMAKES-}" -gt 1 ] 2>/dev/null ; then \
706+
true ; else MAXPARMAKES=8 ; \
707707
fi ; \
708708
PARMAKES_OPT="-j $${MAXPARMAKES}" ; \
709709
;; \
@@ -763,7 +763,7 @@ maintainer-asciidocs:
763763
find . -name '*.adoc' -or -name '*.txt' | ( \
764764
FILES=""; \
765765
while read F ; do \
766-
grep -E '^//+GH_MARKUP_1095_INCLUDE_(BEGIN|END)' "$$F" >/dev/null \
766+
$(EGREP) '^//+GH_MARKUP_1095_INCLUDE_(BEGIN|END)' "$$F" >/dev/null \
767767
|| { echo "$@: SKIP: no GH_MARKUP_1095_INCLUDE_* tags: $$F"; continue ; } ; \
768768
rm -f "$${F}"*.tmp || exit ; \
769769
EXT="1.tmp"; \
@@ -834,7 +834,7 @@ dist-hook:
834834
###
835835
check-scripts-syntax:
836836
@echo 'NOTE: modern bash complains about scripts using backticks (warning not error), which we ignore in NUT codebase for portability reasons: `...` obsolete, use $$(...)'
837-
@RUNBASH=bash; if [ -x /bin/bash ] && /bin/bash -c 'echo $${BASH_VERSION}' | grep -E '^[456789]\.' ; then RUNBASH=/bin/bash ; else if [ -x /usr/bin/env ] ; then RUNBASH="/usr/bin/env bash"; fi; fi ; \
837+
@RUNBASH=bash; if [ -x /bin/bash ] && /bin/bash -c 'echo $${BASH_VERSION}' | $(EGREP) '^[456789]\.' ; then RUNBASH=/bin/bash ; else if [ -x /usr/bin/env ] ; then RUNBASH="/usr/bin/env bash"; fi; fi ; \
838838
for F in `git ls-files || find . -type f` ; do \
839839
case "`file "$$F"`" in \
840840
*"Bourne-Again shell script"*) ( set -x ; $$RUNBASH -n "$$F" ; ) ;; \
@@ -854,6 +854,7 @@ shellcheck-disclaimer:
854854
# can test the logic with numerous SHELL_PROGS in a CI setting, and because
855855
# check-scripts-syntax probably has checked the basic syntax above already.
856856
shellcheck-nde:
857+
GREP="$(GREP)"; EGREP="$(EGREP)"; export GREP; export EGREP; \
857858
cd $(srcdir)/tests && SERVICE_FRAMEWORK="selftest" ./nut-driver-enumerator-test.sh
858859

859860
shellcheck: shellcheck-disclaimer check-scripts-syntax
@@ -943,8 +944,8 @@ endif !WITH_PDF_NONASCII_TITLES
943944
CHANGELOG_REQUIRE_GROUP_BY_DATE_AUTHOR_ENVVAR = true
944945
$(abs_top_builddir)/ChangeLog: tools/gitlog2changelog.py dummy-stamp
945946
@cd $(abs_top_srcdir) && \
946-
if test -e .git ; then \
947-
NUT_GITDIR=".git" ; if test -r "$${NUT_GITDIR}" -a ! -d "$${NUT_GITDIR}" ; then GD="`grep -E '^gitdir:' "$${NUT_GITDIR}" | sed 's/^gitdir: *//'`" && test -n "$$GD" -a -d "$$GD" && NUT_GITDIR="$$GD" ; fi ; \
947+
if ( test -e .git ) 2>/dev/null || test -d .git || test -f .git || test -h .git ; then \
948+
NUT_GITDIR=".git" ; if test -r "$${NUT_GITDIR}" -a ! -d "$${NUT_GITDIR}" ; then GD="`$(EGREP) '^gitdir:' "$${NUT_GITDIR}" | sed 's/^gitdir: *//'`" && test -n "$$GD" -a -d "$$GD" && NUT_GITDIR="$$GD" ; fi ; \
948949
if test -s "$@" -a -d "$${NUT_GITDIR}" && test -z "`find "$${NUT_GITDIR}" -newer "$@" 2>/dev/null`" ; then \
949950
echo " DOC-CHANGELOG-GENERATE $@ : SKIP (keep existing)" ; \
950951
echo "Using still-valid ChangeLog file generated earlier from same revision of Git source metadata in '$${NUT_GITDIR}'" >&2 ; \
@@ -966,12 +967,12 @@ $(abs_top_builddir)/ChangeLog: tools/gitlog2changelog.py dummy-stamp
966967
else \
967968
if test x"$(abs_top_srcdir)" != x"$(abs_top_builddir)" -a -s ./ChangeLog ; then \
968969
echo " DOC-CHANGELOG-GENERATE $@ : SKIP (keep existing)" ; \
969-
if ! diff ./ChangeLog "$@" >/dev/null 2>/dev/null ; then \
970+
if diff ./ChangeLog "$@" >/dev/null 2>/dev/null ; then \
971+
echo "Using distributed ChangeLog file from sources (and builddir already has content identical to one in srcdir)" >&2 ; \
972+
else \
970973
echo "Using distributed ChangeLog file from sources (and builddir is not srcdir)" >&2 ; \
971974
rm -f "$@" || true ; \
972975
cp -pf ./ChangeLog "$@" || { cat ./ChangeLog > "$@" ; touch -r ./ChangeLog "$@" || true ; } ; \
973-
else \
974-
echo "Using distributed ChangeLog file from sources (and builddir already has content identical to one in srcdir)" >&2 ; \
975976
fi ; \
976977
else \
977978
if test -s "$@" ; then \
@@ -1274,7 +1275,9 @@ install-as-root:
12741275
|| if [ -s '@sysconfdir@/ups.conf' -a -s '@sysconfdir@/upsd.conf' -a -s '@sysconfdir@/upsd.users' -a -s '@sysconfdir@/upsmon.conf' ] ; then exit 1 ; \
12751276
else echo "$@: some configs are missing, assuming new NUT installation" >&2; fi; \
12761277
fi ; \
1277-
if ! $${applied_udev} && (command -v udevadm); then \
1278+
if $${applied_udev} && (command -v udevadm); then \
1279+
true ; \
1280+
else \
12781281
udevadm control --reload-rules && udevadm trigger && applied_udev=true || true ; \
12791282
fi ; \
12801283
fi ; \
@@ -1406,8 +1409,8 @@ install-win-bundle-thirdparty:
14061409
relcgiexecdir="`echo './$(cgiexecdir)/' | sed 's,//*,/,g'`" ; \
14071410
rellibexecdir="`echo './$(libexecdir)/' | sed 's,//*,/,g'`" ; \
14081411
cd '$(DESTDIR)' || exit ; \
1409-
find . -type f | grep -Ei '\.(exe|dll)$$' \
1410-
| grep -vE "^($${relbindir}|$${relsbindir}|$${reldriverexecdir}|$${relcgiexecdir}|$${rellibexecdir})" \
1412+
find . -type f | $(EGREP) -i '\.(exe|dll)$$' \
1413+
| $(EGREP) -v "^($${relbindir}|$${relsbindir}|$${reldriverexecdir}|$${relcgiexecdir}|$${rellibexecdir})" \
14111414
| ( RES=0 ; while IFS= read LINE ; do echo "$$LINE" ; RES=1; done; exit $$RES )
14121415

14131416
else !HAVE_WINDOWS
@@ -1426,7 +1429,7 @@ print-DISTCLEANFILES:
14261429

14271430
# TODO: Recursive mode to consider patterns defined in sub-dir makefiles
14281431
git-realclean-check:
1429-
@if test -e .git && (command -v git); then \
1432+
@if ( ( test -e .git ) 2>/dev/null || test -d .git || test -f .git || test -h .git ) && (command -v git); then \
14301433
git status --ignored || while read F ; do \
14311434
for P in $(MAINTAINERCLEANFILES) ; do \
14321435
case "$$F" in \
@@ -1475,11 +1478,11 @@ check-parallel-builds:
14751478
cd '$(abs_top_builddir)' || exit ; \
14761479
$(MAKE) $(AM_MAKEFLAGS) -k -s $${PARMAKES_OPT} clean || { RES=$$?; echo "$@: FAILED: make pre-clean before checking subdirs for sources" >&2; exit $$RES; } ; \
14771480
for D in `cd '$(top_srcdir)' && find . -name '*.c' -o -name '*.cpp' | sed 's,/[^/]*\.cp*$$,,' | uniq` ; do \
1478-
[ -e "$(top_srcdir)/$$D/Makefile.am" ] && [ -s "$$D/Makefile" ] || continue ; \
1481+
( ( [ -e "$(top_srcdir)/$$D/Makefile.am" ] ) 2>/dev/null || [ -f "$(top_srcdir)/$$D/Makefile.am" ] || [ -h "$(top_srcdir)/$$D/Makefile.am" ] ) && [ -s "$$D/Makefile" ] || continue ; \
14791482
$(MAKE) $(AM_MAKEFLAGS) -k -s $${PARMAKES_OPT} clean || { RES=$$?; echo "$@: FAILED: make clean before going to $$D" >&2; exit $$RES; } ; \
14801483
echo " $@ in $${D}" ; \
14811484
( cd "$$D" && $(MAKE) $(AM_MAKEFLAGS) -k -s $${PARMAKES_OPT} ) || { RES=$$?; echo "$@: FAILED: parallel make in $$D" >&2; \
1482-
echo "To investigate, try: (MAKEFLAGS='$(MAKEFLAGS)' ; export MAKEFLAGS; $(MAKE) $(AM_MAKEFLAGS) $${PARMAKES_OPT} clean ; automake -f && ./config.status && clear && (cd $${D}/ && $(MAKE) $(AM_MAKEFLAGS) V=1 $${PARMAKES_OPT} 2>&1 ; echo $$?) | tee /tmp/make.log ; RES=$$? ; grep -E '(\] Error|No rule to)' /tmp/make.log && less /tmp/make.log ; exit $$RES )"; \
1485+
echo "To investigate, try: (MAKEFLAGS='$(MAKEFLAGS)' ; export MAKEFLAGS; $(MAKE) $(AM_MAKEFLAGS) $${PARMAKES_OPT} clean ; automake -f && ./config.status && clear && (cd $${D}/ && $(MAKE) $(AM_MAKEFLAGS) V=1 $${PARMAKES_OPT} 2>&1 ; echo $$?) | tee /tmp/make.log ; RES=$$? ; $(EGREP) '(\] Error|No rule to)' /tmp/make.log && less /tmp/make.log ; exit $$RES )"; \
14831486
echo "If builds were interrupted before, you may also have to re-initialize the build area completely, e.g.: git clean -fdX ; ./ci_build.sh && $(MAKE) $(MAKEFLAGS) $(AM_MAKEFLAGS) $@" ; \
14841487
exit $$RES; } ; \
14851488
DIRS="$${DIRS} $${D}" ; \

NEWS.adoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,18 @@ https://github.com/networkupstools/nut/milestone/12
138138
- Updated `docs/*.txt`: add asciidoc comments with links to nut-website
139139
rendered contents of most interesting pages. [#3095]
140140

141+
- Revised CI and deliverable scripts, and Makefile recipes, to not use
142+
the verbatim `grep -E` (loudly preferred by newer systems, but may be
143+
absent on older ones) after all, nor use `egrep` (loudly disliked by
144+
newer systems). Instead, use what `configure` script detected for the
145+
generated files (or ones made from templates), and use a similar
146+
detection in standalone scripts. Also revised the use of `grep -q`,
147+
`id -u`, `diff -u`, etc. which are not ubiquitous, and of `test -e`
148+
which is not only absent in some older shells, but can cause them to
149+
abort processing the script immediately. Also the `if ! condition`
150+
syntax is not supported everywhere (or the `!` operator generally).
151+
[#3099, #1660]
152+
141153

142154
Release notes for NUT 2.8.4 - what's new since 2.8.3
143155
----------------------------------------------------

autogen.sh

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,9 @@ else
2424
DEBUG=false
2525
fi
2626

27+
[ -n "${GREP}" ] || { GREP="`command -v grep`" && [ x"${GREP}" != x ] || { echo "$0: FAILED to locate GREP tool" >&2 ; exit 1 ; } ; export GREP ; }
28+
[ -n "${EGREP}" ] || { if ( [ x"`echo a | $GREP -E '(a|b)'`" = xa ] ) 2>/dev/null ; then EGREP="$GREP -E" ; else EGREP="`command -v egrep`" ; fi && [ x"${EGREP}" != x ] || { echo "$0: FAILED to locate EGREP tool" >&2 ; exit 1 ; } ; export EGREP ; }
29+
2730
NUT_VERSION_QUERY=UPDATE_FILE "`dirname $0`"/tools/gitlog2version.sh
2831

2932
if [ -n "${PYTHON-}" ] ; then
@@ -108,8 +111,8 @@ if [ ! -f scripts/udev/nut-usbups.rules.in -o \
108111
! -f scripts/devd/nut-usb.conf.in -o \
109112
! -f scripts/devd/nut-usb.quirks -o \
110113
! -f tools/nut-scanner/nutscan-usb.h ] \
111-
|| [ -n "`find drivers -newer scripts/hotplug/libhid.usermap | grep -E '(-hid|nutdrv_qx|usb.*)\.c'`" ] \
112-
|| [ -n "`find drivers -not -newer tools/nut-usbinfo.pl | grep -E '(-hid|nutdrv_qx|usb.*)\.c'`" ] \
114+
|| [ -n "`find drivers -newer scripts/hotplug/libhid.usermap | ${EGREP} '(-hid|nutdrv_qx|usb.*)\.c'`" ] \
115+
|| [ -n "`find drivers \! -newer tools/nut-usbinfo.pl | ${EGREP} '(-hid|nutdrv_qx|usb.*)\.c'`" ] \
113116
; then
114117
if perl -e 1; then
115118
VERBOSE_FLAG_PERL=""
@@ -191,7 +194,7 @@ else
191194
fi
192195

193196
[ "$AUTOTOOL_RES" = 0 ] && [ -s configure ] && [ -x configure ] \
194-
|| { cat << EOF
197+
|| { ( cat << EOF
195198
----------------------------------------------------------------------
196199
FAILED: did not generate an executable configure script!
197200
@@ -206,8 +209,9 @@ FAILED: did not generate an executable configure script!
206209
# "ifdef" block if your autotools still would not grok it.
207210
----------------------------------------------------------------------
208211
EOF
212+
) >&2
209213
exit 1
210-
} >&2
214+
}
211215

212216
# Some autoconf versions may leave "/bin/sh" regardless of CONFIG_SHELL
213217
# which originally was made for "recheck" operations
@@ -233,6 +237,7 @@ else
233237
CONFIG_SHELL="`head -1 configure | sed 's,^#!,,'`"
234238
fi
235239

240+
echo "autogen.sh: testing generated script syntax with $CONFIG_SHELL" >&2
236241
# NOTE: Unquoted CONFIG_SHELL, may be multi-token
237242
$CONFIG_SHELL -n configure 2>/dev/null >/dev/null \
238243
|| {

0 commit comments

Comments
 (0)