Skip to content

Conversation

@jimklimov
Copy link
Member

@jimklimov jimklimov commented Aug 5, 2024

Closes: #2573

Follows up from #2568 and #2554 recent efforts.

Adding the banner to C++ tool nutconf had some impact on detection of time headers and methods, which failed on Linux+mingw builds of NUT for Windows. Apparently its visibility was different from plain C builds, and never tried for C++ before.

Notable changes include patterns printed by the driver startup - now it would be NUT version info description first, then driver name and info. Previously it was driver name+version and short NUT version in parentheses afterwards (so could have double parentheses with development builds). Also the -V request for version would not report upsnotify (mis-)configuration concerns.

Also nut-scanner now shows its name in the banner, and upsdrvctl remains a bit special to clarify that it is the driver controller program, not a driver itself.

Like with earlier work, a forced semver can be injected (e.g. for embedded builds with policies that use one firmware version for everything, to have a way to reflect real NUT version), 1.1.1 in the test below:

# OLDER DRIVER VERSION PATTERN:
:; /tmp/nut-old/drivers/snmp-ups -V
Network UPS Tools - Generic SNMP UPS driver 1.31 (2.8.2.815.11-826-g717229874)

# NEW PATTERN EXAMPLES:
:; (set -x ;./drivers/snmp-ups -V ; ./drivers/upsdrvctl -V; ./clients/upsc -V ; ./tools/nut-scanner/nut-scanner -V )
+ ./drivers/snmp-ups -V
Network UPS Tools driver 2.8.2.835.23-858-g2a0f7b228 (development iteration after 1.1.1) - Generic SNMP UPS driver 1.31
+ ./drivers/upsdrvctl -V
Network UPS Tools upsdrvctl - UPS driver controller 2.8.2.835.23-858-g2a0f7b228 (development iteration after 1.1.1)
+ ./clients/upsc -V
Network UPS Tools upsc 2.8.2.835.23-858-g2a0f7b228 (development iteration after 1.1.1)
+ ./tools/nut-scanner/nut-scanner -V
Network UPS Tools nut-scanner 2.8.2.835.23-858-g2a0f7b228 (development iteration after 1.1.1)

NOTE: I wonder if these changes can facilitate work on #2097, e.g. to separate a common-version.c with all code referencing NUT version macros to produce a .la file of its own, and linked almost everywhere libcommon.la is now - in places that those version methods are actually used. This would make a version string change a problem of a smaller object file recompilation and then just relinking of its real consumers (compared to several libcommon*.la variants used now, see #2584, with a change in common.o - whether through its sources or nut_version.h - requiring at least a relink of almost every NUT binary).

…programs to print_banner_once() [networkupstools#2573]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…ayout there [networkupstools#2573]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
… "-V" handling [networkupstools#2573]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…g program versions [networkupstools#2573]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…programs to describe_NUT_VERSION_once() [networkupstools#2573]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…ON_once() rather than directly UPS_VERSION [networkupstools#2573]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…with its copy of describe_NUT_VERSION_once() instead of large code chunk in the program [networkupstools#2573]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…pass it to print_banner_once() and show_usage() [networkupstools#2573]

Also update tools/nut-scanner/Makefile.am to have the symbols in libnutscan

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
… follow common NUT pattern [networkupstools#2573]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…use of print_banner_once() [networkupstools#2375]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…help and new standalone option) [networkupstools#2573]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
… CLI option

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…T_VERSION_once() copy of the code [networkupstools#2573]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…(include)

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…IX_THREAD_SAFE_FUNCTIONS

It seems C++ builds using NUT config.h => timehead.h on WIN32 struggle
uniquely (as C ones did not) with alleged redefinition of localtime_r()
and gmtime_r() which is in fact optionally present in headers but not
found by linking tests in AC_CHECK_FUNCS().

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…time methods

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
… localtime_r() etc.

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
@jimklimov jimklimov added bug Windows nut-scanner refactor/fightwarn PR or issue proposal to improve code maintainability without functional changes, or to fix warnings service/daemon start/stop General subject for starting and stopping NUT daemons (drivers, server, monitor); also BG/FG/Debug cross-builds portability We want NUT to build and run everywhere possible labels Aug 5, 2024
@jimklimov jimklimov added the nutconf NUT configuration library and tool label Aug 5, 2024
@jimklimov jimklimov added this to the 2.8.3 milestone Aug 5, 2024
@jimklimov jimklimov changed the title Fix uses of banner_is_disabled() to not preclude -V printouts, common formation of the banner string, detection of time.h methods Fix uses of banner_is_disabled() to not preclude -V printouts; common formation of the banner string; better detection of time.h methods Aug 5, 2024
@AppVeyorBot

This comment was marked as resolved.

… builds [networkupstools#2583, networkupstools#1611]

Partially inspired by /mingw64/include/time.h

NOTE: Unlike linux+mingw cross-builds, the semi-native ones on
Windows with MSYS2 do not enforce _POSIX_THREAD_SAFE_FUNCTIONS
and so can lack the optional declarations in the file above.

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
…WIN32 fallbacks [networkupstools#1611, networkupstools#2583]

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
jimklimov added a commit to jimklimov/nut that referenced this pull request Aug 5, 2024
@AppVeyorBot
Copy link

@jimklimov jimklimov merged commit 3679d49 into networkupstools:master Aug 5, 2024
@jimklimov jimklimov deleted the issue-2573 branch August 5, 2024 21:12
jimklimov added a commit that referenced this pull request Sep 13, 2024
…me, only mention "driver" if needed (once) [#2583]

Example change:

* Network UPS Tools driver 2.8.2.1064-1064-g501bbdc62 (development iteration after 2.8.2) - network XML UPS 0.46
* Network UPS Tools 2.8.2.1064-1064-g501bbdc62 (development iteration after 2.8.2) - network XML UPS driver 0.46

Compare to older versions' markup where NUT version tailed in the end
(generally fixed by PR #2583 due to possible nested parentheses in dev builds):

* Network UPS Tools - Generic HID driver 0.53 (2.8.2)

...and to other non-driver programs now, which generally do print their
program name/type after NUT before version:

* Network UPS Tools upsmon 2.8.2.1064-1064-g501bbdc62 (development iteration after 2.8.2)

Signed-off-by: Jim Klimov <jimklimov+nut@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug cross-builds nut-scanner nutconf NUT configuration library and tool portability We want NUT to build and run everywhere possible refactor/fightwarn PR or issue proposal to improve code maintainability without functional changes, or to fix warnings service/daemon start/stop General subject for starting and stopping NUT daemons (drivers, server, monitor); also BG/FG/Debug Windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Fix uses of banner_is_disabled() to not preclude -V printouts

2 participants