Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' as of 2024-05-18 into FTY
Browse files Browse the repository at this point in the history
Signed-off-by: Jim Klimov <[email protected]>
  • Loading branch information
jimklimov committed May 18, 2024
2 parents 5b859e6 + 9f8dc40 commit c405cec
Show file tree
Hide file tree
Showing 170 changed files with 6,868 additions and 1,244 deletions.
4 changes: 4 additions & 0 deletions .github/codeql/codeql-config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# For interpreted languages:
paths:
- scripts/python/module
- scripts/python/app
2 changes: 1 addition & 1 deletion .github/workflows/PyNUTClient.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ jobs:
{ TAG_NAME="$(git describe --tags --match 'v[0-9]*.[0-9]*.[0-9]' --exclude '*-signed' --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*')" \
|| TAG_NAME="$(git describe --tags --exclude '*rc*' --exclude '*alpha*' --exclude '*beta*' --exclude '*Windows*' --exclude '*IPM*')" ; } \
&& test -n "${TAG_NAME}" \
|| TAG_NAME="2.8.1-`TZ=UTC date +%s`" ;
|| TAG_NAME="2.8.2-`TZ=UTC date +%s`" ;
fi >&2 ;
TAG_NAME="$(echo "$TAG_NAME" | sed -e 's/^v\([0-9]\)/\1/' -e 's,^.*/,,' -e 's/^v//' -e 's/-g.*$//' -e 's/-/./g')" ;
echo "TAG_NAME=$TAG_NAME" >> $GITHUB_OUTPUT
Expand Down
48 changes: 44 additions & 4 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ on:
jobs:
analyze:
name: Analyze
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
permissions:
actions: read
contents: read
Expand All @@ -32,10 +32,22 @@ jobs:
strategy:
fail-fast: false
matrix:
# https://docs.github.com/en/actions/using-jobs/using-a-matrix-for-your-jobs
language: [ 'cpp' ]
# CodeQL supports [ 'cpp', 'csharp', 'go', 'java', 'javascript', 'python', 'ruby' ]
# Learn more about CodeQL language support at https://aka.ms/codeql-docs/language-support
# TODO: Want to find Python sources to test like with LGTM, see https://github.com/networkupstools/nut/issues/1726
os: ['ubuntu-latest']
# TOTHINK: windows-latest, macos-latest
compiler: ['CC=gcc CXX=g++', 'CC=clang CXX=clang++']
NUT_SSL_VARIANTS: ['no', 'nss', 'openssl']
NUT_USB_VARIANTS: ['no', 'libusb-1.0', 'libusb-0.1']
include:
# Add cell(s) to the matrix, beside the combinatorics made above
- language: 'python'
os: 'ubuntu-latest'
compiler: 'PYTHON=python3'
NUT_SSL_VARIANTS: 'no'
NUT_USB_VARIANTS: 'no'

steps:
- name: Checkout repository
Expand All @@ -52,12 +64,40 @@ jobs:

# Details on CodeQL's query packs refer to : https://docs.github.com/en/code-security/code-scanning/automatically-scanning-your-code-for-vulnerabilities-and-errors/configuring-code-scanning#using-queries-in-ql-packs
# queries: security-extended,security-and-quality
config-file: ./.github/codeql/codeql-config.yml

# https://docs.github.com/en/code-security/code-scanning/creating-an-advanced-setup-for-code-scanning/codeql-code-scanning-for-compiled-languages
- if: matrix.language == 'cpp' && matrix.os == 'ubuntu-latest'
name: NUT CI Prerequisite packages (Ubuntu)
run: |
sudo apt update
case x"${{matrix.compiler}}" in x*clang*) sudo apt install clang ;; x*) sudo apt install gcc g++ ;; esac
sudo apt install libltdl-dev libtool libtool-bin cppcheck ccache libgd-dev libcppunit-dev libsystemd-dev libssl-dev libnss3-dev augeas-tools libaugeas-dev augeas-lenses libusb-dev libusb-1.0-0-dev libmodbus-dev libsnmp-dev libpowerman0-dev libfreeipmi-dev libipmimonitoring-dev libavahi-common-dev libavahi-core-dev libavahi-client-dev libgpiod-dev libneon27-dev libi2c-dev i2c-tools lm-sensors
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v3
#- name: Autobuild
# uses: github/codeql-action/autobuild@v3

#- if: matrix.language == 'cpp'
# name: NUT CI Build (default-all-errors matrix)
# run: |
# BUILD_TYPE=default-all-errors BUILD_SSL_ONCE=true DO_DISTCHECK=no CI_SKIP_CHECK=true CANBUILD_DOCS_ALL=no ${{ matrix.compiler }} NUT_SSL_VARIANTS=${{ matrix.NUT_SSL_VARIANTS }} NUT_USB_VARIANTS=${{ matrix.NUT_USB_VARIANTS }} ./ci_build.sh

#- if: matrix.language == 'cpp'
# name: NUT CI Build (fightwarn-all)
# run: |
# BUILD_TYPE=fightwarn-all ./ci_build.sh

# TOTHINK: Can we prepare the working area once (apt, autogen => containers?)
# and then spread it out for builds and analyses?
# Can ccache be used across builds?
- if: matrix.language == 'cpp'
name: NUT CI Build
run: |
./autogen.sh
./configure --enable-warnings --enable-Werror --enable-Wcolor --with-all=auto --with-dev --without-docs ${{matrix.compiler}} --with-ssl=${{matrix.NUT_SSL_VARIANTS}} --with-usb=${{matrix.NUT_USB_VARIANTS}}
make -s -j 8
# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,12 @@ Makefile.in
/test-driver
*-spellchecked
*-prepped
*.usage-report
*.adoc-parsed
*.adoc*.tmp
*.adoc*.tmp.*
*.txt*.tmp
*.txt*.tmp.*
/cppcheck*.xml
/.ci*.txt*
/.ci*.log
Expand Down
68 changes: 64 additions & 4 deletions Jenkinsfile-dynamatrix
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@ import org.nut.dynamatrix.*;
def dynacfgPipeline = [:]

// NOTE: These can be further disabled or active in different combo specs
// below based on branch names
// below based on branch names. Also note that the values are somewhat
// "inversed" -- e.g. that "disabledSomething = false" means "enable it".
dynacfgPipeline.disableSlowBuildAutotools = false
dynacfgPipeline.disableSlowBuildCIBuild = false
dynacfgPipeline.disableSlowBuildCIBuildExperimental = false
Expand Down Expand Up @@ -270,7 +271,7 @@ import org.nut.dynamatrix.*;

// Imported from jenkins-dynamatrix JSL vars/autotools.groovy:
// a workaround for the cases of curiously missing MAKE envvar...
dynacfgPipeline.buildPhases['distcheck'] = """( if [ x"\${MAKE-}" = x ]; then echo "WARNING: MAKE is somehow unset, defaulting!" >&2; MAKE=make; fi; eval \${CONFIG_ENVVARS} time \${MAKE} \${MAKE_OPTS} distcheck DISTCHECK_FLAGS="\${CONFIG_OPTS}" )"""
dynacfgPipeline.buildPhases['distcheck'] = """( if [ x"\${MAKE-}" = x ]; then echo "WARNING: MAKE is somehow unset, defaulting!" >&2; MAKE=make; fi; eval \${CONFIG_ENVVARS} time \${MAKE} \${MAKE_OPTS} distcheck DISTCHECK_FLAGS=\${CONFIG_OPTS:+\\"\$CONFIG_OPTS\\"} )"""

// Note: shellcheck/spellcheck/... require autotools currently
// or need to be redefined with respective BUILD_TYPE
Expand Down Expand Up @@ -301,7 +302,10 @@ set | sort -n """
}

withEnvOptional(dynacfgPipeline.defaultTools) {
unstashCleanSrc(dynacfgPipeline.stashnameSrc)
stage('Unstash sources') {
unstashCleanSrc(dynacfgPipeline.stashnameSrc)
}

buildMatrixCellCI(dynacfgPipeline, dsbcClone, stageNameClone)
//buildMatrixCellCI(dynacfgPipeline, dsbc, stageName)
}
Expand Down Expand Up @@ -331,7 +335,10 @@ set | sort -n """
}

withEnvOptional(dynacfgPipeline.defaultTools) {
unstashCleanSrc(dynacfgPipeline.stashnameSrc)
stage('Unstash sources') {
unstashCleanSrc(dynacfgPipeline.stashnameSrc)
}

def dynacfgPipeline_ciBuild = dynacfgPipeline.clone()
dynacfgPipeline_ciBuild.buildSystem = 'ci_build.sh'
dynacfgPipeline_ciBuild.buildPhases = [:]
Expand Down Expand Up @@ -437,6 +444,59 @@ set | sort -n """
//'bodyParStages': {}
] // one slowBuild filter configuration, autotools-Wall

,[name: 'Default autotools driven build with default configuration, bitness and warning levels on each NUT CI farm platform (but with fatal warnings as of gnu99/gnu++11, must pass where enabled)',
disabled: dynacfgPipeline.disableSlowBuildAutotools,
//branchRegexSource: ~/^(PR-.+|fightwarn.*)$/,
//branchRegexTarget: dynacfgPipeline.branchStableRegex,
//branchRegexTarget: ~/fightwarn/,
//appliesToChangedFilesRegex: dynacfgPipeline.appliesToChangedFilesRegex_C,
'getParStages': { def dynamatrix, Closure body ->
return dynamatrix.generateBuild([
//commonLabelExpr: dynacfgBase.commonLabelExpr,
//defaultDynamatrixConfig: dynacfgBase.defaultDynamatrixConfig,
requiredNodelabels: [],
excludedNodelabels: [],

dynamatrixAxesVirtualLabelsMap: [
//'BITS': [32, 64],
// 'CSTDVERSION': ['03', '2a'],
//'CSTDVERSION_${KEY}': [ ['c': '03', 'cxx': '03'], ['c': '99', 'cxx': '98'], ['c': '17', 'cxx': '2a'], 'ansi' ],
//'CSTDVERSION_${KEY}': [ ['c': '03', 'cxx': '03'], ['c': '99', 'cxx': '98'], ['c': '17', 'cxx': '2a'] ],
'CSTDVERSION_${KEY}': [ ['c': '99', 'cxx': '11'] ],
'CSTDVARIANT': ['gnu']
],
dynamatrixAxesCommonEnv: [
// One set of several simultaneously exported envvars!
// CONFIG_OPTS are picked up by our dynamatrix configuration
// and substituted into shell "as is" for normal builds
// (so splitting into many tokens), or quoted as a single
// token DISTCHECK_FLAGS in its stage (split by make later).
['LANG=C','LC_ALL=C','TZ=UTC',
'CONFIG_OPTS=--with-all=auto --with-docs=auto --with-ssl=auto --enable-Werror --enable-warnings --disable-Wcolor --enable-silent-rules'
]
],

mergeMode: [ 'dynamatrixAxesVirtualLabelsMap': 'replace', 'excludeCombos': 'merge' ],
allowedFailure: [
dynacfgPipeline.axisCombos_WINDOWS,
dynacfgPipeline.axisCombos_STRICT_C
],
runAllowedFailure: true,
//dynamatrixAxesLabels: ['OS_FAMILY', 'OS_DISTRO', '${COMPILER}VER', 'ARCH${ARCH_BITS}'],
//dynamatrixAxesLabels: [~/^OS/, '${COMPILER}VER', 'ARCH${ARCH_BITS}'],
dynamatrixAxesLabels: [~/^OS_DISTRO/, 'COMPILER'],
excludeCombos: dynacfgPipeline.excludeCombos_DEFAULT_STRICT_C
+ [dynacfgPipeline.axisCombos_WINDOWS_CROSS]
+ [[~/OS_DISTRO=openbsd-6\./, ~/COMPILER=GCC/]]
// Here we picked just OSes and compilers (gcc or clang),
// so exclude systems which have e.g. gcc-4.2.1 which claims
// type range comparison warnings despite pragma fencing.
// gcc-4.8.x on CentOS 7 and Ubuntu 14.04 looks already okay.
], body)
}, // getParStages
//'bodyParStages': {}
] // one slowBuild filter configuration, autotools-everywhere

,[name: 'Various non-docs distchecked target builds with main and ~newest supported C/C++ revisions (must pass on all platforms)',
disabled: dynacfgPipeline.disableSlowBuildCIBuild,
//branchRegexSource: ~/^(PR-.+|fightwarn.*)$/,
Expand Down
72 changes: 58 additions & 14 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,21 @@
# Export certain values for ccache which NUT ci_build.sh can customize,
# to facilitate developer iteration re-runs of "make" later.
# At least GNU and BSD make implementations are okay with this syntax.
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_BASEDIR=@CCACHE_BASEDIR@
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_DIR=@CCACHE_DIR@
@NUT_AM_MAKE_CAN_EXPORT@export CCACHE_PATH=@CCACHE_PATH@
@NUT_AM_MAKE_CAN_EXPORT@export PATH=@PATH_DURING_CONFIGURE@
@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_NAMESPACE@export CCACHE_NAMESPACE=@CCACHE_NAMESPACE@
@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_BASEDIR@export CCACHE_BASEDIR=@CCACHE_BASEDIR@
@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_DIR@export CCACHE_DIR=@CCACHE_DIR@
@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export CCACHE_PATH=@CCACHE_PATH@
@NUT_AM_MAKE_CAN_EXPORT@@NUT_AM_EXPORT_CCACHE_PATH@export PATH=@PATH_DURING_CONFIGURE@

# First target often defines default behavior: all
# We follow up with another pass to `make doc` because our wild recipes
# sometimes preclude generating all of them on the first pass (FIXME!)
# missing e.g. PDF and HTML which then pop up in `make check` footprint,
# or misses a .prep-src-docs stage needed to pattern-make man page files
# with some "make" implementations...
all all-am-local all-local: all-recursive
+@$(MAKE) $(AM_MAKEFLAGS) doc
+@$(MAKE) $(AM_MAKEFLAGS) doc

# include directory for aclocal
ACLOCAL_AMFLAGS = -I m4
Expand Down Expand Up @@ -227,7 +237,7 @@ distclean-local:
spellcheck spellcheck-interactive:
+@RES=0; \
(cd $(builddir)/docs && $(MAKE) $(AM_MAKEFLAGS) -s $(abs_top_builddir)/docs/.prep-src-docs) || RES=$$? ; \
(cd $(builddir)/docs/man && $(MAKE) $(AM_MAKEFLAGS) -s $(abs_top_builddir)/docs/.prep-src-docs) || RES=$$? ; \
(cd $(builddir)/docs/man && $(MAKE) $(AM_MAKEFLAGS) -s $(abs_top_builddir)/docs/man/.prep-src-docs) || RES=$$? ; \
(cd $(builddir)/docs && $(MAKE) $(AM_MAKEFLAGS) -s $@) || RES=$$? ; \
(cd $(builddir)/docs/man && $(MAKE) $(AM_MAKEFLAGS) -s $@) || RES=$$? ; \
(cd $(builddir)/conf && $(MAKE) $(AM_MAKEFLAGS) -s $@) || RES=$$? ; \
Expand All @@ -251,13 +261,15 @@ spellcheck spellcheck-interactive:
# such as PDF generators, so it should only be called at developer's
# discretion, choice and risk. The "check-man" targets covers source
# texts, man pages and HTML rendering of man pages, as enabled by tools.
doc spellcheck-sortdict \
doc spellcheck-sortdict spellcheck-report-dict-usage \
all-docs check-docs \
man all-man man-man check-man man-html all-html:
+cd $(builddir)/docs && $(MAKE) $(AM_MAKEFLAGS) $@
man all-man man-man check-man html-man all-html:
+cd $(abs_top_builddir)/docs && $(MAKE) $(AM_MAKEFLAGS) -s $(abs_top_builddir)/docs/.prep-src-docs
+cd $(abs_top_builddir)/docs/man && $(MAKE) $(AM_MAKEFLAGS) -s $(abs_top_builddir)/docs/man/.prep-src-docs
+cd $(abs_top_builddir)/docs && $(MAKE) $(AM_MAKEFLAGS) $@

INSTALL.nut UPGRADING NEWS README:
+cd $(builddir)/docs && $(MAKE) $(AM_MAKEFLAGS) ../$(@F).adoc-parsed && cp -f ../$(@F).adoc-parsed ../$(@F)
+cd $(abs_top_builddir)/docs && $(MAKE) $(AM_MAKEFLAGS) ../$(@F).adoc-parsed && cp -f ../$(@F).adoc-parsed ../$(@F)

# Workarounds for https://github.com/github/markup/issues/1095
# require direct definition of our attributes in each source
Expand Down Expand Up @@ -412,19 +424,51 @@ dummy-stamp:
ChangeLog: dummy-stamp
+@$(MAKE) $(AM_MAKEFLAGS) $(abs_top_builddir)/ChangeLog

# Be sure to not confuse with a DIST'ed file (and so try to overwrite it):
if WITH_PDF_NONASCII_TITLES
WITH_PDF_NONASCII_TITLES_ENVVAR = WITH_PDF_NONASCII_TITLES=yes
else
WITH_PDF_NONASCII_TITLES_ENVVAR = WITH_PDF_NONASCII_TITLES=no
endif

# Be sure to not confuse with a DIST'ed file (and so try to overwrite it);
# do however avoid re-generating it if already made on a previous pass and
# the Git HEAD pointer (branch) or its actual "index" or "object" database
# did not change since then - meaning the local developer or CI did not
# modify the metadata (subsequent generation of the huge PDF/HTML files
# can cost dearly).
# Note there's a bit more fuss about Git internals which NUT should not
# really care about encapsulation-wise (detection of NUT_GITDIR location
# which may reside elsewhere, e.g. with local repo clones with reference
# repo configuration, or submodules). But this is a Git-crawling target
# anyway, and in the worst case (Git's design changes) we would spend a
# bit of time researching the FS in vain, and go on to re-generate the
# ChangeLog when maybe we should not have - oh well:
$(abs_top_builddir)/ChangeLog: tools/gitlog2changelog.py dummy-stamp
@cd $(abs_top_srcdir) && \
if test -e .git ; then \
CHANGELOG_FILE="$@" $(abs_top_builddir)/tools/gitlog2changelog.py $(GITLOG_START_POINT) || \
{ printf "gitlog2changelog.py failed to generate the ChangeLog.\n\nNOTE: See https://github.com/networkupstools/nut/commits/master for change history.\n\n" > "$@" ; } ; \
NUT_GITDIR=".git" ; if test -r "$${NUT_GITDIR}" -a ! -d "$${NUT_GITDIR}" ; then GD="`grep -E '^gitdir:' "$${NUT_GITDIR}" | sed 's/^gitdir: *//'`" && test -n "$$GD" -a -d "$$GD" && NUT_GITDIR="$$GD" ; fi ; \
if test -s "$@" -a -d "$${NUT_GITDIR}" && test -z "`find "$${NUT_GITDIR}" -newer "$@" 2>/dev/null`" ; then \
echo " DOC-CHANGELOG-GENERATE $@ : SKIP (keep existing)" ; \
echo "Using still-valid ChangeLog file generated earlier from same revision of Git source metadata in '$${NUT_GITDIR}'" >&2 ; \
else \
echo " DOC-CHANGELOG-GENERATE $@" ; \
CHANGELOG_FILE="$@" $(WITH_PDF_NONASCII_TITLES_ENVVAR) $(abs_top_builddir)/tools/gitlog2changelog.py $(GITLOG_START_POINT) || { \
echo " DOC-CHANGELOG-GENERATE $@ : FAILED (non-fatal)" >&2 ; \
printf "gitlog2changelog.py failed to generate the ChangeLog.\n\nNOTE: See https://github.com/networkupstools/nut/commits/master for change history.\n\n" > "$@" ; \
} ; \
fi ; \
else \
if test x"$(abs_top_srcdir)" != x"$(abs_top_builddir)" -a -s ./ChangeLog ; then \
echo " DOC-CHANGELOG-GENERATE $@ : SKIP (keep existing)" ; \
echo "Using distributed ChangeLog file from sources" >&2 ; \
rm -f "$@" || true ; \
cat ./ChangeLog > "$@" ; \
else \
if ! test -s "$@" ; then \
if test -s "$@" ; then \
echo " DOC-CHANGELOG-GENERATE $@ : SKIP (keep existing)" ; \
echo "Using distributed ChangeLog file from sources" >&2 ; \
else \
echo " DOC-CHANGELOG-GENERATE $@ : FAILED (non-fatal)" >&2 ; \
printf "Failed to generate the ChangeLog.\n\nNOTE: See https://github.com/networkupstools/nut/commits/master for change history.\n\n" > "$@" ; \
fi ; \
fi ; \
Expand Down
Loading

0 comments on commit c405cec

Please sign in to comment.