Remove Sys V Init support from RPM distribution.#106
Conversation
As all the RPM based distributions use systemd now, and have done it for an extended period of time, it is no longer necessary for the Lyrion RPM package to support Sys V Init.
Updated and improved information on how to use systemd drop in files to amend/change the start-up parameters of Lyrion Music Server
The file /etc/sysconfig/lyrionmusicserver was used to configure start-up parameters for the Lyrion Music Server when it was controlled by Sys V Init. The file can also be used by systemd, but it fits very badly in the concept of systemd. It is better not to use it at all. The file is thus replaced by a stub file with some information and a pointer to the README.systemd file.
The use of pgrep in the postrotate section was wrong
The Init script file has been removed. Logic for migrating non-standard Sys V Init configuration to systemd has been removed, The systemd unit file is now properly installed using standard RPM techniques Added dependency on system (%systemd_requires) as the package provides a unit file.
The Sys V Init is outdated. Removed the parallel support of Sys V init. Now only supporting systemd.
Some further small teaks to the explanations to make it more readable.
Made some changes to improve the explanations on how to use drop in files for the systemd unit file.
Removed references to Sys V Init in the README file.
|
Hi, I have a further question. The RPM sepc file has a require statement for PERL to be v 5.10 or higher. I have seen the change to remove PERL binaries for versions 5.20 and earlier. Should I also bump the spec file require statement to require PERL version 5.22 or higher? Regards, Johan |
michaelherger
left a comment
There was a problem hiding this comment.
Thanks for this PR! As you know I'm no expert in this area...
@mavit - would you mind sharing your review thoughts of this suggested change?
| # send USR1 to lyriuonmusicserver PID to reset logging | ||
| /bin/kill -USR1 `pgrep lyrionmusicser 2>&1` >/dev/null 2>&1 || true |
There was a problem hiding this comment.
typo in comment, change on purpose in the process name?
There was a problem hiding this comment.
Hi,
Sorry for the typo. I'll fix that straight away.
The change in the process name is the main error that I fixed in that file. The pgrep command uses the string in the /proc/[pid]/stat file to find the PID. In that file only the first 15 characters of the command is used. If you pass longer strings to pgrep it will not find anything, unless you pass the string with the -f flag (and I have seen that this can lead to other unwanted side effects).
If you look at the logrotate file in the Debian package you will see the same there. They have also shortened squeezeboxserver.
But it is only good if someone else has a look at this too. Also maybe at the question about the required version of PERL in the RPM spec file.
Regards, Johan
Fixed a silly typo in a comment.
Seems sensible. We should probably also mention the maximum supported version, so: Requires: (perl >= 5.22 and perl < 5.43)For maximum accuracy, we could even: Requires: (perl(:MODULE_COMPAT_5.22.0) or \
perl(:MODULE_COMPAT_5.24.0) or \
perl(:MODULE_COMPAT_5.26.0) or \
perl(:MODULE_COMPAT_5.28.0) or \
perl(:MODULE_COMPAT_5.30.0) or \
perl(:MODULE_COMPAT_5.32.0) or \
perl(:MODULE_COMPAT_5.34.0) or \
perl(:MODULE_COMPAT_5.36.0) or \
perl(:MODULE_COMPAT_5.38.0) or \
perl(:MODULE_COMPAT_5.40.0) or \
perl(:MODULE_COMPAT_5.42.0)) |
| postrotate | ||
| /bin/kill -USR1 `pgrep lyrionmusicserver >/dev/null 2>&1` >/dev/null 2>&1 || true | ||
| # send USR1 to lyrionmusicserver PID to reset logging | ||
| /bin/kill -USR1 `pgrep lyrionmusicser 2>&1` >/dev/null 2>&1 || true |
There was a problem hiding this comment.
Now that we know that we have systemd, how about the following, to deliver the signal without guessing the process from its name?
| /bin/kill -USR1 `pgrep lyrionmusicser 2>&1` >/dev/null 2>&1 || true | |
| systemctl --kill-whom=main --signal=USR1 kill lyrionmusicserver.service |
There was a problem hiding this comment.
@mavit ,
Thanks for this suggestion. I was looking at this possibility too, but in the end decided against it, mostly because I did not want to change too much. But as you think this is better, then I'll add this. I would just like to do one small change and that is to use the full path to systemctl:
/usr/bin/systemctl --kill-whom=main --signal=USR1 kill lyrionmusicserver.service
Do you have any objections?
Regards, Johan
|
|
||
| # FHS compatible directory structure | ||
| mkdir -p $RPM_BUILD_ROOT%{_sysconfdir}/init.d | ||
| mkdir -p $RPM_BUILDROOT%{_unitdir} |
There was a problem hiding this comment.
We need the following to ensure we have the %{_unitdir} macro:
BuildRequires: systemd-rpm-macros
https://docs.fedoraproject.org/en-US/packaging-guidelines/Systemd/#packaging_filesystem
There was a problem hiding this comment.
OK, will do this. I guess I was lucky that it worked on my server without that macro. I will let you all know when I have implemented and tested this.
Regards, Johan
| /usr/bin/systemctl enable %{shortname}.service >/dev/null 2>&1 || : | ||
| /usr/bin/systemctl restart %{shortname}.service >/dev/null 2>&1 || : |
There was a problem hiding this comment.
The idea of unconditionally enabling the service when the package is upgraded, even if the user has previously disabled it, makes me uneasy. Could we use presets and scriptlets instead?
https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_systemd
There was a problem hiding this comment.
Yes I know this is strange, but it has always been like this, even before systemd support was introduced. The RPM scripts enabled and started the service. Please allow me some time to read up on the guide lines, and then I'll update the respective scripts.
Regards, Johan
I had a look at the Require statement and I have done some tests. I ran into problems so I had to read up a bit before I got it working. According to https://rpm-software-management.github.io/rpm/manual/dependencies.html "Requires" lines can't be continued over several lines (the short paragraph just above the "Conflicts" section). If your proposal with the MODULE_COMPAT_X.XX.X statements is rewritten into a single long line, then it works. As such a long "Requires" line is not really readable, I would prefer to use your other proposal: Requires: (perl >= 5.22 and perl < 5.43) This format works on SUSE based distributions but not on Fedora/RedHat based distributions. Instead the format: Requires: (perl(:VERSION) >= 5.22 and perl(:VERSION) < 5.43) must be used. There is, however, one more snag. Boolean conditions in Requires statements are only allowed in RPM 4.13 and above. CentOS 7, RHEL 7, Fedora 26 and older use older versions of RPM. In the SUSE world, openSUSE and SLES before 15.0 used older versions of RPM. I don't know whether this is only a theoretical issue, i.e. if anyone runs LMS on such old versions of RedHat/SUSE distributions, or not. If it actually is a real issue, then it can be worked around like this in the spec file: Requires: Perl >=5.22 What do you think? Regards, Johan |
Suggestion by mavit, to use systemctl functionality to signal lyruionmusicserver with USR1 after log rotation.
- Added systemd as pre-requisite with the %systemd_requires macro. - Added BuildRequires systemd-rpm-macros - Added use of systemd_pre, systemd_preun, systemd_post and systemd_postun_with_restart to initialise and handle the unit file and service correctly. - Added a systemd preset file to enable lyrionmusicserver at installation time. - Added logic to start lyrionmusicserver immediately during install if it is a first time installation. Upgrades will follow the packaging rules.
Added a systemd preset file to enable lyrionmusicserver immediately at installation.
Added in wrong location.
Added systemd preset file for RPM. Removed Sys V init file for RPM.
|
@mavit , @michaelherger , I have committed changes to my fork now that addresses the points raised by mavit.
The statement (perl >= 5.22 and perl < 5.43) Will only work on SUSE flavours (perl(:VERSION) >= 5.22 and perl(:VERSION) < 5.43) Will only work on Fedora/RedHat flavours. This one Does not work on Fedora/RedHat If we really want to have a perl requirement for both larger or equal to 5.22 and less than 5.43 we need to use the long statement given by mavit here above. But it has to be re-written in a single line as "Requires:" statements can't be written on several lines with line continuation characters. So I ended up with: Requires: (perl(:MODULE_COMPAT_5.22.0) or perl(:MODULE_COMPAT_5.24.0) or perl(:MODULE_COMPAT_5.26.0) or perl(:MODULE_COMPAT_5.28.0) or perl(:MODULE_COMPAT_5.30.0) or perl(:MODULE_COMPAT_5.32.0) or perl(:MODULE_COMPAT_5.34.0) or perl(:MODULE_COMPAT_5.36.0) or perl(:MODULE_COMPAT_5.38.0) or perl(:MODULE_COMPAT_5.40.0) or perl(:MODULE_COMPAT_5.42.0)) I should mention one more thing, it is only possible to use boolean logic in Requires statements on RPM 4.13 and newer. I think there is an overlap, at least in the RedHat world with version using Perl 5.22 and RPM versions lower than 4.13. I don't know how much of a problem this would be.
During upgrades the service will remain disabled if it was disabled before the upgrade started. Also if the service was stopped before the upgrade, it will remain stopped after the upgrade. And of course if the service was enabled and running before the upgrade it will remain that way after the upgrade. I have tested this on openSUSE Leap, openSUSE tumbleweed, Rocky 10 and Fedora 43. Please let me know if you have any questions or remarks. Regards, Johan |
|
I am really sorry, I have to retract what I said about the "Requires" statement for perl here above. I did some more testing on older versions of SUSE and the "Requires" statement I chose does not work on openSUSE 15.6. I am afraid I need to do more testing. Regards, Johan |
Refined the perl Requires statement to work on both SUSE and RedHat based distros. Will work with both rpm and zypper/dnf commands. Now requires minimum v 5.22 and less than v. 5.43. Also changed Recommends: perl(IO::Socket::SSL) to Requires: perl(IO::Socket::SSL) As I noticed that a lot of functionality in LMS will not work without that.
|
I have done some more testing and I can conclude that some of my testing was made more difficult than necessary because I am old. When I sit with a Linux command line in front of me, I instinctively write "rpm -ivh ..." when I want to install anything, rather than "zypper in ..." or "dnf install ..." respectively. Another complication is that SUSE distros and RedHat based distros have chosen different methods to Anyway, I have found that this Requires statement work on opensuse Leap 15.X, opensuse Leap 15, opensuse Tumbleweed, Rocky, v 8, 9, 10 and Fedora 43 Requires: ((perl >= 5.22 or perl(:VERSION) >= 5.22) with (perl < 5.43 or perl(:VERSION) < 5.43)) This works irrespectively of whether rpm or zypper/dnf is used to install the packages. It will still work on older SUSE distributions (with earlier RPM versions) , but only when using zypper in that case. Please also note that the current LMS 9.1 package can only be installed on Rocky 8 with dnf and not with RPM. Installing it with dnf will pull in 113 perl packages that are not really necessary. I have committed the corresponding changes to my fork. I am now finally confident that I found a working solution and would appreciate your feedback. Regards, Johan |
Co-authored-by: Peter Oliver <github.com@mavit.org.uk>
|
@mavit , Thanks, accepted that correction. Regards, Johan |
Co-authored-by: Peter Oliver <github.com@mavit.org.uk>
Removed and updated Require statements as advised by @mavit.
OK, I don't mind very much how we do it. I only normally tend to change as little as possible in the behaviour of scripts/programs I edit. I'll update the spec file in my branch and then we will have to wait and see what Michael writes. Regards, Johan |
|
I've been lurking, happily, because I'm glad there are people out there who know these things. I wouldn't. I really don't have much to add to the discussion... |
Followed advice from Mavit about Requires: statments
mavit
left a comment
There was a problem hiding this comment.
Added a few minor nit-picks.
Co-authored-by: Peter Oliver <github.com@mavit.org.uk>
Improving comments. Co-authored-by: Peter Oliver <github.com@mavit.org.uk>
Improve comments. Co-authored-by: Peter Oliver <github.com@mavit.org.uk>
Improve comments Co-authored-by: Peter Oliver <github.com@mavit.org.uk>
Because the systemd-* RPM macros differs between Red Hat and SUSE distributions. Special handling of the macro systemd_pre is necessary. Is now scripted to be evaluated during installation rather than at build time.
mavit
left a comment
There was a problem hiding this comment.
Looks good to me. Thanks for persisting with it.
|
Hi, Thanks for checking it all. Regards, Johan |
|
Thanks guys! Are we good to merge? And what should be the changelog one-liner? |
|
Hi, Yes I think we we are good to merge. What about this for the One-liner "Removal of SYSV Init support and better systemd support." Regards, Johan |
|
maybe add that this is for the RPM package only so, "Removal of SYSV Init support and better systemd support in the RPM package for Red Hat/SUSE." |
|
Thanks a lot! |
|
I don't see a new build of the RPM package after your merge. Is it because of the complaints I see here above that I haven't signed off my commits? Regards, Johan |
|
Build failed with: Is this a dependency I'd have to load on the build host? The runner (on Github) is an Ubuntu 22.04 (see https://github.com/actions/runner-images/blob/ubuntu22/20260525.156/images/ubuntu/Ubuntu2204-Readme.md). They don't have Fedora or the like runners... Would you have a great idea how to fix this? |
|
Hi, Yes the package systemd-rpm-macros is a build requirement. It contains a single file /usr/lib/rpm/macros.d/macros.systemd. Unfortunately I have no experience with Ubuntu and even less experience with building RPM packages on Ubuntu. I did some searching for Ubuntu and of course the corresponding macros/scriptlets have completely different names. A really horrible solution would be to remove the "BuildRequires: rpm_systemd-macros" in the spec file and drop the file "/usr/lib/rpm/macros.d/macros.systemd" on the build host, and hope for the best. An equally horrible solution would be that I replaced thos macros with shell script code. Maybe @mavit, knows how to solve this elegantly. Regards, Johan |
|
I'm currently trying to make it build in a Fedora container instead. Can you access https://github.com/michaelherger/slimserver/actions/runs/27104259169/job/79990444015? It's failing with: Is this something you've seen before? |
|
Ok, could get past that by removing the executable bit from all the |
|
Scratch that - I didn't push this PR to my repo clone on which I'm testing this out.
New build to test: https://downloads.nixda.ch/lyrionmusicserver-9.2.0-0.1.1780895307.noarch.rpm |
|
https://lyrion.org/downloads/#v920-development-build is now up to date. Thanks again! |
|
Good morning, Thanks for your efforts! I have tested the build now. It works without any issues. I have tested on different versions of SUSE and on different flavours of Red Hat based distributions. I tested clean installs and upgrades. I assume that this will complicate your build procedure in the future. Is that a problem? May I ask what was the reason for the "UNKNOWN" string in the resulting RPM file? I have the same when I build on my own server here at home. I would like to understand the reason. Regards, Johan |
|
I don't know how you're testing. Are you using the |
|
OK, I don't have git installed on my Linux server either, so probably that is the reason then. Yes I use the buildme.pl script. I download the repositories, unpack them and then I run the buildme.pl script. I think it is time for me to start looking at installing git and maybe also learn a bit more about it. |
|
Git is worth the learning curve! I often use it even only locally, without pushing code anywhere, just to have a history of changes etc. And I'm not a power user at all. Just the basics like having different versions, change history, branches etc. |
Fedora. RedHat and SUSE moved from Sys V Init to systemd in 2011 (Fedora
v. 15) and 2014 (RHEL7 and openSUSE/SLES 12) respectively.
The LMS RPM package has supported Sys V Init and systemd in parallel since
v. 8.2. The RPM package installs the systemd support by default if the OS
use systemd (users can of course change this after installation, but why
would they?).
I think it is now time to remove the support for Sys V Init. This mainly
means removing the Sys V Init script and some logic in the RPM spec file.
The file /etc/sysconfig/lyrionmusicserver was used to pass basic start-up
configuration to the Sys V Init script. This file has now been replaced
with a stub file pointing to a file explaining how to change the start-up
configuration using systemd drop in files for the systemd unit.
Further changes: