Skip to content

Commit 55dfd0b

Browse files
authored
Merge 9bed9e3 into a630434
2 parents a630434 + 9bed9e3 commit 55dfd0b

27 files changed

Lines changed: 3424 additions & 3030 deletions

Makefile.am

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,22 +136,22 @@ install-fanout-cleanup: install-recursive @dotMAKE@
136136
# Called from generated-sources-with-a-touch:
137137
touch-include-all-nut_version-generated.timestamp:
138138
@[ -s include/nut_version.h ]
139-
@touch -r include/nut_version.h -d '-10 seconds' include/.all.nut_version-generated.timestamp && exit ; \
139+
@touch -r include/nut_version.h -d '-10 seconds' include/.all.nut_version-generated.timestamp 2>/dev/null && exit ; \
140140
touch -d '1970-01-01T00:00:00' include/.all.nut_version-generated.timestamp && exit ; \
141141
touch include/.all.nut_version-generated.timestamp
142142

143143
touch-clients-all-libupsclient_version-generated.timestamp:
144144
@[ -s clients/libupsclient-version.h ]
145-
@touch -r clients/libupsclient-version.h -d '-10 seconds' clients/.all.libupsclient_version-generated.timestamp && exit ; \
145+
@touch -r clients/libupsclient-version.h -d '-10 seconds' clients/.all.libupsclient_version-generated.timestamp 2>/dev/null && exit ; \
146146
touch -d '1970-01-01T00:00:00' clients/.all.libupsclient_version-generated.timestamp && exit ; \
147147
touch clients/.all.libupsclient_version-generated.timestamp
148148

149149
touch-docs-man-all-linkman-generated.timestamp:
150150
@[ -s docs/man/linkman-driver-names.txt ] && [ -s docs/man/linkman-drivertool-names.txt ]
151151
@if test -n "`find docs/man/linkman-driver-names.txt -newer docs/man/linkman-drivertool-names.txt`" ; then \
152-
touch -r docs/man/linkman-drivertool-names.txt -d '-10 seconds' docs/man/.all.nut_linkman-generated.timestamp && exit ; \
152+
touch -r docs/man/linkman-drivertool-names.txt -d '-10 seconds' docs/man/.all.nut_linkman-generated.timestamp 2>/dev/null && exit ; \
153153
else \
154-
touch -r docs/man/linkman-driver-names.txt -d '-10 seconds' docs/man/.all.nut_linkman-generated.timestamp && exit ; \
154+
touch -r docs/man/linkman-driver-names.txt -d '-10 seconds' docs/man/.all.nut_linkman-generated.timestamp 2>/dev/null && exit ; \
155155
fi ; \
156156
touch -d '1970-01-01T00:00:00' docs/man/.all.nut_linkman-generated.timestamp && exit ; \
157157
touch docs/man/.all.nut_linkman-generated.timestamp

ci_build.adoc

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,24 @@ It can be stored outside of the build area(s), under `${CI_CACHE_NUT_BASEDIR}`
106106
by caller (e.g. via `~/.profile` of a developer) or guessed from environment
107107
variables typical for CI runs.
108108
109+
Note there is also a separate `DO_USE_NUTCI_CACHE_DEBUG=yes` (or `...=first`)
110+
toggle, which aims to keep a copy of not only the `config.cache`, but also of
111+
`config.log` and `config.h` files, as well as a copy of the help text from
112+
`configure` script, from a first run with new cache hash for troubleshooting.
113+
114+
A further `DO_USE_NUTCI_CACHE_DEBUG=each` keeps such files time-stamped, from
115+
every run (primarily to help determine if re-runs do modify some detection
116+
results due to mis-interpretation of cached data -- i.e. to help fix the `m4`
117+
scripts and/or `configure.ac` source file).
118+
119+
WARNING: It is up to the caller (developer, CI) to ensure that third-party
120+
dependencies and tools (and their flags delivered by `pkg-config`, or module
121+
paths for interpreted languages, etc.) remain the same between cached runs.
122+
109123
If something acts up, or the build environment changes invisibly to the
110124
script, an `export DO_CLEAN_NUTCI_CACHE_BEFORE=yes` (or a more targeted
111-
`DO_CLEAN_AUTOCONF_CACHE_BEFORE`, since NIT uses similar logic and general
112-
toggle to retain generated test certificates) should fix that.
125+
`export DO_CLEAN_AUTOCONF_CACHE_BEFORE=yes`, since NIT uses similar logic
126+
and general toggle to retain generated test certificates) should fix that.
113127
114128
You can also always nuke the `${CI_CACHE_NUT_BASEDIR}` directory, or the
115129
`AUTOCONF_*` subdirectories and stale lock files under it.

ci_build.sh

Lines changed: 65 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,14 +1292,39 @@ configure_nut() {
12921292
"${CONFIG_OPTS[@]}" \
12931293
&& echo "$0: configure phase complete (0)" >&2 \
12941294
&& {
1295-
if [ x"${DO_USE_AUTOCONF_CACHE}" = xyes ] && [ x"${DO_USE_AUTOCONF_CACHE_DEBUG}" = xyes ] && [ -n "${CI_CACHE_NUT_HASHDIR_CFG_OPT}" ] && [ -s "${CI_CACHE_NUT_HASHDIR_CFG}/config.cache" ] ; then
1296-
if [ x = x"`cat \"${CI_CACHE_NUT_HASHDIR_CFG}/config.log\" \"${CI_CACHE_NUT_HASHDIR_CFG}/config.h\"`" ] ; then
1297-
# Stash a copy to track evolution:
1298-
cp -pf "${CI_CACHE_NUT_HASHDIR_CFG}/config.cache" "${CI_CACHE_NUT_HASHDIR_CFG}/config.cache.orig"
1299-
# Populate on first run (may cost 1-2Mb):
1300-
cp -pf config.log "${CI_CACHE_NUT_HASHDIR_CFG}/"
1301-
cp -pf include/config.h "${CI_CACHE_NUT_HASHDIR_CFG}/"
1302-
fi
1295+
if [ x"${DO_USE_AUTOCONF_CACHE}" = xyes ] \
1296+
&& [ -n "${CI_CACHE_NUT_HASHDIR_CFG_OPT}" ] \
1297+
&& [ -s "${CI_CACHE_NUT_HASHDIR_CFG}/config.cache" ] \
1298+
; then
1299+
case x"${DO_USE_AUTOCONF_CACHE_DEBUG}" in
1300+
xyes|xfirst)
1301+
if [ x = x"`cat \"${CI_CACHE_NUT_HASHDIR_CFG}/config.log\" \"${CI_CACHE_NUT_HASHDIR_CFG}/config.h\"`" ] ; then
1302+
# Stash a copy to track evolution:
1303+
cp -pf "${CI_CACHE_NUT_HASHDIR_CFG}/config.cache" "${CI_CACHE_NUT_HASHDIR_CFG}/config.cache.orig"
1304+
# Populate on first run (may cost 1-2Mb):
1305+
cp -pf config.log "${CI_CACHE_NUT_HASHDIR_CFG}/"
1306+
cp -pf include/config.h "${CI_CACHE_NUT_HASHDIR_CFG}/"
1307+
fi
1308+
1309+
# Make sure all args are declared outside cached logic:
1310+
$CONFIGURE_SCRIPT --help > "${CI_CACHE_NUT_HASHDIR_CFG}/config.help" 2>&1
1311+
;;
1312+
xeach)
1313+
TS="`date '+%s'`" && [ -n "$TS" ] && [ "$TS" -gt 0 ] \
1314+
|| { TS="`date | tr -d ':' | tr -d ' '`" && [ -n "$TS" ] ; } \
1315+
|| TS=$$
1316+
1317+
for F in \
1318+
"${CI_CACHE_NUT_HASHDIR_CFG}/config.cache" \
1319+
config.log include/config.h \
1320+
; do
1321+
cp -pf "$F" "${CI_CACHE_NUT_HASHDIR_CFG}/`basename \"$F\"`.$TS"
1322+
done
1323+
1324+
# Make sure all args are declared outside cached logic:
1325+
$CONFIGURE_SCRIPT --help > "${CI_CACHE_NUT_HASHDIR_CFG}/config.help.$TS" 2>&1
1326+
;;
1327+
esac
13031328
fi
13041329
} && return 0 \
13051330
|| { RES_CFG=$?
@@ -2087,6 +2112,22 @@ default|default-alldrv|default-alldrv:no-distcheck|default-all-errors|default-al
20872112
CONFIG_OPTS+=("CC=${CC}")
20882113
CONFIG_OPTS+=("CXX=${CXX}")
20892114
CONFIG_OPTS+=("CPP=${CPP}")
2115+
2116+
# Do not let autoconf-cached re-runs (re-running the configure script
2117+
# due to a `make` with changed *.m4, *.am or configure.ac sources)
2118+
# complain that CCACHE_* vars were not previously set. This hassle
2119+
# comes with use of AC_ARG_VAR to mark "precious" arguments:
2120+
CONFIG_OPTS+=("CCACHE_NAMESPACE=${CCACHE_NAMESPACE}")
2121+
CONFIG_OPTS+=("CCACHE_BASEDIR=${CCACHE_BASEDIR}")
2122+
CONFIG_OPTS+=("CCACHE_DIR=${CCACHE_DIR}")
2123+
CONFIG_OPTS+=("CCACHE_PATH=${CCACHE_PATH}")
2124+
else
2125+
# Still have them declared; the configure script will probably parse
2126+
# them as empty/undefined and re-evaluate if situation warrants that:
2127+
CONFIG_OPTS+=("CCACHE_NAMESPACE=")
2128+
CONFIG_OPTS+=("CCACHE_BASEDIR=")
2129+
CONFIG_OPTS+=("CCACHE_DIR=")
2130+
CONFIG_OPTS+=("CCACHE_PATH=")
20902131
fi
20912132
20922133
# Build and check this project; note that zprojects always have an autogen.sh
@@ -3111,6 +3152,22 @@ bindings)
31113152
CONFIG_OPTS+=("CC=${CC}")
31123153
CONFIG_OPTS+=("CXX=${CXX}")
31133154
CONFIG_OPTS+=("CPP=${CPP}")
3155+
3156+
# Do not let autoconf-cached re-runs (re-running the configure script
3157+
# due to a `make` with changed *.m4, *.am or configure.ac sources)
3158+
# complain that CCACHE_* vars were not previously set. This hassle
3159+
# comes with use of AC_ARG_VAR to mark "precious" arguments:
3160+
CONFIG_OPTS+=("CCACHE_NAMESPACE=${CCACHE_NAMESPACE}")
3161+
CONFIG_OPTS+=("CCACHE_BASEDIR=${CCACHE_BASEDIR}")
3162+
CONFIG_OPTS+=("CCACHE_DIR=${CCACHE_DIR}")
3163+
CONFIG_OPTS+=("CCACHE_PATH=${CCACHE_PATH}")
3164+
else
3165+
# Still have them declared; the configure script will probably parse
3166+
# them as empty/undefined and re-evaluate if situation warrants that:
3167+
CONFIG_OPTS+=("CCACHE_NAMESPACE=")
3168+
CONFIG_OPTS+=("CCACHE_BASEDIR=")
3169+
CONFIG_OPTS+=("CCACHE_DIR=")
3170+
CONFIG_OPTS+=("CCACHE_PATH=")
31143171
fi
31153172
31163173
# If detect_platform_PKG_CONFIG_PATH_and_FLAGS() customized anything here,

common/common.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3183,12 +3183,17 @@ int upsnotify(upsnotify_state_t state, const char *fmt, ...)
31833183
* a reload action for Type=notify-reload; for more details see
31843184
* https://github.com/systemd/systemd/blob/main/src/core/service.c#L2618
31853185
*/
3186-
struct timespec monoclock_ts;
3187-
int got_monoclock = clock_gettime(CLOCK_MONOTONIC, &monoclock_ts);
3186+
struct timespec monoclock_ts;
3187+
int got_monoclock = clock_gettime(CLOCK_MONOTONIC, &monoclock_ts);
31883188
# endif /* HAVE_CLOCK_GETTIME && HAVE_CLOCK_MONOTONIC */
31893189
# endif /* HAVE_SD_NOTIFY */
31903190
#endif /* WITH_LIBSYSTEMD */
31913191

3192+
/* Some code paths (build configurations/goals) do not involve these,
3193+
* but easier to make-believe that we do than pepper code with ifdefs */
3194+
NUT_UNUSED_VARIABLE(buf);
3195+
NUT_UNUSED_VARIABLE(msglen);
3196+
31923197
/* Were we asked to be quiet on the console? */
31933198
if (upsnotify_report_verbosity < 0) {
31943199
char *quiet_init = getenv("NUT_QUIET_INIT_UPSNOTIFY");
@@ -3258,8 +3263,6 @@ int upsnotify(upsnotify_state_t state, const char *fmt, ...)
32583263

32593264
#if defined(WITH_LIBSYSTEMD) && (WITH_LIBSYSTEMD)
32603265
# if defined(WITHOUT_LIBSYSTEMD) && (WITHOUT_LIBSYSTEMD)
3261-
NUT_UNUSED_VARIABLE(buf);
3262-
NUT_UNUSED_VARIABLE(msglen);
32633266
if (!upsnotify_reported_disabled_systemd) {
32643267
upsdebugx(upsnotify_report_verbosity,
32653268
"%s: notify about state %s with libsystemd: "

0 commit comments

Comments
 (0)