#647 No mention of macros for systemd scriptlets for user units
Closed: Fixed None Opened 2 years ago by amigadave.

https://fedoraproject.org/wiki/Packaging:Scriptlets#Systemd has documentation on the scriptlets to use when installing system units. However, there is no mention of the macros which should be used for user units: %systemd_user_post, %systemd_user_preun, %systemd_user_postun and %systemd_user_postun_with_restart. It would be good to explicitly mention these macros as part of the text, to make it clear that they are allowed in the case of user units.


How would you explicitly mention them? What rules are there for their use? I've never even heard of these macros, nor do I understand what user units would do and how that would be useful in the context of a system-wide Fedora package.

The guideline section you reference is essentially as it was provided to us by the systemd maintainers, who elected not to mention user units. I do not know why.

Please provide a draft or propose some text for us to use, and get buy in from the systemd maintainers.

Replying to [comment:1 tibbs]:

How would you explicitly mention them? What rules are there for their use? I've never even heard of these macros, nor do I understand what user units would do and how that would be useful in the context of a system-wide Fedora package.

I would clarify in the first paragraph that the existing macros are for system units, and that macros for user units are also available. I would replace the first paragraph with:

The systemd package provides a set of helper macros to handle systemd scriptlet operations. These macros support systemd "presets", as documented in Features/PackagePresets. The %systemd_requires macro is a shortcut for listing the per-scriptlet dependencies on systemd. For a typical service that provides system units (those that are installed under %_unitdir), the following scriptlets should be used:

Then, after the paragraph about systemd units active by default that must be covered by the preset policy, I would insert another paragraph:

There are additional macros for services which provide user units (those that are installed under %_userunitdir), and those should be used similarly to those for system units. The user unit macros are: %systemd_user_post, %systemd_user_preun, %systemd_user_postun and %systemd_user_postun_with_restart.

Replying to [comment:1 tibbs]:

The guideline section you reference is essentially as it was provided to us by the systemd maintainers, who elected not to mention user units. I do not know why.

Please provide a draft or propose some text for us to use, and get buy in from the systemd maintainers.

I have asked zbyszek if he can take a look (I do not seem able to cc him myself).

When those guidelines were added, user units weren't really used, so there wasn't a good reason to add them to the guidelines. Now we are starting to use them in Fedora, so it's probably good to update the guidelines.

%systemd_user_postun and %systemd_user_postun_with_restart are empty. For user units we only support the global enable/disable operations, but don't do anything to the configuration of individual users, nor do we start or stop services for them. In the future such functionality might be added, but it's not even planned yet, so I think it'd be better not to mention those two at all. So maybe something like this:

There are additional macros for user units (those that are installed under %_userunitdir) that should be used similarly to those for system units. They enable and disable user units according to presets. The macros that should be used are %systemd_user_post (to be used in %post) and %systemd_user_preun (to be used in %preun).

Example:
{{{
%{?systemd_requires}
BuildRequires: systemd

[...]
%post
%systemd_user_post %{name}.service

%preun
%systemd_user_preun %{name}.service
}}}

We discussed this at this weeks meeting (https://meetbot-raw.fedoraproject.org/fedora-meeting-1/2016-10-27/fpc.2016-10-27-16.00.txt):

I seem to have written this up a while ago but....

Announcement text:

The guidelines for systemd scriptlets were updated with mention of the macros to be used for systemd user units.

Metadata Update from @zbyszek:
- Issue assigned to tibbs

2 years ago

%systemd_user_postun and %systemd_user_postun_with_restart are empty. For user units we only support the global enable/disable operations, but don't do anything to the configuration of individual users, nor do we start or stop services for them. In the future such functionality might be added

Are there any other issues (pagure or otherwise) that I can watch to keep tabs on this?

Login to comment on this ticket.

Metadata