diff --git a/.github/workflows/01-make-dist.yml b/.github/workflows/01-make-dist.yml new file mode 100644 index 0000000000..5993f3e6b5 --- /dev/null +++ b/.github/workflows/01-make-dist.yml @@ -0,0 +1,286 @@ +# Adapted from NUT codeql.yml with inspiration taken from +# https://javahelps.com/manage-github-artifact-storage-quota +# regarding uploads of artifacts and clearing the way for them. +# See also: +# https://github.com/actions/upload-artifact +# https://docs.github.com/en/actions/reference/workflows-and-actions/variables +name: "GHA-01: Make dist and docs tarballs, see workflow page for links" + +on: + push: + branches: [ "master", "FTY", "fightwarn", "FTY-obs" ] + tags: + - v* + pull_request_target: + # The branches below must be a subset of the branches above + branches: [ "master", "FTY", "fightwarn", "FTY-obs" ] + schedule: + - cron: '15 12 * * 0' + workflow_dispatch: + # Allow manually running the action, e.g. if disabled after some quietness in the source + +permissions: + contents: read + issues: write + pull-requests: write + +jobs: + make-dist-tarballs: + name: Make Dist and Docs Tarballs + # FIXME: Prepare/maintain a container image with pre-installed + # NUT build/tooling prereqs (save about 3 minutes per run!) + runs-on: ubuntu-latest + permissions: + #actions: read + actions: write + #contents: read + contents: write + repository-projects: write + security-events: write + pull-requests: write + issues: write + + strategy: + fail-fast: false + + steps: + # Post early so this would be about the top comment in the PR trail + # (easy to see, contents replaced later) + - name: "GHA-01: Make dist and docs tarballs - report download URL - t1" + uses: thollander/actions-comment-pull-request@v3 + # if: startsWith(github.ref, 'refs/pull/') + continue-on-error: true + with: + comment-tag: latest-tarball + message: Dist and Docs will be linked here after the "make dist" job completes. + #github-token: ${{ secrets.MAKE_DIST_TOKEN }} + + - name: "GHA-01: Make dist and docs tarballs - report download URL - s1" + uses: marocchino/sticky-pull-request-comment@v2 + # if: startsWith(github.ref, 'refs/pull/') + continue-on-error: true + with: + header: latest-tarball-sticky + only_create: true + message: Dist and Docs will be linked here after the "make dist" job completes. + #github-token: ${{ secrets.MAKE_DIST_TOKEN }} + #GITHUB_TOKEN: ${{ secrets.MAKE_DIST_TOKEN }} + + - name: Checkout repository + uses: actions/checkout@v5 + with: + fetch-depth: 0 + fetch-tags: true + + # https://github.com/marketplace/actions/substitute-string + # Note it warns about "unexpected input(s)" with replacement tokens below, + # as they are by design not predefined, as far as actions API is concened. + # They still work for substitutions though. + - uses: bluwy/substitute-string-action@v3 + id: subst-github-ref-name + with: + _input-text: "${{ github.ref_name }}" + " ": _ + "/": _ + - run: echo "${{ steps.subst-github-ref-name.outputs.result }}" + + # Make build identification more useful (so we use no fallbacks in script) + - name: Try to get more Git metadata + run: | + git describe || { + git remote -v || true + git branch -a || true + for R in `git remote` ; do git fetch $R master ; done || true + git fetch --tags + pwd ; ls -la + echo "=== Known commits in history:" + git log --oneline | wc -l + echo "=== Recent commits in history:" + git log -2 || true + echo "=== Known tags:" + git tag || true + echo "=== Try to ensure 'git describe' works:" + git describe || { + git fetch --all && for R in `git remote` ; do for T in `git tag` ; do git fetch $R $T ; done ; done + git describe || { + TEST_REF="`git symbolic-ref --short HEAD 2>/dev/null || cat .git/HEAD`" && [ -n "${TEST_REF}" ] && git checkout master && git pull --all && git checkout "${TEST_REF}" + git describe || true + } + } + } + + # Using hints from https://askubuntu.com/questions/272248/processing-triggers-for-man-db + # and our own docs/config-prereqs.txt + # NOTE: Currently installing the MAX prerequisite footprint, + # which for building just the docs may be a bit of an overkill. + - name: NUT CI Prerequisite packages (Ubuntu, GCC) + run: | + echo "set man-db/auto-update false" | sudo debconf-communicate + sudo dpkg-reconfigure man-db + sudo apt update + sudo apt install \ + gcc g++ clang \ + ccache time \ + git perl curl \ + make autoconf automake libltdl-dev libtool binutils \ + valgrind \ + cppcheck \ + pkg-config \ + libtool-bin \ + python3 gettext python3-pyqt6 pyqt6-dev-tools \ + aspell aspell-en \ + asciidoc source-highlight python3-pygments dblatex \ + libgd-dev \ + systemd-dev \ + libsystemd-dev \ + libcppunit-dev \ + libssl-dev libnss3-dev \ + augeas-tools libaugeas-dev augeas-lenses \ + libusb-dev libusb-1.0-0-dev \ + libi2c-dev \ + libmodbus-dev \ + libsnmp-dev \ + libpowerman0-dev \ + libfreeipmi-dev libipmimonitoring-dev \ + libavahi-common-dev libavahi-core-dev libavahi-client-dev \ + libgpiod-dev \ + bash dash ksh busybox \ + libneon27-gnutls-dev \ + build-essential git-core libi2c-dev i2c-tools lm-sensors \ + || exit + date > .timestamp-init + + - name: Prepare ccache + # Based on https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#example-using-the-cache-action example + id: cache-ccache + uses: actions/cache@v4 + env: + compiler: 'CC=gcc CXX=g++' + cache-name: cache-ccache-${{ env.compiler }} + with: + path: | + ~/.ccache + ~/.cache/ccache + ~/.config/ccache/ccache.conf + key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/.timestamp-init') }} + restore-keys: | + ${{ runner.os }}-build-${{ env.cache-name }}- + ${{ runner.os }}-build- + ${{ runner.os }}- + + - name: CCache stats before build + run: | + ccache -sv || ccache -s || echo "FAILED to read ccache info, oh well" + rm -f .timestamp-init + + - name: Debug gitlog2version processing + run: bash -x ./tools/gitlog2version.sh || true + + - name: NUT CI Build Configuration + env: + compiler: 'CC=gcc CXX=g++' + run: | + PATH="/usr/lib/ccache:$PATH" ; export PATH + CCACHE_COMPRESS=true; export CCACHE_COMPRESS + ccache --version || true + ( ${{env.compiler}} ; echo "=== CC: $CC => `command -v $CC` =>" ; $CC --version ; echo "=== CXX: $CXX => `command -v $CXX` =>" ; $CXX --version ) || true + ./autogen.sh && \ + ./configure --enable-warnings --enable-Werror --enable-Wcolor --with-all --with-dev --with-docs --enable-docs-changelog ${{env.compiler}} + + # NOTE: In this scenario we do not build actually NUT in the main + # checkout directory, at least not explicitly (recipe may generate + # some files like man pages to fulfill the "dist" requirements; + # for now this may generate some libs to figure out their IDs). + # We do `make docs` to provide them as a separate tarball just + # in case, later. + # DO NOT `make dist-files` here as it includes `dist-sig` and + # needs a GPG keychain with maintainers' secrets deployed locally. + - name: NUT CI Build to create "dist" tarball and related files + env: + compiler: 'CC=gcc CXX=g++' + run: | + PATH="/usr/lib/ccache:$PATH" ; export PATH + CCACHE_COMPRESS=true; export CCACHE_COMPRESS + ccache --version || true + ( ${{env.compiler}} ; echo "=== CC: $CC => `command -v $CC` =>" ; $CC --version ; echo "=== CXX: $CXX => `command -v $CXX` =>" ; $CXX --version ) || true + make -s -j 8 dist dist-hash + + - name: NUT CI Build to verify "dist" tarball build + env: + compiler: 'CC=gcc CXX=g++' + run: | + PATH="/usr/lib/ccache:$PATH" ; export PATH + CCACHE_COMPRESS=true; export CCACHE_COMPRESS + ccache --version || true + ( ${{env.compiler}} ; echo "=== CC: $CC => `command -v $CC` =>" ; $CC --version ; echo "=== CXX: $CXX => `command -v $CXX` =>" ; $CXX --version ) || true + make -s -j 8 distcheck + + - name: CCache stats after distcheck + run: ccache -sv || ccache -s || echo "FAILED to read ccache info, oh well" + + - name: NUT CI Build to package complex docs (not part of dist tarball) + run: | + make -s -j 8 dist-docs + + # Inspired by https://javahelps.com/manage-github-artifact-storage-quota + # Note that the code below wipes everything matched by the filter! + # We may want another script block (after this cleanup of obsolete data) + # to iterate clearing the way build by build until there's X MB available + # (at least 12MB as of Nov 2025). + - if: env.GITHUB_REF_TYPE != 'tag' && steps.subst-github-ref-name.outputs.result != 'master' + name: Delete Old Artifacts for this feature branch/PR + uses: actions/github-script@v6 + id: delete_old_artifact_for_pr + continue-on-error: true + with: + script: | + const res = await github.rest.actions.listArtifactsForRepo({ + owner: context.repo.owner, + repo: context.repo.repo, + }) + + res.data.artifacts + .filter(({ name }) => name === 'NUT-tarballs-${{ steps.subst-github-ref-name.outputs.result }}') + .forEach(({ id }) => { + github.rest.actions.deleteArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: id, + }) + }) + #github-token: ${{ secrets.MAKE_DIST_TOKEN }} + + - name: Upload tarball and its checksum artifacts + uses: actions/upload-artifact@v4 + id: upload_artifact + with: + name: NUT-tarballs-${{ steps.subst-github-ref-name.outputs.result }} + path: | + nut-*.tar* + compression-level: 0 + overwrite: true + + # https://github.com/thollander/actions-comment-pull-request + # FIXME: Something that adds/updates Github Checks would be better + # as it would be seen in the list attached to a status icon of any + # build (e.g. history of master branch) + - name: "GHA-01: Make dist and docs tarballs - report download URL - t2" + uses: thollander/actions-comment-pull-request@v3 + # if: startsWith(github.ref, 'refs/pull/') + continue-on-error: true + with: + comment-tag: latest-tarball + message: Dist and Docs [NUT-tarballs-${{ steps.subst-github-ref-name.outputs.result }}.zip}](${{ steps.upload_artifact.outputs.artifact-url }}) are available for commit ${{ github.sha }} + #github-token: ${{ secrets.MAKE_DIST_TOKEN }} + + # https://github.com/marocchino/sticky-pull-request-comment + - name: "GHA-01: Make dist and docs tarballs - report download URL - s2" + uses: marocchino/sticky-pull-request-comment@v2 + # if: startsWith(github.ref, 'refs/pull/') + continue-on-error: true + with: + header: latest-tarball-sticky + only_create: true + message: Dist and Docs [NUT-tarballs-${{ steps.subst-github-ref-name.outputs.result }}.zip}](${{ steps.upload_artifact.outputs.artifact-url }}) are available for commit ${{ github.sha }} + #github-token: ${{ secrets.MAKE_DIST_TOKEN }} + #GITHUB_TOKEN: ${{ secrets.MAKE_DIST_TOKEN }} diff --git a/.github/workflows/codeql.yml b/.github/workflows/05-codeql.yml similarity index 99% rename from .github/workflows/codeql.yml rename to .github/workflows/05-codeql.yml index 3ef64b68bc..1bcb5d5f78 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/05-codeql.yml @@ -9,7 +9,7 @@ # the `language` matrix defined below to confirm you have the correct set of # supported CodeQL languages. # -name: "CodeQL" +name: "GHA-05: CodeQL" on: push: @@ -96,7 +96,7 @@ jobs: id: cache-ccache uses: actions/cache@v4 env: - cache-name: cache-ccache-${{ matrix.compiler }}-${{ matrix.NUT_SSL_VARIANTS }}-${{ matrix.NUT_SSL_VARIANTS }} + cache-name: cache-ccache-${{ matrix.compiler }}-${{ matrix.NUT_SSL_VARIANTS }}-${{ matrix.NUT_USB_VARIANTS }} with: path: | ~/.ccache diff --git a/.github/workflows/PyNUTClient.yml b/.github/workflows/08-PyNUTClient.yml similarity index 97% rename from .github/workflows/PyNUTClient.yml rename to .github/workflows/08-PyNUTClient.yml index d6298efaf4..353394e9bd 100644 --- a/.github/workflows/PyNUTClient.yml +++ b/.github/workflows/08-PyNUTClient.yml @@ -1,4 +1,4 @@ -name: Publish PyNUT client bindings for NUT 🐍 distributions 📦 to PyPI +name: "GHA-08: Publish PyNUT client bindings for NUT 🐍 distributions 📦 to PyPI" # based on https://medium.com/@VersuS_/automate-pypi-releases-with-github-actions-4c5a9cfe947d # and https://packaging.python.org/en/latest/guides/publishing-package-distribution-releases-using-github-actions-ci-cd-workflows/ diff --git a/Makefile.am b/Makefile.am index 8fc1436077..760782cb09 100644 --- a/Makefile.am +++ b/Makefile.am @@ -823,10 +823,13 @@ EXTRA_DIST += VERSION_DEFAULT # Best-effort delivery for (overly?) customized distros, e.g. via # echo NUT_VERSION_FORCED_SEMVER=1.1.1 > VERSION_FORCED_SEMVER +# ONLY populated into dist tarball if present in the build area! +# (Note we do tarball the VERSION_DEFAULT generated just above) dist-hook: for D in "$(abs_top_srcdir)" "$(abs_top_builddir)" ; do \ for F in VERSION_FORCED VERSION_FORCED_SEMVER ; do \ if [ -s "$$D/$$F" ] ; then \ + echo " DIST $$D/$$F => $(top_distdir)/$$F"; \ cat "$$D/$$F" > "$(top_distdir)/$$F" || true ; \ fi ; \ done ; \ @@ -1019,6 +1022,9 @@ nut-@PACKAGE_VERSION@.tar.gz: dist nut-@PACKAGE_VERSION@.tar.gz.sig: dist-sig nut-@PACKAGE_VERSION@.tar.gz.md5 nut-@PACKAGE_VERSION@.tar.gz.sha256: dist-hash +# Bonus feature, results depend on configure script options and available tools +nut-@PACKAGE_VERSION@-docs.tar.gz: dist-docs + dist-sig: nut-@PACKAGE_VERSION@.tar.gz rm -f nut-@PACKAGE_VERSION@.tar.gz.sig gpg --detach-sign nut-@PACKAGE_VERSION@.tar.gz @@ -1027,6 +1033,51 @@ dist-hash: nut-@PACKAGE_VERSION@.tar.gz md5sum nut-@PACKAGE_VERSION@.tar.gz > nut-@PACKAGE_VERSION@.tar.gz.md5 sha256sum nut-@PACKAGE_VERSION@.tar.gz > nut-@PACKAGE_VERSION@.tar.gz.sha256 +# Helper to have all built docs (config-dependent) neatly aligned +# NOT part of standard tarball, though +EXTRA_DIST_DOCS = VERSION_* *.adoc-parsed + +if WITH_CHANGELOG_TEXT +EXTRA_DIST_DOCS += ChangeLog +endif WITH_CHANGELOG_TEXT + +if WITH_CHANGELOG_ADOC +EXTRA_DIST_DOCS += ChangeLog.adoc +endif WITH_CHANGELOG_ADOC + +if KEEP_NUT_REPORT +EXTRA_DIST_DOCS += config.nut_report_feature.log +endif KEEP_NUT_REPORT + +if WITH_HTML_SINGLE +EXTRA_DIST_DOCS += docs/man/*.html docs/*.html +endif WITH_HTML_SINGLE + +if WITH_HTML_CHUNKED +EXTRA_DIST_DOCS += docs/*.chunked +endif WITH_HTML_CHUNKED + +if WITH_PDFS +EXTRA_DIST_DOCS += docs/*.pdf +endif WITH_PDFS + +if WITH_MANS +if !KNOWN_UNABLE_MANS +EXTRA_DIST_DOCS += \ + docs/man/*.@MAN_SECTION_API_BASE@ \ + docs/man/*.@MAN_SECTION_CFG_BASE@ \ + docs/man/*.@MAN_SECTION_CMD_SYS_BASE@ \ + docs/man/*.@MAN_SECTION_CMD_USR_BASE@ \ + docs/man/*.@MAN_SECTION_MISC_BASE@ +endif !KNOWN_UNABLE_MANS +endif WITH_MANS + +# Modeled after automake generated mesh of rules for "distdir" handling with "am__tar" +dist-docs: all-docs + $${TAR-tar} cf - $(EXTRA_DIST_DOCS) | eval GZIP= gzip $(GZIP_ENV) -c > $(distdir)-docs.tar.gz + ls -la $(distdir)-docs.tar.gz + $${TAR-tar} tzvf $(distdir)-docs.tar.gz || true + # ---------------------------------------------------------------------- # targets from old build system (pre-automake). # supported for a period of time for backward "compatibility". diff --git a/NEWS.adoc b/NEWS.adoc index 4c96d6e935..12de06cfeb 100644 --- a/NEWS.adoc +++ b/NEWS.adoc @@ -256,6 +256,15 @@ several `FSD` notifications into one executed action. [PR #3097] - Updated `docs/*.txt`: add asciidoc comments with links to nut-website rendered contents of most interesting pages. [#3095] + - Added a `make dist-docs` goal to generate, collect and tarball all document + types (man, html-single, html-chunked, pdf) that we may have enabled for the + current build configuration and available tooling. [#1400] + + - Added a GitHub Actions CI job to generate, upload and recycle `make dist` + and `make dist-docs` tarballs so they are easier to obtain for people and + other CI systems (which might not want to follow a Git repository). [#1400, + #2829] + - Source directory `data/html` was renamed to `data/htmlcgi` in order to better reflect its contents and purpose, compared to documentation-oriented `html*` directories (and recipe variable names). This may impact some diff --git a/docs/maintainer-guide.txt b/docs/maintainer-guide.txt index 1e4f0b0b91..e059fbfe95 100644 --- a/docs/maintainer-guide.txt +++ b/docs/maintainer-guide.txt @@ -272,6 +272,8 @@ VERSION_FORCED_SEMVER:NUT_VERSION_FORCED_SEMVER='2.8.3' * `make dist-files` (especially if you did not `make distcheck` above, or had some changes since then) to store the source tarball, checksum and signature files +** Bonus feature: `make dist-docs` (if on a system configured to build all + documentation types) * post-release update of the "in-development" codebase: ** start a feature branch to return the master branch into development state diff --git a/scripts/obs/_config b/scripts/obs/_config index c53e0ce56c..139af5ab1d 100644 --- a/scripts/obs/_config +++ b/scripts/obs/_config @@ -5,8 +5,9 @@ Prefer: libusbx-devel Prefer: libusb-1.0-dev Prefer: neon-devel +Prefer: util-linux -%if "x%{_repository}" == "xRaspbian_11" +%if "x%{_repository}" == "xRaspbian_11" || "x%{_repository}" == "xRHEL_7" %else # Use ccache or sccache (let OBS pick its preference) for faster (re-)builds: BuildFlags: useccache:nut diff --git a/scripts/obs/nut.spec b/scripts/obs/nut.spec index 9d718e3d11..37f8212b82 100644 --- a/scripts/obs/nut.spec +++ b/scripts/obs/nut.spec @@ -51,6 +51,7 @@ %define MODELPATH %{LIBEXECPATH}/driver %define STATEPATH %{_localstatedir}/lib/ups +### Note: this is /etc/nut in Debian version %define CONFPATH %{_sysconfdir}/ups # RPM on OpenSUSE goes: # DOCDIR=/home/abuild/rpmbuild/BUILD/nut-2.8.4.428-build/BUILDROOT/usr/share/doc/packages/nut @@ -66,7 +67,6 @@ # This directory is for user files, use /usr/share/bash-completion/completions/ %define BASHCOMPLETIONPATH %(test -d /usr/share/bash-completion/completions && echo /usr/share/bash-completion/completions || echo "%{_sysconfdir}/bash_completion.d") -### Note: this is /etc/nut in Debian version %define NUT_USER upsd %define NUT_GROUP daemon %define LBRACE ( @@ -91,18 +91,19 @@ %define NUT_SYSTEMD_UNITS_PRESET %(cd scripts/systemd && ls -1 *.preset{,.in} | sed 's,.in$,,' | sort | uniq) +# Not all distros have certain packages (or their equivalents/aliases), +# NOTE: No use searching remote repos for what might be or not be available +# there; we have to use rpm queries based on whatever did get installed +# according to Requires lines below (in turn according to our declaration +# of what is shipped by this or that distro/release), to decide whether we +# deliver certain sub-packages - and set NUTPKG_WITH_ at that time. +# For version-specific checks note that some are directly digited, others +# are off by two or four digits (e.g. 0810 = a "8.10" release), see +# https://en.opensuse.org/openSUSE:Build_Service_cross_distribution_howto + # Does this NUT branch have DMF feature code? %define NUTPKG_WITH_DMF %( test -d scripts/DMF && echo 1 || echo 0 ) -# Not all distros have it -# FIXME: No use searching remote repos; can use rpm queries based on whatever -# did get installed according to Requires lines below, to decide whether we -# deliver certain sub-packages though. -%define NUTPKG_WITH_FREEIPMI %( (yum search freeipmi-devel | grep -E '^(lib)?freeipmi-devel\.' && exit ; dnf search freeipmi-devel | grep -E '^(lib)?freeipmi-devel\.' && exit ; zypper search -s freeipmi-devel | grep -E '(lib)?freeipmi-devel' && exit ; urpmq --sources freeipmi-devel && exit ; pkcon search name freeipmi-devel | grep -E '(Available|Installed).*freeipmi-devel' && exit;) >&2 && echo 1 || echo 0) -%define NUTPKG_WITH_POWERMAN %( (yum search powerman-devel | grep -E '^(lib)?powerman-devel\.' && exit ; dnf search powerman-devel | grep -E '^(lib)?powerman-devel\.' && exit ; zypper search -s powerman-devel | grep -E '(lib)?powerman-devel' && exit ; urpmq --sources powerman-devel && exit ; pkcon search name powerman-devel | grep -E '(Available|Installed).*powerman-devel' && exit;) >&2 && echo 1 || echo 0) -%define NUTPKG_WITH_AVAHI %( (yum search avahi-devel | grep -E '^(lib)?avahi-devel\.' && exit ; dnf search avahi-devel | grep -E '^(lib)?avahi-devel\.' && exit ; zypper search -s avahi-devel | grep -E '(lib)?avahi-devel' && exit ; urpmq --sources avahi-devel && exit ; pkcon search name avahi-devel | grep -E '(Available|Installed).*avahi-devel' && exit;) >&2 && echo 1 || echo 0) -%define NUTPKG_WITH_TCPWRAP %( (yum search tcp_wrappers-devel | grep -E '^(lib)?tcp_wrappers-devel\.' && exit ; dnf search tcp_wrappers-devel | grep -E '^(lib)?tcp_wrappers-devel\.' && exit ; zypper search -s tcp_wrappers-devel | grep -E '(lib)?tcp_wrappers-devel' && exit ; urpmq --sources tcp_wrappers-devel && exit ; pkcon search name tcp_wrappers-devel | grep -E '(Available|Installed).*tcp_wrappers-devel' && exit;) >&2 && echo 1 || echo 0) - # FIXME: Find a smarter way to set those from main codebase recipes... # Something like `git grep 'version-info' '*.am'` ? %define SO_MAJOR_LIBUPSCLIENT 7 @@ -138,9 +139,9 @@ Requires: %{_bindir}/pgrep Requires: %{_bindir}/pkill Requires: %{_bindir}/readlink Requires: usbutils -%if 0%{?suse_version} +#%if 0 % {?suse_version} Requires(post): udev -%endif +#%endif #Requires(post): group(% {NUT_GROUP}) #Requires(post): user(% {NUT_USER}) Requires(postun): %{_bindir}/sh @@ -152,22 +153,47 @@ Recommends: logrotate # To fix end-of-line encoding: BuildRequires: dos2unix +%if ! 0%{?rhel_version} # For man page aliases # https://en.opensuse.org/openSUSE:Packaging_Conventions_RPM_Macros#fdupes BuildRequires: fdupes +%endif -%if 0%{?NUTPKG_WITH_AVAHI} +%if ( ! 0%{?rhel_version} ) && ( ! 0%{?rhel} ) +# Not sure why claimed absent in RHEL7 (even with Fedora/EPEL repo layer added) +%define NUTPKG_WITH_AVAHI 1 BuildRequires: avahi-devel +%else +%define NUTPKG_WITH_AVAHI 0 %endif -%if 0%{?NUTPKG_WITH_FREEIPMI} +%if ( ! 0%{?rhel_version} ) && ( ! 0%{?rhel} ) && ( 0%{?sle_version}>=150000 || ! 0%{?sle_version} ) && ( 0%{?suse_version}>=1300 || ! 0%{?suse_version} ) +# Not sure why claimed absent in RHEL (even with Fedora/EPEL repo layer added) +%define NUTPKG_WITH_FREEIPMI 1 BuildRequires: (libfreeipmi-devel or freeipmi-devel) +%else +%define NUTPKG_WITH_FREEIPMI 0 %endif -BuildRequires: gcc-c++ +%if ( 0%{?rhel_version}>=800 || ! 0%{?rhel_version} ) && ( 0%{?rhel}>=8 || ! 0%{?rhel} ) +# Not in RHEL7 +%define NUTPKG_WITH_LIBGD 1 BuildRequires: gd-devel +%else +%define NUTPKG_WITH_LIBGD 0 +%endif + +BuildRequires: gcc-c++ BuildRequires: libtool + +%if ( 0%{?rhel_version}>=800 || ! 0%{?rhel_version} ) && ( 0%{?rhel}>=8 || ! 0%{?rhel} ) +# Not in RHEL7 +%define NUTPKG_WITH_LTDL 1 BuildRequires: libtool-ltdl-devel +%else +%define NUTPKG_WITH_LTDL 0 +%endif + # libusb-0.1 or libusb-1.0: BuildRequires: (libusb-devel or libusbx-devel) #!Prefer: libusbx-devel @@ -178,6 +204,7 @@ BuildRequires: pkg-config BuildRequires: (python >= 2.6 or python3 or python2) %if 0%{?NUTPKG_WITH_DMF} +# Toggle decided above based on variant of NUT source codebase # LUA 5.1 or 5.2 is known ok for us, both are modern in current distros (201609xx) BuildRequires: lua-devel @@ -193,19 +220,32 @@ BuildRequires: lua-devel # For some platforms we may have to fiddle with distro-named macros like # % if 0 % {?centos_version} # % if 0 % {?suse_version} -# % if 0 % {?rhel_version}>=7 +# % if 0 % {?rhel_version}>=700 # and whatnot +%if ( (0%{?rhel_version}>0 && 0%{?rhel_version}<800) || ! 0%{?rhel_version} ) && ( (0%{?centos_version}>0 && 0%{?centos_version}!=800) || ! 0%{?centos_version} ) +# Strange that this is not present in RHEL (even with Fedora EPEL repos attached) +# and that it is resolvable in CentOS 7, 9, 10 but not 8... +# We only need this to learn paths from apxs tool, so no NUTPKG_WITH_* toggle BuildRequires: (httpd-devel or apache2-devel) +%endif + BuildRequires: (dbus-1-glib-devel or dbus-glib-devel) -%if 0%{?rhel_version}>=8 || ! 0%{?rhel_version} +%if ( ! 0%{?rhel_version} ) && ( ! 0%{?rhel} ) +# Strange that this is not present in RHEL (even with Fedora EPEL repos attached) BuildRequires: (libcppunit-devel or cppunit-devel) %endif # Obsoleted/away in newer distros -%if 0%{?NUTPKG_WITH_TCPWRAP} +%if ( (0%{?rhel_version}>0 && 0%{?rhel_version}<800) || ! 0%{?rhel_version} ) && ( (0%{?centos_version}>0 && 0%{?centos_version}<800) || ! 0%{?centos_version} ) && ( (0%{?fedora_version}>0 && 0%{?fedora_version}<=27) || ! 0%{?fedora_version} ) +# Note that per https://en.opensuse.org/openSUSE:Build_Service_cross_distribution_howto +# there was "fedora_version" until some time before 36, when the macro became "fedora"; +# similarly for "rhel_version <= 700" vs. "rhel == 8"... +%define NUTPKG_WITH_TCPWRAP 1 BuildRequires: (tcpd-devel or tcp_wrappers-devel) +%else +%define NUTPKG_WITH_TCPWRAP 0 %endif # May be plain "neon" and "libusb" in RHEL7 or older? @@ -216,20 +256,32 @@ BuildRequires: (libneon-devel or neon-devel or neon) BuildRequires: (libopenssl-devel or openssl-devel or openssl) #!Prefer: (libopenssl-devel or openssl-devel) -%if 0%{?NUTPKG_WITH_POWERMAN} +%if ( ! 0%{?rhel_version} ) && ( ! 0%{?rhel} ) && ( (0%{?centos_version}>0 && 0%{?centos_version}<1000) || ! 0%{?centos_version} ) && ( (0%{?fedora_version}>0 && 0%{?fedora_version}<4200) || ! 0%{?fedora_version} ) && ( (0%{?fedora}>0 && 0%{?fedora}<42) || ! 0%{?fedora} ) +# Strange that this is not present in RHEL (even with Fedora EPEL repos attached) +# NOTE: fedora_version=99 seems to be rawhide; currently it says this package +# is not known (so likely a post-42 release would be more specific later), +# CentOS10 also does not like the name. +%define NUTPKG_WITH_POWERMAN 1 BuildRequires: powerman-devel +%else +%define NUTPKG_WITH_POWERMAN 0 %endif -%if 0%{?suse_version} +%if ( 0%{?suse_version}>0 || ! 0%{?suse_version} ) && (0%{?centos_version}>=800 || ! 0%{?centos_version} ) && ( ! 0%{?rhel_version} ) && ( ! 0%{?rhel} ) +# Strange that this is not present in RHEL (even with Fedora EPEL repos attached) +# But it also complains about epel-rpm-macros when this is added though. BuildRequires: systemd-rpm-macros +%endif + +%if ( 0%{?rhel_version}>=800 || ! 0%{?rhel_version} ) && ( 0%{?rhel}>=8 || ! 0%{?rhel} ) # Only needed for PDF generation, we do not package that now #BuildRequires: dblatex -%endif BuildRequires: (libxslt-tools or libxslt) BuildRequires: asciidoc +%endif -%if %{defined opensuse_version} +%if 0%{?opensuse_version} # Package provides driver for USB HID UPSes, but people can live with hal addon: Enhances: %{USBHIDDRIVERS} # Package provides the only avalailable driver for other USB UPSes: @@ -301,6 +353,7 @@ interface for monitoring and administering UPS hardware. Detailed information about supported hardware can be found in %{_docdir}/nut. +%if 0%{?NUTPKG_WITH_LTDL} %package -n libnutscan%{SO_MAJOR_LIBNUTSCAN} Summary: Network UPS Tools Library (Uninterruptible Power Supply Monitoring) Group: System/Libraries @@ -331,7 +384,9 @@ interface for monitoring and administering UPS hardware. Detailed information about supported hardware can be found in %{_docdir}/nut. %endif +%endif +%if 0%{?NUTPKG_WITH_LIBGD} %package cgi Summary: Network UPS Tools Web Server Support (UPS Status Pages) Group: Hardware/UPS @@ -347,6 +402,7 @@ interface for monitoring and administering UPS hardware. Detailed information about supported hardware can be found in %{_docdir}/nut. +%endif %package monitor Summary: Network UPS Tools Web Server Support (GUI client) @@ -549,6 +605,7 @@ if [ -x /sbin/udevadm ] ; then /sbin/udevadm trigger --subsystem-match=usb --pro %postun -n libnutclientstub%{SO_MAJOR_LIBNUTCLIENTSTUB} -p /sbin/ldconfig +%if 0%{?NUTPKG_WITH_LTDL} > 0 %post -n libnutscan%{SO_MAJOR_LIBNUTSCAN} -p /sbin/ldconfig %postun -n libnutscan%{SO_MAJOR_LIBNUTSCAN} -p /sbin/ldconfig @@ -557,7 +614,7 @@ if [ -x /sbin/udevadm ] ; then /sbin/udevadm trigger --subsystem-match=usb --pro %post -n libnutconf%{SO_MAJOR_LIBNUTCONF} -p /sbin/ldconfig %postun -n libnutconf%{SO_MAJOR_LIBNUTCONF} -p /sbin/ldconfig - +%endif %endif %files @@ -721,6 +778,7 @@ if [ -x /sbin/udevadm ] ; then /sbin/udevadm trigger --subsystem-match=usb --pro %defattr(-,root,root) %{_libdir}/libnutclientstub.so.* +%if 0%{?NUTPKG_WITH_LTDL} %files -n libnutscan%{SO_MAJOR_LIBNUTSCAN} %defattr(-,root,root) %{_libdir}/libnutscan.so.* @@ -730,7 +788,9 @@ if [ -x /sbin/udevadm ] ; then /sbin/udevadm trigger --subsystem-match=usb --pro %defattr(-,root,root) %{_libdir}/libnutconf.so.* %endif +%endif +%if 0%{?NUTPKG_WITH_LIBGD} %files cgi %defattr(-,root,root) %dir %{CGIPATH} @@ -739,6 +799,7 @@ if [ -x /sbin/udevadm ] ; then /sbin/udevadm trigger --subsystem-match=usb --pro %{HTMLPATH}/* %config(noreplace) %{CONFPATH}/upsstats-single.html %config(noreplace) %{CONFPATH}/upsstats.html +%endif %files monitor %defattr(-,root,root)