Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deliver the NUT configuration report (if "kept") #1835

Merged
merged 8 commits into from
Jan 23, 2023
4 changes: 4 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down
20 changes: 19 additions & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -358,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):
Expand Down Expand Up @@ -4106,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
Expand Down
15 changes: 14 additions & 1 deletion docs/configure.txt
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,21 @@ 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`
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
-----------------------------

Expand All @@ -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
----------------

Expand Down
76 changes: 38 additions & 38 deletions m4/nut_report_feature.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand All @@ -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"
])

Expand Down Expand Up @@ -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],
Expand All @@ -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],
Expand All @@ -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],
Expand All @@ -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],
Expand All @@ -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"
])

Expand Down