diff --git a/autogen.sh b/autogen.sh index 91f98f1377..9d7d05e8c2 100755 --- a/autogen.sh +++ b/autogen.sh @@ -178,6 +178,7 @@ fi [ "$AUTOTOOL_RES" = 0 ] && [ -s configure ] && [ -x configure ] \ || { cat << EOF +---------------------------------------------------------------------- FAILED: did not generate an executable configure script! # Note: on some systems "autoreconf", "automake" et al are dispatcher @@ -189,6 +190,7 @@ FAILED: did not generate an executable configure script! # check the configure.ac line it refers to and un-comment (or comment away) # the third argument for AM_SILENT_RULES check, or comment away the whole # "ifdef" block if your autotools still would not grok it. +---------------------------------------------------------------------- EOF exit 1 } >&2 @@ -217,15 +219,20 @@ else CONFIG_SHELL="`head -1 configure | sed 's,^#!,,'`" fi -# NOTE: Unquoted, may be multi-token +# NOTE: Unquoted CONFIG_SHELL, may be multi-token $CONFIG_SHELL -n configure 2>/dev/null >/dev/null \ -|| { echo "FAILED: configure script did not pass shell interpreter syntax checks with $CONFIG_SHELL" >&2 +|| { + echo "----------------------------------------------------------------------" >&2 + echo "FAILED: configure script did not pass shell interpreter syntax checks with $CONFIG_SHELL" >&2 echo "NOTE: If you are using an older OS release, try executing the script with" >&2 echo "a more functional shell implementation (dtksh, bash, dash...)" >&2 echo "You can re-run this script with a CONFIG_SHELL in environment" >&2 + echo "----------------------------------------------------------------------" >&2 exit 1 } +echo "----------------------------------------------------------------------" echo "SUCCESS: The generated configure script passed shell interpreter syntax checks" echo "Please proceed by running './configure --with-many-desired-options'" echo "For details check './configure --help' or docs/configure.txt in NUT sources" +echo "----------------------------------------------------------------------" diff --git a/ci_build.sh b/ci_build.sh index cf094e0e24..ca111198cc 100755 --- a/ci_build.sh +++ b/ci_build.sh @@ -667,7 +667,9 @@ check_gitignore() { # Shell-glob filename pattern for points of interest to git status # and git diff; note that filenames starting with a dot should be # reported by `git status -- '*'` and not hidden. - [ -n "${FILE_GLOB-}" ] || FILE_GLOB='*' + [ -n "${FILE_GLOB-}" ] || FILE_GLOB="'*'" + # Always filter these names away: + FILE_GLOB_EXCLUDE="':!.ci*.log*'" [ -n "${GIT_ARGS-}" ] || GIT_ARGS='' # e.g. GIT_ARGS="--ignored" # Display contents of the diff? # (Helps copy-paste from CI logs to source to amend quickly) @@ -682,12 +684,11 @@ check_gitignore() { # One invocation should report to log if there was any discrepancy # to report in the first place (GITOUT may be empty without error): - GITOUT="`git status $GIT_ARGS -s -- "${FILE_GLOB}"`" \ + GITOUT="`git status $GIT_ARGS -s -- ${FILE_GLOB} ${FILE_GLOB_EXCLUDE}`" \ || { echo "WARNING: Could not query git repo while in `pwd`" >&2 ; GITOUT=""; } if [ -n "${GITOUT-}" ] ; then echo "$GITOUT" \ - | grep -E -v '^.. \.ci.*\.log.*' \ | grep -E "${FILE_REGEX}" else echo "Got no output and no errors querying git repo while in `pwd`: seems clean" >&2 @@ -695,12 +696,12 @@ check_gitignore() { echo "===" # Another invocation checks that there was nothing to complain about: - if [ -n "`git status $GIT_ARGS -s "${FILE_GLOB}" | grep -E -v '^.. \.ci.*\.log.*' | grep -E "^.. ${FILE_REGEX}"`" ] \ + if [ -n "`git status $GIT_ARGS -s ${FILE_GLOB} ${FILE_GLOB_EXCLUDE} | grep -E "^.. ${FILE_REGEX}"`" ] \ && [ "$CI_REQUIRE_GOOD_GITIGNORE" != false ] \ ; then echo "FATAL: There are changes in $FILE_DESCR files listed above - tracked sources should be updated in the PR (even if generated - not all builders can do so), and build products should be added to a .gitignore file, everything made should be cleaned and no tracked files should be removed! You can 'export CI_REQUIRE_GOOD_GITIGNORE=false' if appropriate." >&2 if [ "$GIT_DIFF_SHOW" = true ]; then - PAGER=cat git diff -- "${FILE_GLOB}" || true + PAGER=cat git diff -- ${FILE_GLOB} ${FILE_GLOB_EXCLUDE} || true fi echo "===" return 1 @@ -1083,7 +1084,9 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-sp fi fi else - echo "WARNING: It seems you are building on MacOS, but HOMEBREW_PREFIX is not set or valid; it can help with auto-detection of some features!" + echo "WARNING: It seems you are building on MacOS, but HOMEBREW_PREFIX is not set or valid." + echo 'If you do use this build system, try running eval "$(brew shellenv)"' + echo "in your terminal or shell profile, it can help with auto-detection of some features!" fi ;; esac diff --git a/common/common.c b/common/common.c index 729e7fbefb..5acecd0118 100644 --- a/common/common.c +++ b/common/common.c @@ -1018,6 +1018,12 @@ int compareprocname(pid_t pid, const char *procname, const char *progname) } #endif + /* TOTHINK: Developer builds wrapped with libtool may be prefixed + * by "lt-" in the filename. Should we re-enter (or wrap around) + * this search with a set of variants with/without the prefix on + * both sides?.. + */ + /* Nothing above has matched */ ret = 0; diff --git a/configure.ac b/configure.ac index be40080330..4d149b3518 100644 --- a/configure.ac +++ b/configure.ac @@ -5,7 +5,7 @@ dnl +------------------------------------------------------------------+ dnl NUT version number is defined here, with a Git suffixed macro like dnl NUT_VERSION_MACRO "2.7.4-2838-gdfc3ac08" dnl in include/nut_version.h (generated by make) -AC_INIT([nut],[2.8.2.1],[https://github.com/networkupstools/nut/issues]) +AC_INIT([nut],[2.8.2.1],[https://github.com/networkupstools/nut/issues],[nut],[https://networkupstools.org/]) dnl See docs/maintainer-guide.txt about releases - updating the version dnl above is a small part of the consistent ritual! @@ -16,7 +16,7 @@ dnl If the NUT codebase in this workspace is being developed and rebuilt dnl without reconfiguration, detailed version in the binaries will differ dnl (that one comes from the NUT_VERSION_MACRO from nut_version.h file). (command -v git >/dev/null 2>/dev/null) \ -&& NUT_SOURCE_GITREV="`(git describe --tags --match 'v[0-9]*.[0-9]*.[0-9]' --exclude '*-signed' --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*' 2>/dev/null || git describe --tags --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*' --exclude '*Windows*' --exclude '*IPM*' 2>/dev/null ) | sed -e 's/^v\([0-9]\)/\1/' -e 's,^.*/,,'`" \ +&& NUT_SOURCE_GITREV="`(git describe --tags --match 'v@<:@0-9@:>@*.@<:@0-9@:>@*.@<:@0-9@:>@' --exclude '*-signed' --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*' 2>/dev/null || git describe --tags --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*' --exclude '*Windows*' --exclude '*IPM*' 2>/dev/null ) | sed -e 's/^v\(@<:@0-9@:>@\)/\1/' -e 's,^.*/,,'`" \ || NUT_SOURCE_GITREV="" dnl Gitrev-based build identifier which can be used for e.g. PyPI uploads: @@ -5292,7 +5292,16 @@ AS_CASE(["${CONFIG_CXXFLAGS}"], AS_CASE(["${nut_with_debuginfo_C}"], [yes], [ AS_IF([test x"${CLANGCC}" = x"yes" -o x"${GCC}" = x"yes"], [ - CFLAGS="${CFLAGS} -O0 -g3 -gdwarf-2" + dnl Where we can enable debug, minimize the optimizations. + dnl On some platforms LIBNETSNMP_CFLAGS or some such defines + dnl _FORTIFY_SOURCE=N which in turn "requires compiling with + dnl optimization", so we can not disable it in CFLAGS applied + dnl in the end of each and every build command line (highest + dnl priority). However, CPPFLAGS are before (making these + dnl lines an implementation-dependent hack)... + dnl AS_IF([set | grep -E 'FORTIFY_SOURCE'], [], [CFLAGS="${CFLAGS} -O0"]) + CPPFLAGS="${CPPFLAGS} -O0" + CFLAGS="${CFLAGS} -g3 -gdwarf-2" ],[nut_with_debuginfo_C="Unknown C compiler, not adding options"] )], dnl # [no]: By default we do not add debug info @@ -5305,7 +5314,9 @@ AS_CASE(["${nut_with_debuginfo_C}"], AS_CASE(["${nut_with_debuginfo_CXX}"], [yes], [ AS_IF([test "x$CLANGXX" = xyes -o "x$GXX" = xyes], [ - dnl Where we can enable debug, minimize the optimizations + dnl Where we can enable debug, minimize the optimizations. + dnl NOTE: Concerns for -O0 behavior commented above are about C code, + dnl not seen (yet) with C++. CXXFLAGS="${CXXFLAGS} -O0 -g3 -gdwarf-2" dnl Use same settings for CPPUNIT tests (they bump their own by default) CPPUNIT_NUT_CXXFLAGS="" diff --git a/docs/config-prereqs.txt b/docs/config-prereqs.txt index 8f6de45016..939f542cf6 100644 --- a/docs/config-prereqs.txt +++ b/docs/config-prereqs.txt @@ -1366,6 +1366,16 @@ setup, and https://brew.sh if you want to install it on your MacOS system depending on architecture -- see https://docs.brew.sh/Installation for more details; find via `brew config | grep HOMEBREW_PREFIX: | awk '{print $2}'`). +NOTE: The quickest pre-configuration for `ci_build.sh` integration with this +non-default build system would be to add this line into your shell profile: +---- +eval "$(brew shellenv)" +---- + +NOTE: Homebrew is not the only build/packaging system available for MacOS, +so NUT scripts do not make any assumptions nor try to find a build system +they were not told about (via `HOMEBREW_PREFIX` in this case). + Currently known dependencies for basic build include: ---- # Optional for a quick spin: diff --git a/docs/nut.dict b/docs/nut.dict index 8a0c0b2b5b..575264f3a8 100644 --- a/docs/nut.dict +++ b/docs/nut.dict @@ -1,4 +1,4 @@ -personal_ws-1.1 en 3197 utf-8 +personal_ws-1.1 en 3198 utf-8 AAC AAS ABI @@ -2751,6 +2751,7 @@ sfr sgml sgs sha +shellenv shm shutdownArguments shutdowncmd diff --git a/drivers/libshut.c b/drivers/libshut.c index 8d8991613d..7a9f78bd34 100644 --- a/drivers/libshut.c +++ b/drivers/libshut.c @@ -1283,7 +1283,7 @@ static int shut_control_msg( __func__, data_size); return -1; } - if (data_size > 0x0F) { + if (data_size > 0x0F || data_size > sizeof(shut_pkt) - 2) { upsdebugx(1, "%s: WARNING: data_size %" PRI_NUT_USB_CTRL_CHARBUFSIZE " may be too large for SHUT packet?", __func__, data_size); @@ -1293,7 +1293,7 @@ static int shut_control_msg( } shut_pkt[1] = (unsigned char)(data_size<<4) + (unsigned char)data_size; if ( (requesttype == REQUEST_TYPE_SET_REPORT) && (remaining_size < 8) ) - memcpy(&shut_pkt[2], bytes, data_size); /* we need to send ctrl.data */ + memcpy(&shut_pkt[2], bytes, data_size > sizeof(shut_pkt) - 2 ? sizeof(shut_pkt) - 2 : data_size); /* we need to send ctrl.data */ else memcpy(&shut_pkt[2], &ctrl, 8); shut_pkt[(data_size+3) - 1] = shut_checksum(&shut_pkt[2], (unsigned char)data_size); diff --git a/m4/nut_check_aspell.m4 b/m4/nut_check_aspell.m4 index dbccd27878..4515821add 100644 --- a/m4/nut_check_aspell.m4 +++ b/m4/nut_check_aspell.m4 @@ -114,7 +114,7 @@ if test -z "${nut_have_aspell_seen}"; then AS_IF([test -n "$ASPELL_FILTER_TEX_PATH" -a -d "$ASPELL_FILTER_TEX_PATH"], [ASPELL_NUT_TEXMODE_ARGS="--filter-path='${ASPELL_FILTER_TEX_PATH}' ${ASPELL_NUT_TEXMODE_ARGS}"]) ASPELL_NUT_COMMON_ARGS="-d en -a" dnl Using "eval" to handle quotes, in case of funny paths - out0="`LANG=C; LC_ALL=C; export LANG; export LC_ALL; exec -- 2>&1; set -x; echo test | eval ${ASPELL} ${ASPELL_NUT_TEXMODE_ARGS} ${ASPELL_NUT_COMMON_ARGS}`"; res0=$? + out0="`LANG=C; LC_ALL=C; export LANG; export LC_ALL; ( set -x; echo test | eval ${ASPELL} ${ASPELL_NUT_TEXMODE_ARGS} ${ASPELL_NUT_COMMON_ARGS} ) 2>&1`"; res0=$? AS_IF([test x"$res0" != x0], [ AC_MSG_NOTICE([FAILED CMD: ${ASPELL} ${ASPELL_NUT_TEXMODE_ARGS} ${ASPELL_NUT_COMMON_ARGS}]) AC_MSG_NOTICE([aspell result ($res0) and output: $out0]) @@ -126,7 +126,7 @@ if test -z "${nut_have_aspell_seen}"; then AC_MSG_RESULT(no) AC_MSG_CHECKING([if detected aspell configuration works with built-in paths (tweaked one finds wrong binary modules)]) ASPELL_NUT_TEXMODE_ARGS="-t" - out0="`LANG=C; LC_ALL=C; export LANG; export LC_ALL; exec -- 2>&1; set -x; echo test | eval ${ASPELL} ${ASPELL_NUT_TEXMODE_ARGS} ${ASPELL_NUT_COMMON_ARGS}`"; res0=$? + out0="`LANG=C; LC_ALL=C; export LANG; export LC_ALL; ( set -x; echo test | eval ${ASPELL} ${ASPELL_NUT_TEXMODE_ARGS} ${ASPELL_NUT_COMMON_ARGS} ) 2>&1`"; res0=$? AS_IF([test x"$res0" = x0], [ASPELL_FILTER_TEX_PATH=""], [ AC_MSG_NOTICE([FAILED CMD: ${ASPELL} ${ASPELL_NUT_TEXMODE_ARGS} ${ASPELL_NUT_COMMON_ARGS}]) AC_MSG_NOTICE([aspell result ($res0) and output: $out0])