Skip to content

Commit

Permalink
[eclipse-kanto#85] Provide RPM support
Browse files Browse the repository at this point in the history
Aligned RPM support with the Debian packages one.

Signed-off-by: Konstantina Gramatova <[email protected]>
  • Loading branch information
konstantina-gramatova committed Sep 21, 2022
1 parent 029dcd4 commit 43836f0
Show file tree
Hide file tree
Showing 4 changed files with 82 additions and 66 deletions.
48 changes: 48 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,12 @@ nfpms:
dst: /etc/systemd/system/suite-connector.service
file_info:
mode: 0644
packager: deb
- src: ./build-tmp/suite-connector/resources/suite-connector.service
dst: /usr/lib/systemd/system/suite-connector.service
file_info:
mode: 0644
packager: rpm
- src: ./build-tmp/suite-connector/resources/config.json
dst: /etc/suite-connector/config.json
type: config
Expand Down Expand Up @@ -599,6 +605,12 @@ nfpms:
dst: /etc/systemd/system/container-management.service
file_info:
mode: 0644
packager: deb
- src: ./build-tmp/container-management/containerm/resources/container-management.service
dst: /usr/lib/systemd/system/container-management.service
file_info:
mode: 0644
packager: rpm
- src: ./build-tmp/container-management/containerm/resources/config.json
dst: /etc/container-management/config.json
type: config
Expand All @@ -621,6 +633,12 @@ nfpms:
dst: /etc/systemd/system/file-upload.service
file_info:
mode: 0644
packager: deb
- src: ./build-tmp/file-upload/resources/file-upload.service
dst: /usr/lib/systemd/system/file-upload.service
file_info:
mode: 0644
packager: rpm
- src: ./build-tmp/file-upload/resources/config.json
dst: /etc/file-upload/config.json
type: config
Expand All @@ -643,6 +661,12 @@ nfpms:
dst: /etc/systemd/system/software-update.service
file_info:
mode: 0644
packager: deb
- src: ./build-tmp/software-update/resources/software-update.service
dst: /usr/lib/systemd/system/software-update.service
file_info:
mode: 0644
packager: rpm
- src: ./build-tmp/software-update/resources/config.json
dst: /etc/software-update/config.json
type: config
Expand All @@ -665,6 +689,12 @@ nfpms:
dst: /etc/systemd/system/local-digital-twins.service
file_info:
mode: 0644
packager: deb
- src: ./build-tmp/local-digital-twins/resources/local-digital-twins.service
dst: /usr/lib/systemd/system/local-digital-twins.service
file_info:
mode: 0644
packager: rpm
- src: ./build-tmp/local-digital-twins/resources/config.json
dst: /etc/local-digital-twins/config.json
type: config
Expand Down Expand Up @@ -692,6 +722,12 @@ nfpms:
dst: /etc/systemd/system/suite-bootstrapping.service
file_info:
mode: 0644
packager: deb
- src: ./build-tmp/suite-bootstrapping/resources/suite-bootstrapping.service
dst: /usr/lib/systemd/system/suite-bootstrapping.service
file_info:
mode: 0644
packager: rpm
- src: ./build-tmp/suite-bootstrapping/resources/config.json
dst: /etc/suite-bootstrapping/config.json
type: config
Expand Down Expand Up @@ -719,6 +755,12 @@ nfpms:
dst: /etc/systemd/system/file-backup.service
file_info:
mode: 0644
packager: deb
- src: ./build-tmp/file-backup/resources/file-backup.service
dst: /usr/lib/systemd/system/file-backup.service
file_info:
mode: 0644
packager: rpm
- src: ./build-tmp/file-backup/resources/config.json
dst: /etc/file-backup/config.json
type: config
Expand All @@ -741,6 +783,12 @@ nfpms:
dst: /etc/systemd/system/system-metrics.service
file_info:
mode: 0644
packager: deb
- src: ./build-tmp/system-metrics/resources/system-metrics.service
dst: /usr/lib/systemd/system/system-metrics.service
file_info:
mode: 0644
packager: rpm
- src: ./build-tmp/system-metrics/resources/config.json
dst: /etc/system-metrics/config.json
type: config
Expand Down
57 changes: 18 additions & 39 deletions build/postinst_rpm
Original file line number Diff line number Diff line change
@@ -1,54 +1,33 @@
systemctl_start_if_enabled () {
if (systemctl -q is-enabled "$1"); then
echo "Starting $1"
systemctl start "$1" || :
fi
}

if [ $1 -eq 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then
# Initial installation

# Configure Mosquitto to look for the suite-connector config file
echo "include_dir /etc/mosquitto/conf.d" >> /etc/mosquitto/mosquitto.conf

# Use a systemctl preset
# instead of "systemctl enable"
# as per Fedora's guidelines

# Use `:` instead of `true` as this is the usual expansion of rpm scriptlets

# If containerd and mosquitto aren't enabled, enable them
systemctl unmask containerd.service >/dev/null || :
/usr/lib/systemd/systemd-update-helper install-system-units containerd.service || :
systemctl unmask mosquitto.service >/dev/null || :
# Handle dependent services installation and start up
/usr/lib/systemd/systemd-update-helper install-system-units mosquitto.service || :
/usr/lib/systemd/systemd-update-helper install-system-units containerd.service || :

# If mosquitto is already running, restart it to pick up the new configuration
# Configure Mosquitto to look for the suite-connector config file
echo "include_dir /etc/mosquitto/conf.d" >> /etc/mosquitto/mosquitto.conf
/usr/lib/systemd/systemd-update-helper mark-restart-system-units mosquitto.service || :

# Enable the Kanto services
systemctl unmask suite-connector.service >/dev/null || :
# Install the Kanto services
/usr/lib/systemd/systemd-update-helper install-system-units suite-connector.service || :
systemctl unmask container-management.service >/dev/null || :
/usr/lib/systemd/systemd-update-helper install-system-units local-digital-twins.service || :
/usr/lib/systemd/systemd-update-helper install-system-units suite-bootstrapping.service || :
/usr/lib/systemd/systemd-update-helper install-system-units container-management.service || :
systemctl unmask file-upload.service >/dev/null || :
/usr/lib/systemd/systemd-update-helper install-system-units file-upload.service || :
systemctl unmask software-update.service >/dev/null || :
/usr/lib/systemd/systemd-update-helper install-system-units software-update.service || :
systemctl unmask file-backup.service >/dev/null || :
/usr/lib/systemd/systemd-update-helper install-system-units file-backup.service || :
systemctl unmask system-metrics.service >/dev/null || :
/usr/lib/systemd/systemd-update-helper install-system-units system-metrics.service || :

# Start the containerd and mosquitto services, if enabled
systemctl_start_if_enabled containerd.service || :
systemctl_start_if_enabled mosquitto.service || :

# Start the Kanto services, if enabled
systemctl_start_if_enabled suite-connector.service || :
systemctl_start_if_enabled container-management.service || :
systemctl_start_if_enabled file-upload.service || :
systemctl_start_if_enabled software-update.service || :
systemctl_start_if_enabled file-backup.service || :
systemctl_start_if_enabled system-metrics.service || :
# Start the Kanto services if enabled
if [ -d /run/systemd/system ]; then
systemctl is-enabled -q suite-connector.service && systemctl start suite-connector.service >/dev/null || :
systemctl is-enabled -q local-digital-twins.service && systemctl start local-digital-twins.service >/dev/null || :
systemctl is-enabled -q suite-bootstrapping.service && systemctl start suite-bootstrapping.service >/dev/null || :
systemctl is-enabled -q container-management.service && systemctl start container-management.service >/dev/null || :
systemctl is-enabled -q file-upload.service && systemctl start file-upload.service >/dev/null || :
systemctl is-enabled -q software-update.service && systemctl start software-update.service >/dev/null || :
systemctl is-enabled -q file-backup.service && systemctl start file-backup.service >/dev/null || :
systemctl is-enabled -q system-metrics.service && systemctl start system-metrics.service >/dev/null || :
fi
fi
26 changes: 10 additions & 16 deletions build/postrm_rpm
Original file line number Diff line number Diff line change
@@ -1,24 +1,18 @@
if [ $1 -ge 1 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then
# Package upgrade, not uninstall

# Do not call mark-restart-system-units on containerd and mosquitto,
# they have their own scripts

# Use `:` instead of `true` as this is the usual expansion of rpm scriptlets

# The Kanto services, including ones that are usually disabled by default
/usr/lib/systemd/systemd-update-helper mark-restart-system-units suite-bootpping.service || :
/usr/lib/systemd/systemd-update-helper mark-restart-system-units local-digital-twins.service || :
/usr/lib/systemd/systemd-update-helper mark-restart-system-units suite-connector.service || :
/usr/lib/systemd/systemd-update-helper mark-restart-system-units container-management.service || :
/usr/lib/systemd/systemd-update-helper mark-restart-system-units file-upload.service || :
/usr/lib/systemd/systemd-update-helper mark-restart-system-units software-update.service || :
/usr/lib/systemd/systemd-update-helper mark-restart-system-units file-backup.service || :
/usr/lib/systemd/systemd-update-helper mark-restart-system-units system-metrics.service || :
# Mark the Kanto services for restart, including ones that are usually disabled by default
# Shouldn't we mark the services in the pre and call daemon reload-restart in the post - it's not handled by default
/usr/lib/systemd/systemd-update-helper mark-restart-system-units suite-connector.service
/usr/lib/systemd/systemd-update-helper mark-restart-system-units local-digital-twins.service|| :
/usr/lib/systemd/systemd-update-helper mark-restart-system-units suite-bootstrapping.service|| :
/usr/lib/systemd/systemd-update-helper mark-restart-system-units container-management.service|| :
/usr/lib/systemd/systemd-update-helper mark-restart-system-units file-upload.service|| :
/usr/lib/systemd/systemd-update-helper mark-restart-system-units software-update.service|| :
/usr/lib/systemd/systemd-update-helper mark-restart-system-units file-backup.service|| :
/usr/lib/systemd/systemd-update-helper mark-restart-system-units system-metrics.service|| :
fi

# $1 is 0 on uninstall, 1 on upgrade

if [ $1 -eq 0 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then
# Package uninstall, not upgrade

Expand Down
17 changes: 6 additions & 11 deletions build/prerm_rpm
Original file line number Diff line number Diff line change
@@ -1,21 +1,16 @@
if [ $1 -eq 0 ] && [ -x "/usr/lib/systemd/systemd-update-helper" ]; then
# Package removal, not upgrade

# Do not call remove-system-units on containerd and mosquitto,
# they have their own scripts

# Use `:` instead of `true` as this is the usual expansion of rpm scriptlets

# /usr/lib/systemd/systemd-update-helper remove-system-units does the following:
# Stops the service and disables it from automatically running.

# The Kanto services, including ones that are usually disabled by default
# Remove the Kanto services, including ones that are usually disabled by default
/usr/lib/systemd/systemd-update-helper remove-system-units system-metrics.service || :
/usr/lib/systemd/systemd-update-helper remove-system-units file-backup.service || :
/usr/lib/systemd/systemd-update-helper remove-system-units software-update.service || :
/usr/lib/systemd/systemd-update-helper remove-system-units file-upload.service || :
/usr/lib/systemd/systemd-update-helper remove-system-units container-management.service || :
/usr/lib/systemd/systemd-update-helper remove-system-units suite-connector.service || :
/usr/lib/systemd/systemd-update-helper remove-system-units local-digital-twins.service || :
/usr/lib/systemd/systemd-update-helper remove-system-units suite-bootstrapping.service || :
/usr/lib/systemd/systemd-update-helper remove-system-units local-digital-twins.service || :
/usr/lib/systemd/systemd-update-helper remove-system-units suite-connector.service || :

# Reload systemd
/usr/lib/systemd/systemd-update-helper system-reload
fi

0 comments on commit 43836f0

Please sign in to comment.