Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .ci/goreleaser/postinstall.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,12 @@ fi

mkdir -p /var/lib/wfx
chown -R wfx:wfx /var/lib/wfx

if command -v systemctl &> /dev/null; then
systemctl enable wfx.service
fi

if [ -d /run/systemd/system ]; then
systemctl --system daemon-reload
systemctl start wfx.service
fi
12 changes: 12 additions & 0 deletions .ci/goreleaser/preremove.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#!/bin/sh
# SPDX-FileCopyrightText: 2025 Siemens AG
#
# SPDX-License-Identifier: Apache-2.0

if command -v systemctl &> /dev/null; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, this script – as the others – use /bin/sh as shell which could effectively be dash, bash, zsh, fish, .... and command -v also resolves shell functions: So if there's a shell function aptly named systemctl defined, e.g., in the global config file, that shell function is called instead of the systemctl executable on disk, which could be OK or not. On the other hand, in strictly POSIX shells, one cannot use type -p (which resolves in $PATH only) as parameters (as -p) to type are not POSIX defined/mandated. Well, there's no silver bullet here...

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will replace current scripts with autogenerated code from dh_installsystemd, this does not solve the issue you mentioned, but at least it's aligned with debians maintainer scripts.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With going Debian only (see below comment), that may be an option, as long as it is easily maintainable.

systemctl disable wfx.service
fi

if [ -d /run/systemd/system ]; then
systemctl stop wfx.service
fi
1 change: 1 addition & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ nfpms:
priority: extra
scripts:
postinstall: .ci/goreleaser/postinstall.sh
preremove: .ci/goreleaser/preremove.sh
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As this patch set applies to deb and rpm formats, how is the convention on RPM-based distros, e.g., Fedora, RHEL, ... regarding starting a service after installation? If that differs from Debian's, we need to switch-case here.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

At least fedora does not start services on install, so we need to distinguish here.
One can provide different scripts for rpm and deb, but, unfortunately, that would cause either, some code duplication on the user handling in existing scripts, or (as suggested by nfpm - https://nfpm.goreleaser.com/docs/tips/) adding some quirks to detect on which package system is the actual script is executed:

if you need to know the packaging system I have found it useful to add a /etc/path-to-cfg/package.env that contains _INSTALLED_FROM=apk|deb|rpm which can be sourced into the pre/post install/remove scripts

Further, it seems only wfx is built for deb and rpm, but not wfxctl and wfx-viewer. Is this intentional?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Further, it seems only wfx is built for deb and rpm, but not wfxctl and wfx-viewer. Is this intentional?

These are released in extra packages, see, e.g., the release artifacts for v0.4.1. This way, one can decide fine-grained what's needed or not for the application scenario at hand.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm, OK, either we open the if-then-else hell or opt for one package format. I would go for Debian only and drop RPM support for the time being (requiring a breaking note and reasoning in the CHANGELOG).
If RPM turns out to be needed, we have at least a good argument for bringing in hard-to-maintain code :)

postremove: .ci/goreleaser/postremove.sh
contents:
# it's the same content for all architectures
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ This is a maintenance release.

### Changed

- Start and enable wfx service on installation and stop and disable it on removal
- Migrated from Swagger to OpenAPI v3
- The previous Swagger (OpenAPI v2) specification is still available at `/api/wfx/v1/swagger.json` to _ensure compatibility_ with older clients (e.g., SWUpdate <= 2024.12). This endpoint will be removed in a future release.
- The top-level `/swagger.json` is no longer served, as no known clients make use of it.
Expand Down