Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[FEATURE] Systemd unit file in RPM packages #831

Closed
b00ga opened this issue Nov 8, 2023 · 4 comments
Closed

[FEATURE] Systemd unit file in RPM packages #831

b00ga opened this issue Nov 8, 2023 · 4 comments
Assignees

Comments

@b00ga
Copy link
Contributor

b00ga commented Nov 8, 2023

Is your feature request related to a problem? Please describe.
RPM package does not install systemd unit.

Describe the solution you'd like
Published RPM package to include systemd unit.

Describe alternatives you've considered
I've installed the systemd unit file from the CORE repo by downloading the file from the master branch on github after package install.

Additional context
DEB package already installs the systemd unit file, so would be nice to have parity.
Presumably RPMs are supported for Enterprise Linux distros (Red Hat and family). All currently supported distros (EL7/EL8/EL9) and relatives like Fedora all have systemd (RHEL6 did not, but is effectively EOL since 2020/12/01).

@bharnden
Copy link
Contributor

bharnden commented Nov 8, 2023

Just to be clear, you are saying it doesn't due to the issue of the variable usage?

@bharnden bharnden self-assigned this Nov 8, 2023
@bharnden
Copy link
Contributor

bharnden commented Nov 8, 2023

I think I see what you are talking about now. I never use the service aspect, so I had to refresh myself.

fpm, which I use to help build the packages does not support an --rpm-systemd flag, like --deb-systemd. I will need to try a couple work arounds.

@b00ga
Copy link
Contributor Author

b00ga commented Nov 8, 2023

Hmmm, interesting. I didn't realize fpm had any systemd support. Looking at the fpm code (e.g. here), this is basically fpm generating pre/post scripts for the deb. I guess technically if you were packaging directly with dpkg/files-in-a-debian-directory, you'd tell deb-helper to use some systemd debhelper macros that would generate these scriptlets for you (see this AskUbuntu question).

RPM similarly has helper macros (in the systemd package on EL7/EL8 and the systemd-rpm-macros package in EL9 and Fedora). These will also generate the scriptlets for you, and I guess the fpm developers haven't implemented something similar to what these scriptlets create. (see Fedora Packaging Guidelines on Packaging systemd and for systemd units).

So in the absence of fpm doing it for you, you'd need to have scriptlet files, say in the packaging dir, to hand off to fpm's pre/post command line options for RPM. You can see what the macros definitions are by running rpm --showrc and searching for those scriptlets referenced in the link above (%systemd_post , %systemd_preun and %systemd_postun_with_restart).

Just as a for instance, here's what those scriptlets look like on RHEL8:

  • systemd_post
if [ $1 -eq 1 ] ; then 
        # Initial installation 
        systemctl preset %{?*} >/dev/null 2>&1 || : 
fi 
  • systemd_preun
if [ $1 -eq 0 ] ; then 
       # Package removal, not upgrade 
       systemctl --no-reload disable %{?*} > /dev/null 2>&1 || : 
       systemctl stop %{?*} > /dev/null 2>&1 || : 
fi
  • systemd_postun_with_restart
systemctl daemon-reload >/dev/null 2>&1 || : 
if [ $1 -ge 1 ] ; then 
        # Package upgrade, not uninstall 
        systemctl try-restart %{?*} >/dev/null 2>&1 || : 
fi 

@bharnden
Copy link
Contributor

bharnden commented Nov 8, 2023

I made some adjustments on develop that should hopefully help compensate for both issues you noted

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants