CI: add support for "custom" dependencies in the codebase? Case in question: how to best handle modbus extensions for NUT drivers? #2076
Labels
CI
Entries related to continuous integration infrastructure (historically also recipes like Makefiles)
modbus
packaging
portability
We want NUT to build and run everywhere possible
Milestone
I have a nagging feeling from the olden days, when many autotools projects came with
contrib
,custom
or similar sources of third-party stuff like zlib, etc. so a single tarball could provide most of the build-required ecosystem in days before packaging... IIRC autotools were largely made because of such use-case, to consistently build such mixed codebases using either system-provided or custom-smuggled code.Lately there are a couple of efforts relying on
libmodbus
features which are not (yet) in its mainline code and so packages - PR #2063 (for issue #139) new support for USB, and PR #1671 relies on support for ASCII vs. binary ModBus protocols. Neither is so far included into the upstream library project, and given how slow it is lately about even merging PRs or answering to issues/questions, I am not fully sure we should hold our fingers crossed and hopes to merge new drivers depending on such new features.On the other hand, specifically for the modbus-ascii part of the question, there is some development simmering from a still-open PR stephane/libmodbus#275 from 2015, and a https://github.com/stephane/libmodbus/tree/ascii-support branch in the main project with last commits in 2022, so maybe "they" as domain experts had reasons (security? stability?..) to not merge this - and we would somehow compromise NUT installations by taking in "random-quality" code as a dependency?
WDYT: Would it make sense to expand NUT codebase to rely on potentially custom-built e.g.
libmodbus
, depending onconfigure
-time tests whether the system packages provide the needed feature(s) already? There could be different ways to provide that - e.g. most likely a git submodule to our fork of libmodbus with added features (becoming a directory with a copy as part ofmake dist
), but might technically be a full directory copy in the NUT sources, or a tarball to pull from location X, etc.I suppose such extra source build would yield a
libmodbus.so/a
library file, which we may have to juggle in the installation footprint to not conflict with a system-provided one - neither to overwrite it, nor to auto-ldload
into the same namespace by unsuspecting consumers; in this regard using a static library to build into the concerned drivers and/ornut-scanner
(libnutscan?) may be a least-conflicting option for full-library custom builds (potentially irky forlibnutscan
and whatever its consumers might pull in - such as the system'slibmodbus
again).Another alternative is to follow the path our PR #1671 took -- to provide the new abilities with source files in NUT codebase (
modbus-ascii.{c,h}
) which otherwise rely on standardly availablelibmodbus
packages, thus with minimal long-term conflict against the OS-provided library. I guess this approach could be extended withconfigure
-time checks to use either this implementation or one that hopefully eventually appears in the upstream library. It is not unlike somecommon/*.c
files we have to provide string and other functions available on some platforms but not on others.A year ago I was wary in that PR review about adding a custom semi-fork in NUT. Now that so little has changed in the library itself over the year, this in fact seems like a viable option. (There is still a question about making this secure somehow, to not introduce unreviewed errors on the HW/protocol support side...)
This partially overlaps with issue #1491 which is about general automation of such prerequisite builds (whether to facilitate NUT for Windows or other platforms with questionable support of pre-packaged build dependencies) but does not delve into customizing such dependencies' sources for NUT.
CC @EchterAgo @asperg @aquette @clepple
The text was updated successfully, but these errors were encountered: