Skip to content

Commit

Permalink
Merge branch 'master' into invt_modbus
Browse files Browse the repository at this point in the history
  • Loading branch information
jimklimov authored Sep 12, 2024
2 parents 29c02d8 + 945b4bb commit 0dc3727
Show file tree
Hide file tree
Showing 360 changed files with 24,550 additions and 4,750 deletions.
134 changes: 109 additions & 25 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,17 @@ jobs:
parameters:
XCODE_VER:
type: string
default: "12.5.1"
# https://circleci.com/docs/using-macos/#supported-xcode-versions-silicon
default: "13.4.1"
CC:
type: string
default: "" # e.g. "clang"
CXX:
type: string
default: "" # e.g. "clang++"
CPP:
type: string
default: "" # e.g. "clang -E"
CC_STDVER:
type: string
default: "" # e.g. "-std=gnu17"
Expand All @@ -39,15 +43,27 @@ jobs:
BREW_MORE:
type: string
default: "" # e.g. "avahi" for all-driver tests
#HOMEBREW_PREFIX:
# Detected below at run-time
# See https://docs.brew.sh/Installation :
# * /opt/homebrew for Apple Silicon,
# * /usr/local for macOS Intel and
# * /home/linuxbrew/.linuxbrew for Linux
# TODO: Find a way to select one of the values based on the platform?
#type: string
#default: "/opt/homebrew" # since July 2024 CircleCI only serves Apple Silicon instances
#default: "/usr/local" # was when CircleCI builders had x86

environment:
CC: << parameters.CC >>
CXX: << parameters.CXX >>
CPP: << parameters.CPP >>
CC_STDVER: << parameters.CC_STDVER >>
CXX_STDVER: << parameters.CXX_STDVER >>
BUILD_TYPE: << parameters.BUILD_TYPE >>
CI_BUILDDIR: << parameters.CI_BUILDDIR >>
BREW_MORE: << parameters.BREW_MORE >>
#HOMEBREW_PREFIX: << parameters.HOMEBREW_PREFIX >>

# Specify the execution environment. You can specify an image from Dockerhub or use one of our Convenience Images from CircleCI's Developer Hub.
# See: https://circleci.com/docs/2.0/configuration-reference/#docker-machine-macos-windows-executor
Expand All @@ -65,25 +81,63 @@ jobs:

# Note: MacOS default /bin/bash 3.x is too old for ci_build.sh
# Brew brings /usr/local/bin/bash 5.x as of this writing
# TODO: Are Binutils needed?
# We also reinstall/relink openssl@3 because asciidoc deps pull
# in openssl@1 and MAYBE they conflict (cause lack of exposed
# symlinks).
- run:
name: "homebrew"
command: |-
HOMEBREW_NO_AUTO_UPDATE=1; export HOMEBREW_NO_AUTO_UPDATE;
brew install ccache bash libtool pkg-config gd libusb neon net-snmp openssl $BREW_MORE #binutils
#HOMEBREW_NO_AUTO_UPDATE=1; export HOMEBREW_NO_AUTO_UPDATE;
brew install ccache bash libtool binutils autoconf automake git m4 \
pkg-config aspell asciidoc docbook-xsl cppunit gd \
libusb neon net-snmp \
nss openssl \
libmodbus freeipmi powerman $BREW_MORE
#brew reinstall openssl@3
if ps -ef | grep -v grep | grep sshd ; then
brew install mc
ifconfig -a || true
fi
# - run:
# name: "homebrew-libtool"
# command: |-
# #find /usr /opt /lib* -name '*ltdl*' -ls 2>/dev/null || true
# brew unlink libtool && brew link libtool
# #find /usr /opt /lib* -name '*ltdl*' -ls 2>/dev/null || true
# https://github.com/Homebrew/legacy-homebrew/issues/15488
- run:
name: "homebrew-relink"
command: |-
#find /usr /opt /lib* -name '*ltdl*' -ls 2>/dev/null || true
brew unlink libtool && brew link libtool
#find /usr /opt /lib* -name '*ltdl*' -ls 2>/dev/null || true
brew info openssl
#brew info openssl@3
#brew info [email protected]
#command -v pkg-config || true
#pkg-config --list-all || true
#HOMEBREW_PREFIX="`brew config | grep HOMEBREW_PREFIX: | awk '{print $2}'`"
#ls -la "${HOMEBREW_PREFIX}/lib/pkgconfig" || true
#ls -la "${HOMEBREW_PREFIX}/include/openssl" || true
#ls -la "${HOMEBREW_PREFIX}/include/openssl"/* || true
#find "${HOMEBREW_PREFIX}"/Cellar/openssl* -ls || true
pkg-config --libs --cflags nss
pkg-config --libs --cflags openssl || {
brew unlink openssl && brew link --force openssl
pkg-config --libs --cflags openssl ; }
brew unlink net-snmp && brew link --force net-snmp
- restore_cache:
keys:
- ccache-{{ .Branch }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}
- ccache-master-{{ arch }}-{{ .Environment.CIRCLE_JOB }}

# Fail fast if we had a problem with prerequisites - this
# situation would likely impact all build branches anyway.
# Requires a Personal API token in the building account:
# https://support.circleci.com/hc/en-us/articles/360052058811-Exit-Build-Early-if-Any-Test-Fails
- run:
name: Fail Fast
when: on_fail
command: |-
echo "Canceling workflow as a step resulted in failure"
curl -X POST --header "Content-Type: application/json" "https://circleci.com/api/v2/workflow/${CIRCLE_WORKFLOW_ID}/cancel?circle-token=${CIRCLE_TOKEN}"
# - run:
# name: "check shell"
# command: /usr/bin/env bash --version || true; command -v bash || true
Expand All @@ -99,14 +153,16 @@ jobs:
# uses of sem_init() and sem_destroy() in nut-scanner.c)
# NOTE: CANBUILD_NIT_TESTS=yes to check if single-executor environments
# do not have a problem with it.
# NOTE: python3.11 is available but broken on some of the workers
# (no homebrew dirs in search path)
- run:
name: "ci_build"
command: |-
CI_CCACHE_SYMLINKDIR="/usr/local/opt/ccache/libexec" \
HOMEBREW_PREFIX="`brew config | grep HOMEBREW_PREFIX: | awk '{print $2}'`" \
CANBUILD_NIT_TESTS=yes \
CFLAGS="$CC_STDVER -Wno-poison-system-directories -Wno-deprecated-declarations" \
CXXFLAGS="$CXX_STDVER -Wno-poison-system-directories" \
LDFLAGS="-L/usr/local/lib" \
CFLAGS="$CC_STDVER" \
CXXFLAGS="$CXX_STDVER" \
PYTHON=python3.12 \
./ci_build.sh
- run:
Expand All @@ -125,53 +181,81 @@ jobs:
- ~/.ccache
key: ccache-{{ .Branch }}-{{ arch }}-{{ .Environment.CIRCLE_JOB }}

- store_artifacts:
path: config.log

- store_artifacts:
path: config.nut_report_feature.log


# Invoke jobs via workflows
# See: https://circleci.com/docs/2.0/configuration-reference/#workflows
workflows:
xcode-workflow:
jobs:
# Note: while "ccache" lists hordes of symlinks to gcc-XXX versions,
# in practice these toolkits are not installed (by default)
# or actually identify as clang

### This scenario is a subset of fightwarn-all below (modulo C standard),
### so disabled to not waste time from free CircleCI allowance limit:
# - osx-xcode:
# name: "gnu17-clang-xcode12_5_1-default-all-errors"
# XCODE_VER: "12.5.1"
# name: "gnu17-clang-xcode13_4_1-default-all-errors"
# XCODE_VER: "13.4.1"
# CC: "clang"
# CXX: "clang++"
# CC_STDVER: "-std=gnu17"
# CXX_STDVER: "-std=gnu++17"

# - osx-xcode:
# name: "gnu11-gcc-xcode13_4_1-out-of-tree"
# CC: "gcc"
# CXX: "g++"
# CC_STDVER: "-std=gnu11"
# CXX_STDVER: "-std=gnu++11"
# # Try an out-of-tree build:
# CI_BUILDDIR: "obj"

# - osx-xcode:
# name: "c99-cxx11-gcc-xcode13_4_1-default-distcheck"
# CC: "gcc"
# CXX: "g++"
# CC_STDVER: "-std=c99"
# CXX_STDVER: "-std=c++11"
# # Try usual and distchecked build:
# BUILD_TYPE: "default"

- osx-xcode:
name: "gnu11-gcc-xcode12_5_1-out-of-tree"
CC: "gcc"
CXX: "g++"
name: "gnu11-clang-xcode13_4_1-out-of-tree"
CC: "clang"
CXX: "clang++"
CPP: "clang -E"
CC_STDVER: "-std=gnu11"
CXX_STDVER: "-std=gnu++11"
# Try an out-of-tree build:
CI_BUILDDIR: "obj"

- osx-xcode:
name: "c99-cxx11-gcc-xcode12_5_1-default-distcheck"
CC: "gcc"
CXX: "g++"
name: "c99-cxx11-clang-xcode13_4_1-default-distcheck"
CC: "clang"
CXX: "clang++"
CPP: "clang -E"
CC_STDVER: "-std=c99"
CXX_STDVER: "-std=c++11"
# Try usual and distchecked build:
BUILD_TYPE: "default"

- osx-xcode:
name: "stdDefault-xcode12_5_1-fightwarn-all"
name: "stdDefault-xcode13_4_1-fightwarn-all"
# Run "default-all-errors" with both compiler families,
# using their default C/C++ standard for current release:
BUILD_TYPE: "fightwarn-all"

### This does not work due to missing dependencies built for MacOS in homebrew:
### TODO? Evaluate other packagers (MacPorts, fink...)?
# - osx-xcode:
# name: "c17-clang-xcode12_5_1-alldrv"
# XCODE_VER: "12.5.1"
# name: "c17-clang-xcode13_4_1-alldrv"
# XCODE_VER: "13.4.1"
# CC: "clang"
# CXX: "clang++"
# CC_STDVER: "-std=c17"
Expand Down
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
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
/_install_pkgprotodir/
Makefile
Makefile.in

## Parent directory only
/aclocal.m4
/ar-lib
Expand All @@ -22,6 +23,7 @@ Makefile.in
/ChangeLog.adoc
/config.guess
/config.log
/config.log.inplace-outer
/config.status
/config.sub
/config.h
Expand All @@ -43,16 +45,23 @@ Makefile.in
/README
/TODO
/UPGRADING
/VERSION_DEFAULT
/VERSION_FORCED
/VERSION_FORCED_SEMVER
/install-sh
/libtool
/ltmain.sh
/missing
/test-driver
*-contentchecked
*-spellchecked
*-prepped
*.usage-report
*.adoc-parsed
*.adoc*.tmp
*.adoc*.tmp.*
*.txt*.tmp
*.txt*.tmp.*
/cppcheck*.xml
/.ci*.txt*
/.ci*.log
Expand Down
14 changes: 13 additions & 1 deletion COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,26 @@
or (at your option) any later version. See "LICENSE-GPL2" in the root of this
distribution.

The files in the scripts/python/ directory are released under GNU General
The scripts/python/module/nut_telnetlib.py file is copied for fall-back
purposes from Python 3.10, and released under its original license (the
PSF License Version 2). It was only modified in the comment section to
describe the copy, purpose and provenance per section 3 of the license.
According to https://github.com/python/cpython/blob/3.10/LICENSE most of
the licenses Python was provided under over the years are GPL-compatible.

Other files in the scripts/python/ directory are released under GNU General
Public License (GPL) version 3, or (at your option) any later version. See
"LICENSE-GPL3" in the root of this distribution.

The Perl client module (scripts/perl/Nut.pm) is released under the same
license as Perl itself. That is to say either GPL version 1 or (at your option)
any later version, or the "Artistic License".

The scripts/installer contents were donated to the Network UPS Tools project
by Eaton in 2022, including the license change from the one originally used
with their software companion to terms of the open-source project (that is,
GPL version 2 or newer).

Several fallback implementations for methods absent from standard library of
an end-user's current build platform are derived from source code available
under the two-clause BSD license (common/strptime.c, common/strnlen.c)
Expand Down
Loading

0 comments on commit 0dc3727

Please sign in to comment.