Skip to content

Commit 92ea04e

Browse files
authored
Merge pull request #3300 from jimklimov/issue-3256
Recipe updates for NetBSD 11 support; fix nut-scanner builds --without-threading
2 parents 50ccbd5 + c709708 commit 92ea04e

47 files changed

Lines changed: 563 additions & 244 deletions

Some content is hidden

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

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
/_install_pkgprotodir/
1515
Makefile
1616
Makefile.in
17+
tags
1718

1819
## Parent directory only
1920
/aclocal.m4

Makefile.am

Lines changed: 72 additions & 72 deletions
Large diffs are not rendered by default.

NEWS.adoc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,12 @@ https://github.com/networkupstools/nut/milestone/12
9797
not normally get into those code paths with the `x*()` methods which
9898
should bail out and abort the program with a common error message when
9999
an allocation fails. [#3293]
100+
* We have long abstracted `(s)size_t` value printing in debug logs etc.
101+
using `PRIuSIZE` and similar macros. They fell back to `"%zu"` when not
102+
provided otherwise, but not all platforms actually deliver these format
103+
characters. Now it is evaluated at `configure` time (to check that the
104+
characters may be used), and if not -- during `nut_stdint.h` parsing to
105+
fit known `int`/`long`/`long long` types. [#3300]
100106

101107
- NUT for Windows specific updates:
102108
* Revised detection of (relative) paths to program and configuration files
@@ -429,11 +435,22 @@ several `FSD` notifications into one executed action. [PR #3097]
429435
* Fixed `m4/ax_realpath_lib.m4` up with more ways to try and gauge the
430436
build-time library name from linker/compiler, to improve the chances
431437
that `nut-scanner` would find them. [#3293]
438+
* Added an option to (primarily) `--disable-threading` for systems with
439+
detected but broken `libpthread` support, or to test alternate code
440+
paths during development or in CI. [#3300]
432441

433442
- Recipes, CI and helper script updates not classified above:
434443
* Fixed CI recipes for PyPI publication of PyNUT(Client) module to also
435444
include the source distribution (was posted for NUT v2.8.1 and v2.8.2
436445
tagged releases, but absent for v2.8.3 and v2.8.4). [#3056]
446+
* A new version of BSD `make` in NetBSD 11 (Beta) aka `bmake` in some other
447+
operating systems, complains about some of our sub-`$(MAKE)` calls despite
448+
the explicit `+` prefix in corresponding lines, possibly because that call
449+
happens not directly in a rule definition, but in a substituted shell code
450+
snippet. The recommended workaround was to add a "Special Source" called
451+
`.MAKE` to let the tool know that we expect sub-makes in that recipe.
452+
However, *other* `make` implementations do not know about this token,
453+
so its support is tried and detected at `configure` time. [PR #3300]
437454
* Updated `make spellcheck` to help avoid asciidoc admonition blocks with
438455
visually invalid sentences (after rendering as a box in HTML or PDF).
439456
[#3077]

UPGRADING.adoc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,10 @@ Changes from 2.8.4 to 2.8.5
125125
updated, either to explicitly package the binding for several versions,
126126
or to not-deliver files no longer installed into the prototype area. [#1792]
127127
128+
- Added a `configure` script option to (primarily) `--disable-threading`
129+
for systems with detected but broken `libpthread` support, which can
130+
cause `nut-scanner` to crash while loading system libraries. [#3300]
131+
128132
- Introduced a new driver category for interaction with OS-reported UPS
129133
devices via D-Bus, with the `nut-upower` driver as the first implementation.
130134
This driver requires `glib-2.0` and `gio-2.0` development libraries to be

clients/Makefile.am

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ $(top_builddir)/common/libcommon.la \
2323
$(top_builddir)/common/libcommonclient.la \
2424
$(top_builddir)/common/libcommonversion.la \
2525
$(top_builddir)/common/libcommonstrjson.la \
26-
$(top_builddir)/common/libparseconf.la: dummy
26+
$(top_builddir)/common/libparseconf.la: dummy @dotMAKE@
2727
+@cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F)
2828

2929
# Builds from root dir arrange stuff decently. Make sure parallel builds
@@ -39,7 +39,7 @@ LDADD_CLIENT =
3939
if ENABLE_SHARED_PRIVATE_LIBS
4040
$(top_builddir)/common/libcommonversion-private.la \
4141
$(top_builddir)/common/libnutprivate-@NUT_SOURCE_GITREV_SEMVER_UNDERSCORES@-common-all.la \
42-
$(top_builddir)/common/libnutprivate-@NUT_SOURCE_GITREV_SEMVER_UNDERSCORES@-common-client.la: dummy
42+
$(top_builddir)/common/libnutprivate-@NUT_SOURCE_GITREV_SEMVER_UNDERSCORES@-common-client.la: dummy @dotMAKE@
4343
+@cd $(@D) && $(MAKE) $(AM_MAKEFLAGS) $(@F)
4444

4545
$(top_builddir)/common/libcommonversion-private.la: $(top_builddir)/include/nut_version.h

common/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ else !BUILDING_IN_TREE
9292
BUILT_SOURCES = common-nut_version.c
9393
endif !BUILDING_IN_TREE
9494

95-
$(top_builddir)/include/nut_version.h:
95+
$(top_builddir)/include/nut_version.h: @dotMAKE@
9696
+@if [ -s '$@' ] && ( [ x"$(NUT_VERSION_H_GENERATED)" = xtrue ] || [ x"$${NUT_VERSION_H_GENERATED}" = xtrue ] ) ; then \
9797
if [ x"$(MAINTAINER_GENERATE_HEADER_DEBUG)" = xyes ] ; then \
9898
echo "=== SKIP (common) $@ (NUT_VERSION_H_GENERATED makevar=$(NUT_VERSION_H_GENERATED) shellvar=$${NUT_VERSION_H_GENERATED})" >&2; \

common/common.c

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3767,7 +3767,13 @@ char * mkstr_dynamic(const char *fmt_dynamic, const char *fmt_reference, ...)
37673767
static void vupslog(int priority, const char *fmt, va_list va, int use_strerror)
37683768
{
37693769
int ret, errno_orig = errno;
3770+
#ifdef HAVE_VA_COPY_VARIANT
3771+
size_t bufsize = 128;
3772+
#else
3773+
/* err on the safe(r) side, as re-runs can truncate
3774+
* the output when varargs are re-used */
37703775
size_t bufsize = LARGEBUF;
3776+
#endif
37713777
char *buf = (char *)xcalloc(bufsize, sizeof(char));
37723778

37733779
/* Be pedantic about our limitations */
@@ -3827,7 +3833,7 @@ static void vupslog(int priority, const char *fmt, va_list va, int use_strerror)
38273833
* Based on https://stackoverflow.com/a/72981237/4715872
38283834
*/
38293835
if (bufsize < SIZE_MAX/2) {
3830-
size_t newbufsize = bufsize*2;
3836+
size_t newbufsize = bufsize < LARGEBUF ? LARGEBUF : bufsize*2;
38313837
if (ret > 0) {
38323838
/* Be generous, we snprintfcat() some
38333839
* suffixes, prefix a timestamp, etc. */
@@ -4794,10 +4800,14 @@ static void nut_free_search_paths(void) {
47944800
}
47954801

47964802
if (search_paths != search_paths_builtin) {
4803+
#if HAVE_DECL_REALPATH
47974804
size_t i;
47984805
for (i = 0; search_paths[i] != NULL; i++) {
4806+
upsdebugx(7, "%s: freeing search_paths[%" PRIuSIZE "]: '%s'",
4807+
__func__, i, NUT_STRARG(search_paths[i]));
47994808
free((char *)search_paths[i]);
48004809
}
4810+
#endif /* else: curated selection of pointers to some of the built-in strings */
48014811
free(search_paths);
48024812
search_paths = search_paths_builtin;
48034813
}
@@ -4819,10 +4829,17 @@ void nut_prepare_search_paths(void) {
48194829
size_t count_builtin = 0, count_filtered = 0, i, j, index = 0;
48204830
const char ** filtered_search_paths;
48214831
DIR *dp;
4832+
#if HAVE_DECL_REALPATH
4833+
/* Per docs, buffer must be at least PATH_MAX bytes */
4834+
char realpath_buf[NUT_PATH_MAX + 1] = {0}, *realpath_dirname = NULL;
4835+
#endif
48224836

48234837
/* As a starting point, allow at least as many items as before */
48244838
/* TODO: somehow extend (xrealloc?) if we mix other paths later */
4825-
for (i = 0; search_paths_builtin[i] != NULL; i++) {}
4839+
for (i = 0; search_paths_builtin[i] != NULL; i++) {
4840+
/* Different way of printing with minimal crash-ability on older systems */
4841+
upsdebugx(7, "counting search_paths_builtin[%d] : %s", (int)i, NUT_STRARG(search_paths_builtin[i]));
4842+
}
48264843
count_builtin = i + 1; /* +1 for the NULL */
48274844

48284845
/* Bytes inside should all be zeroed... */
@@ -4834,22 +4851,35 @@ void nut_prepare_search_paths(void) {
48344851
int dupe = 0;
48354852
const char *dirname = search_paths_builtin[i];
48364853

4854+
upsdebugx(7, "%s: checking search_paths_builtin[%" PRIuSIZE " of %" PRIuSIZE "] : %s",
4855+
__func__, i, count_builtin - 1, NUT_STRARG(dirname));
48374856
if ((dp = opendir(dirname)) == NULL) {
48384857
upsdebugx(5, "%s: SKIP "
48394858
"unreachable directory #%" PRIuSIZE " : %s",
4840-
__func__, index++, dirname);
4859+
__func__, index, NUT_STRARG(dirname));
4860+
index++;
48414861
continue;
48424862
}
48434863
index++;
48444864

48454865
#if HAVE_DECL_REALPATH
48464866
/* allocates the buffer we free() later */
4847-
dirname = (const char *)realpath(dirname, NULL);
4867+
upsdebugx(7, "%s: call realpath()", __func__);
4868+
errno = 0;
4869+
realpath_dirname = realpath(dirname, realpath_buf);
4870+
if (errno || !realpath_dirname)
4871+
upsdebug_with_errno(7, "%s: realpath() failed and returned: %s", __func__, NUT_STRARG(realpath_dirname));
4872+
else
4873+
upsdebugx(7, "%s: realpath() returned: %s", __func__, NUT_STRARG(realpath_dirname));
4874+
if (realpath_dirname)
4875+
dirname = (const char *)realpath_dirname;
48484876
#endif
48494877

48504878
/* Revise for duplicates */
48514879
/* Note: (count_filtered == 0) means first existing dir seen, no hassle */
48524880
for (j = 0; j < count_filtered; j++) {
4881+
upsdebugx(7, "%s: check for duplicates filtered_search_paths[%" PRIuSIZE " of %" PRIuSIZE "] : %s",
4882+
__func__, j, count_filtered, NUT_STRARG(filtered_search_paths[j]));
48534883
if (!strcmp(filtered_search_paths[j], dirname)) {
48544884
#if HAVE_DECL_REALPATH
48554885
if (strcmp(search_paths_builtin[i], dirname)) {
@@ -4866,7 +4896,6 @@ void nut_prepare_search_paths(void) {
48664896

48674897
dupe = 1;
48684898
#if HAVE_DECL_REALPATH
4869-
free((char *)dirname);
48704899
/* Have some valid value, for kicks (likely
48714900
* to be ignored in the code path below) */
48724901
dirname = search_paths_builtin[i];
@@ -4879,9 +4908,10 @@ void nut_prepare_search_paths(void) {
48794908
upsdebugx(5, "%s: ADD[#%" PRIuSIZE "] "
48804909
"existing unique directory: %s",
48814910
__func__, count_filtered, dirname);
4882-
#if !HAVE_DECL_REALPATH
4883-
/* Make a copy of table entry, else we have
4884-
* a dynamic result of realpath() made above.
4911+
#if HAVE_DECL_REALPATH
4912+
/* Make a copy of table entry, or the buffer
4913+
* with a result of realpath() made above,
4914+
* to eventually conststently free().
48854915
*/
48864916
dirname = (const char *)xstrdup(dirname);
48874917
#endif
@@ -4984,7 +5014,7 @@ static char * get_libname_in_dir(const char* base_libname, size_t base_libname_l
49845014
char current_test_path[NUT_PATH_MAX + 1];
49855015

49865016
upsdebugx(3, "%s('%s', %" PRIuSIZE ", '%s', %i): Entering method...",
4987-
__func__, base_libname, base_libname_length, dirname, index);
5017+
__func__, NUT_STRARG(base_libname), base_libname_length, NUT_STRARG(dirname), index);
49885018

49895019
memset(current_test_path, 0, sizeof(current_test_path));
49905020

@@ -5117,7 +5147,7 @@ static char * get_libname_in_pathset(const char* base_libname, size_t base_libna
51175147
/* First call to tokenization passes the string, others pass NULL */
51185148
pathset_tmp = xstrdup(pathset);
51195149
upsdebugx(4, "%s: Looking for lib %s in a colon-separated path set",
5120-
__func__, base_libname);
5150+
__func__, NUT_STRARG(base_libname));
51215151
while (NULL != (onedir = strtok( (onedir ? NULL : pathset_tmp), ":" ))) {
51225152
libname_path = get_libname_in_dir(base_libname, base_libname_length, onedir, (*counter)++);
51235153
if (libname_path != NULL)
@@ -5153,7 +5183,7 @@ char * get_libname(const char* base_libname)
51535183
size_t base_libname_length = strlen(base_libname);
51545184
struct stat st;
51555185

5156-
upsdebugx(3, "%s('%s'): Entering method...", __func__, base_libname);
5186+
upsdebugx(3, "%s('%s'): Entering method...", __func__, NUT_STRARG(base_libname));
51575187

51585188
/* First, check for an exact hit by absolute/relative path
51595189
* if `base_libname` includes path separator character(s) */

conf/Makefile.am

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,20 @@ SPELLCHECK_SRC = $(dist_sysconf_DATA) \
3737
# We also have to export some variables that may be tainted by relative
3838
# paths when parsing the other makefile (e.g. MKDIR_P that may be defined
3939
# via expanded $(top_builddir)/install-sh):
40-
#%-spellchecked: % Makefile.am $(top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT)
40+
#%-spellchecked: % Makefile.am $(top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT) @dotMAKE@
4141
# +$(MAKE) -s -f $(top_builddir)/docs/Makefile $(AM_MAKEFLAGS) MKDIR_P="$(MKDIR_P)" builddir="$(builddir)" srcdir="$(srcdir)" top_builddir="$(top_builddir)" top_srcdir="$(top_srcdir)" SPELLCHECK_SRC_ONE="$<" SPELLCHECK_SRCDIR="$(srcdir)" SPELLCHECK_BUILDDIR="$(builddir)" $@
4242

4343
# NOTE: Portable suffix rules do not allow prerequisites, so we shim them here
4444
# by a wildcard target in case the make implementation can put the two together.
4545
*-spellchecked: Makefile.am $(top_srcdir)/docs/Makefile.am $(abs_srcdir)/$(NUT_SPELL_DICT)
4646

47-
.sample.sample-spellchecked:
47+
.sample.sample-spellchecked: @dotMAKE@
4848
+$(MAKE) -s -f $(top_builddir)/docs/Makefile $(AM_MAKEFLAGS) MKDIR_P="$(MKDIR_P)" builddir="$(builddir)" srcdir="$(srcdir)" top_builddir="$(top_builddir)" top_srcdir="$(top_srcdir)" SPELLCHECK_SRC_ONE="$<" SPELLCHECK_SRCDIR="$(srcdir)" SPELLCHECK_BUILDDIR="$(builddir)" $@
4949

50-
.in.in-spellchecked:
50+
.in.in-spellchecked: @dotMAKE@
5151
+$(MAKE) -s -f $(top_builddir)/docs/Makefile $(AM_MAKEFLAGS) MKDIR_P="$(MKDIR_P)" builddir="$(builddir)" srcdir="$(srcdir)" top_builddir="$(top_builddir)" top_srcdir="$(top_srcdir)" SPELLCHECK_SRC_ONE="$<" SPELLCHECK_SRCDIR="$(srcdir)" SPELLCHECK_BUILDDIR="$(builddir)" $@
5252

53-
spellcheck spellcheck-interactive spellcheck-sortdict:
53+
spellcheck spellcheck-interactive spellcheck-sortdict: @dotMAKE@
5454
+$(MAKE) -f $(top_builddir)/docs/Makefile $(AM_MAKEFLAGS) MKDIR_P="$(MKDIR_P)" builddir="$(builddir)" srcdir="$(srcdir)" top_builddir="$(top_builddir)" top_srcdir="$(top_srcdir)" SPELLCHECK_SRC="$(SPELLCHECK_SRC)" SPELLCHECK_SRCDIR="$(srcdir)" SPELLCHECK_BUILDDIR="$(builddir)" $@
5555

5656

0 commit comments

Comments
 (0)