From 863f2fc59c9702114ae0a269faafd5bd0cde5713 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 22 Jan 2023 18:11:21 +0100 Subject: [PATCH 1/8] m4/nut_report_feature.m4: standardize indentation, more M4 AS_IFs [#1826] --- m4/nut_report_feature.m4 | 76 ++++++++++++++++++++-------------------- 1 file changed, 38 insertions(+), 38 deletions(-) diff --git a/m4/nut_report_feature.m4 b/m4/nut_report_feature.m4 index dbe4455a29..31814c2ce2 100644 --- a/m4/nut_report_feature.m4 +++ b/m4/nut_report_feature.m4 @@ -10,10 +10,10 @@ AC_DEFUN([NUT_REPORT_FILE], dnl arg#2 = value dnl arg#3 = file tag (e.g. number) dnl arg#4 = file title (e.g. "NUT Configuration summary:") - if test -z "${nut_report_feature_flag$3}"; then + AS_IF([test x"${nut_report_feature_flag$3}" = x], [ nut_report_feature_flag$3="1" ac_clean_files="${ac_clean_files} config.nut_report_feature.log.$3" - if test x1 = x$3 ; then + if test x1 = "x$3" ; then echo "$4" echo "$4" | sed 's/./=/g' echo "" @@ -23,7 +23,7 @@ AC_DEFUN([NUT_REPORT_FILE], echo "$4" | sed 's/./-/g' echo "" fi > "config.nut_report_feature.log.$3" - fi + ]) printf "* $1:\t$2\n" >> "config.nut_report_feature.log.$3" ]) @@ -55,14 +55,14 @@ AC_DEFUN([NUT_REPORT_FEATURE], dnl arg#3 = value dnl arg#4 = autoconf varname dnl arg#5 = longer description (autoconf comment) - AC_MSG_CHECKING([whether to $1]) - AC_MSG_RESULT([$2 $3]) - NUT_REPORT([$1], [$2 $3]) - - AM_CONDITIONAL([$4], test "$2" = "yes") - if test "$2" = "yes"; then - AC_DEFINE_UNQUOTED($4, 1, $5) - fi + AC_MSG_CHECKING([whether to $1]) + AC_MSG_RESULT([$2 $3]) + NUT_REPORT([$1], [$2 $3]) + + AM_CONDITIONAL([$4], test "$2" = "yes") + AS_IF([test x"$2" = x"yes"], [ + AC_DEFINE_UNQUOTED($4, 1, $5) + ]) ]) AC_DEFUN([NUT_REPORT_SETTING], @@ -71,12 +71,12 @@ AC_DEFUN([NUT_REPORT_SETTING], dnl arg#2 = autoconf varname dnl arg#3 = value dnl arg#4 = longer description (autoconf comment) - AC_MSG_CHECKING([setting for $1]) - AC_MSG_RESULT([$3]) - NUT_REPORT([$1], [$3]) + AC_MSG_CHECKING([setting for $1]) + AC_MSG_RESULT([$3]) + NUT_REPORT([$1], [$3]) - dnl Note: unlike features, settings do not imply an AutoMake toggle - AC_DEFINE_UNQUOTED($2, $3, $4) + dnl Note: unlike features, settings do not imply an AutoMake toggle + AC_DEFINE_UNQUOTED($2, $3, $4) ]) AC_DEFUN([NUT_REPORT_SETTING_PATH], @@ -85,12 +85,12 @@ AC_DEFUN([NUT_REPORT_SETTING_PATH], dnl arg#2 = autoconf varname dnl arg#3 = value dnl arg#4 = longer description (autoconf comment) - AC_MSG_CHECKING([setting for $1]) - AC_MSG_RESULT([$3]) - NUT_REPORT_PATH([$1], [$3]) + AC_MSG_CHECKING([setting for $1]) + AC_MSG_RESULT([$3]) + NUT_REPORT_PATH([$1], [$3]) - dnl Note: unlike features, settings do not imply an AutoMake toggle - AC_DEFINE_UNQUOTED($2, $3, $4) + dnl Note: unlike features, settings do not imply an AutoMake toggle + AC_DEFINE_UNQUOTED($2, $3, $4) ]) AC_DEFUN([NUT_REPORT_SETTING_PATH_INTEGRATIONS], @@ -99,12 +99,12 @@ AC_DEFUN([NUT_REPORT_SETTING_PATH_INTEGRATIONS], dnl arg#2 = autoconf varname dnl arg#3 = value dnl arg#4 = longer description (autoconf comment) - AC_MSG_CHECKING([setting for $1]) - AC_MSG_RESULT([$3]) - NUT_REPORT_PATH_INTEGRATIONS([$1], [$3]) + AC_MSG_CHECKING([setting for $1]) + AC_MSG_RESULT([$3]) + NUT_REPORT_PATH_INTEGRATIONS([$1], [$3]) - dnl Note: unlike features, settings do not imply an AutoMake toggle - AC_DEFINE_UNQUOTED($2, $3, $4) + dnl Note: unlike features, settings do not imply an AutoMake toggle + AC_DEFINE_UNQUOTED($2, $3, $4) ]) AC_DEFUN([NUT_REPORT_TARGET], @@ -122,18 +122,18 @@ AC_DEFUN([NUT_REPORT_TARGET], AC_DEFUN([NUT_REPORT_COMPILERS], [ - (echo "" - echo "NUT Compiler settings:" - echo "----------------------" - echo "" - printf '* CC \t: %s\n' "$CC" - printf '* CFLAGS \t: %s\n' "$CFLAGS" - printf '* CXX \t: %s\n' "$CXX" - printf '* CXXFLAGS\t: %s\n' "$CXXFLAGS" - printf '* CPP \t: %s\n' "$CPP" - printf '* CPPFLAGS\t: %s\n' "$CPPFLAGS" - printf '* CONFIG_FLAGS\t: %s\n' "$CONFIG_FLAGS" - ) > config.nut_report_feature.log.9 + (echo "" + echo "NUT Compiler settings:" + echo "----------------------" + echo "" + printf '* CC \t: %s\n' "$CC" + printf '* CFLAGS \t: %s\n' "$CFLAGS" + printf '* CXX \t: %s\n' "$CXX" + printf '* CXXFLAGS\t: %s\n' "$CXXFLAGS" + printf '* CPP \t: %s\n' "$CPP" + printf '* CPPFLAGS\t: %s\n' "$CPPFLAGS" + printf '* CONFIG_FLAGS\t: %s\n' "$CONFIG_FLAGS" + ) > config.nut_report_feature.log.9 ac_clean_files="${ac_clean_files} config.nut_report_feature.log.9" ]) From a1dacb28029a9a9eaf9d1efdbf55a115219dc5d7 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 22 Jan 2023 18:17:07 +0100 Subject: [PATCH 2/8] m4/nut_report_feature.m4, Makefile.am: install config.nut_report_feature.log if kept [#1826] --- Makefile.am | 4 ++++ m4/nut_report_feature.m4 | 2 ++ 2 files changed, 6 insertions(+) diff --git a/Makefile.am b/Makefile.am index 7b87c013ba..15c04d411e 100644 --- a/Makefile.am +++ b/Makefile.am @@ -27,6 +27,10 @@ EXTRA_DIST = INSTALL.nut LICENSE-GPL2 LICENSE-GPL3 MAINTAINERS UPGRADING # want to adapt it to their autotools or locally fix a tarball-based build. EXTRA_DIST += autogen.sh +if KEEP_NUT_REPORT +nodist_data_DATA = config.nut_report_feature.log +endif + # ---------------------------------------------------------------------- # flags to pass to ./configure when calling "make distcheck" and "make # distcheck-light". Try to check as many features as possible! Also diff --git a/m4/nut_report_feature.m4 b/m4/nut_report_feature.m4 index 31814c2ce2..29b98eda8f 100644 --- a/m4/nut_report_feature.m4 +++ b/m4/nut_report_feature.m4 @@ -152,4 +152,6 @@ AC_DEFUN([NUT_PRINT_FEATURE_REPORT], ac_clean_files="${ac_clean_files} config.nut_report_feature.log" cat config.nut_report_feature.log.* ]) + + AM_CONDITIONAL(KEEP_NUT_REPORT, test x"${nut_enable_keep_nut_report_feature-}" = xyes) ]) From a8781a418b121a96fa8303c48d708224f5f72031 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 22 Jan 2023 18:27:44 +0100 Subject: [PATCH 3/8] configure.ac: report GITREV (if any) valid at the time of configure run --- configure.ac | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index b2fbd1f095..834aaf0569 100644 --- a/configure.ac +++ b/configure.ac @@ -7,6 +7,14 @@ dnl NUT_VERSION_MACRO "2.7.4-2838-gdfc3ac08" dnl in include/nut_version.h (generated by make) AC_INIT([nut],[2.8.0.1],[https://github.com/networkupstools/nut/issues]) +dnl Note: this refers to GITREV at the time of configure script running +dnl primarily for better messaging in the script itself. +dnl If the NUT codebase in this workspace is being developed and rebuilt +dnl without reconfiguration, detailed version in the binaries will differ. +(command -v git >/dev/null 2>/dev/null) \ +&& GITREV="`git describe --tags 2>/dev/null | sed -e 's/^v\([0-9]\)/\1/' -e 's,^.*/,,'`" \ +|| GITREV="" + dnl Keep track of command-line options passed to this script: AC_MSG_CHECKING([for CONFIG_FLAGS]) CONFIG_FLAGS="" @@ -54,7 +62,9 @@ AC_SUBST(CONFIG_FLAGS) AC_CONFIG_AUX_DIR([.]) AC_CONFIG_SRCDIR(server/upsd.c) AC_CONFIG_MACRO_DIR([m4]) -echo "Network UPS Tools version ${PACKAGE_VERSION}" +AS_IF([test x"${GITREV}" = x], + [echo "Network UPS Tools version ${PACKAGE_VERSION}"], + [echo "Network UPS Tools version ${PACKAGE_VERSION} (${GITREV})"]) AC_CANONICAL_TARGET NUT_CHECK_OS NUT_STASH_WARNINGS From 4c1cef914889c1bb30fd81df59f696a15bf35dd2 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 22 Jan 2023 18:28:18 +0100 Subject: [PATCH 4/8] configure.ac: NUT_REPORT() the PACKAGE_VERSION (and GITREV if any) valid at the time of configure run [#1826] --- configure.ac | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/configure.ac b/configure.ac index 834aaf0569..ed7a2f87f6 100644 --- a/configure.ac +++ b/configure.ac @@ -368,6 +368,11 @@ AC_C_VARARRAYS NUT_ARG_ENABLE([keep_nut_report_feature], [Request that we keep config.nut_report_feature.log (normally deleted by configure script after displaying)], [no]) + +AS_IF([test x"${GITREV}" = x], + [NUT_REPORT([configured version], [${PACKAGE_VERSION}])], + [NUT_REPORT([configured version], [${PACKAGE_VERSION} (${GITREV})])]) + dnl Note: the compiler/pragma/attr methods below are custom for NUT codebase: NUT_COMPILER_FAMILY dnl Help find warning/error details in a wall of text (must be processed before NUT_COMPILER_FAMILY_FLAGS): From 9744922c784ed1e41b7ace1093c5b2e6136d4dc5 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 22 Jan 2023 18:36:46 +0100 Subject: [PATCH 5/8] docs/configure.txt: document --enable-keep_nut_report_feature and that the file can be installed [#1826] --- docs/configure.txt | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/configure.txt b/docs/configure.txt index 138bae9142..ffb3162e0c 100644 --- a/docs/configure.txt +++ b/docs/configure.txt @@ -41,6 +41,15 @@ Network UPS Tools upsd 2.8.0.1 A more industrial approach is to use `lib/libupsclient-config --config-flags` where supported. +Keeping a report of NUT configuration +------------------------------------- + + --enable-keep_nut_report_feature + +If this option is enabled (not currently default), the report displayed +by `configure` script will be kept in a file when the script ends, and +installed into the data directory. + In-place replacement defaults ----------------------------- @@ -65,6 +74,10 @@ If the installed NUT version supports reporting of `CONFIG_FLAGS` used during its build, the `configure` script will try to take those values into account when running in this mode. +NOTE: This does not currently rely on the configuration report optionally +installed by `--enable-keep_nut_report_feature` above, but might do so +eventually. + Driver selection ---------------- From dc441e616a8ac321b5e21a8f4416c1d9dc1a0587 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 22 Jan 2023 18:37:21 +0100 Subject: [PATCH 6/8] docs/configure.txt: debug-report of CONFIG_FLAGS is now shorter --- docs/configure.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/configure.txt b/docs/configure.txt index ffb3162e0c..e5a93ea505 100644 --- a/docs/configure.txt +++ b/docs/configure.txt @@ -35,7 +35,7 @@ to produce a replacement by asking NUT programs for `--help` or for ---- :; upsd -DV Network UPS Tools upsd 2.8.0.1 - 0.000000 [D1] Network UPS Tools version 2.8.0.1 configured with flags: --with-all=auto --with-doc=skip ... +Network UPS Tools version 2.8.0.1 configured with flags: --with-all=auto --with-doc=skip ... ---- A more industrial approach is to use `lib/libupsclient-config --config-flags` From e6912da1243a10b60f0c7f74592a937f1ec577ab Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 22 Jan 2023 18:40:32 +0100 Subject: [PATCH 7/8] UPGRADING: document --enable-keep_nut_report_feature and that the file can be installed [#1826, #1708] --- UPGRADING | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/UPGRADING b/UPGRADING index b724e8173b..47bc73c3a1 100644 --- a/UPGRADING +++ b/UPGRADING @@ -79,6 +79,11 @@ Changes from 2.8.0 to 2.8.1 to eradicate `@PIDPATH@/nut` ambiguity in favor of `@ALTPIDPATH@` for the unprivileged processes vs. `@PIDPATH@` for those running as root [#1719] +- The "layman report" of NUT configuration options displayed after the run + of `configure` script can now be retained and installed by using the + `--enable-keep_nut_report_feature` option; packagers are welcome to make + use of this, to better keep track of their deliveries [#1826, #1708] + - Renamed generated nut-common.tmpfiles(.in) => nut-common-tmpfiles.conf(.in) to install a /usr/lib/systemd-tmpfiles/*.conf pattern [#1755] From f14bbcfb3544af18ec54ca0aa7f4486b77de6868 Mon Sep 17 00:00:00 2001 From: Jim Klimov Date: Sun, 22 Jan 2023 21:29:29 +0100 Subject: [PATCH 8/8] configure.ac, m4/nut_report_feature.m4: move KEEP_NUT_REPORT definition to before AC_OUTPUT [#1826] --- configure.ac | 3 +++ m4/nut_report_feature.m4 | 2 -- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/configure.ac b/configure.ac index ed7a2f87f6..feff0c000b 100644 --- a/configure.ac +++ b/configure.ac @@ -4121,6 +4121,9 @@ m4_foreach_w([SCRIPTFILE], [ ) ]) +dnl Define this before AC_OUTPUT(), so not in report below +AM_CONDITIONAL(KEEP_NUT_REPORT, test x"${nut_enable_keep_nut_report_feature-}" = xyes) + AC_OUTPUT NUT_REPORT_COMPILERS diff --git a/m4/nut_report_feature.m4 b/m4/nut_report_feature.m4 index 29b98eda8f..31814c2ce2 100644 --- a/m4/nut_report_feature.m4 +++ b/m4/nut_report_feature.m4 @@ -152,6 +152,4 @@ AC_DEFUN([NUT_PRINT_FEATURE_REPORT], ac_clean_files="${ac_clean_files} config.nut_report_feature.log" cat config.nut_report_feature.log.* ]) - - AM_CONDITIONAL(KEEP_NUT_REPORT, test x"${nut_enable_keep_nut_report_feature-}" = xyes) ])