DevHeads.net

cleaning up installation of systemd *user* units

Hi everyone,

tl;dr: I submitted some PRs. If you didn't get a PR, feel free to ignore this.
Otherwise read on for a lengthy explanation...

We now have a round 100 user units packaged in Fedora, yay!

Our packaging guidelines [1] specify that they should be packaged
essentially in the same way as system units. This means that
a) units which should be enabled by default need a line in
/usr/lib/systemd/user-preset/90-default-user.preset
provided by fedora-release package
b) %systemd_user_post and %systemd_user_preun should be used
to call systemctl preset --global

For this to work, systemd should have a default policy of 'disable *'
for user units. This was missing, so the default policy was 'enable *'.
There's a long-standing ticket to add 'disable *' [2].

For *system* units, systemd calls preset-all in its %post.
For *user* units, this is not done.

On top of this, and probably at least partially caused by this,
various packages that install user units do strange things.
In particular, many units do not use the scriptlets properly.

I'd like to clean this all up for F31:

1. add a default policy of 'disable *' for user units
(<a href="https://src.fedoraproject.org/rpms/fedora-release/pull-request/80" title="https://src.fedoraproject.org/rpms/fedora-release/pull-request/80">https://src.fedoraproject.org/rpms/fedora-release/pull-request/80</a>)
2. call 'preset-all --global' in systemd %post
(will do once the fedora-release PR is merged)
3. use the scriptlets in more packages
(<a href="https://src.fedoraproject.org/rpms/p11-remote/pull-request/1" title="https://src.fedoraproject.org/rpms/p11-remote/pull-request/1">https://src.fedoraproject.org/rpms/p11-remote/pull-request/1</a>
<a href="https://src.fedoraproject.org/rpms/pipewire/pull-request/4" title="https://src.fedoraproject.org/rpms/pipewire/pull-request/4">https://src.fedoraproject.org/rpms/pipewire/pull-request/4</a>
<a href="https://src.fedoraproject.org/rpms/pulseaudio/pull-request/2" title="https://src.fedoraproject.org/rpms/pulseaudio/pull-request/2">https://src.fedoraproject.org/rpms/pulseaudio/pull-request/2</a>
<a href="https://src.fedoraproject.org/rpms/unity-gtk-module/pull-request/1" title="https://src.fedoraproject.org/rpms/unity-gtk-module/pull-request/1">https://src.fedoraproject.org/rpms/unity-gtk-module/pull-request/1</a>
<a href="https://src.fedoraproject.org/fork/zbyszek/rpms/grub2/tree/use-scriptlets" title="https://src.fedoraproject.org/fork/zbyszek/rpms/grub2/tree/use-scriptlets">https://src.fedoraproject.org/fork/zbyszek/rpms/grub2/tree/use-scriptlets</a>
Those can be merged independently of the other changes.)

No action is required from packagers, except for the PRs listed above
to be merged.

grub2 maintainers: please enable PRs in pagure! Otherwise, pull the
changes from my use-scriptlets branch.

[1] <a href="https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_user_units" title="https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_user_units">https://docs.fedoraproject.org/en-US/packaging-guidelines/Scriptlets/#_u...</a>
[2] <a href="https://bugzilla.redhat.com/show_bug.cgi?id=1468501" title="https://bugzilla.redhat.com/show_bug.cgi?id=1468501">https://bugzilla.redhat.com/show_bug.cgi?id=1468501</a>

Current state of *user* units in Fedora:

unit name / static symlink [Install] preset scriptlets notes
-----------------------------------------------+-----------+-----------------------+------------+--------------------
at-spi-dbus-bus.service no
bamfdaemon.service no yes
blueman-applet.service no yes
bup-web.service yes yes not adding preset
colord-session.service no
cros-garcon.service yes yes not adding preset
cros-garcon.service.d/cros-garcon-override.conf
cros-pulse-config.service yes yes not adding preset
cros-sftp.service yes yes not adding preset
dbus-broker.service yes 90-default-user.preset yes
dbus-daemon.service yes yes not wanted by default
dbus.socket yes 90-default-user.preset yes
dunst.service yes
emacs.service yes no
ethumb.service no yes
evolution-addressbook-factory.service no
evolution-calendar-factory.service no
evolution-source-registry.service no
evolution-user-prompter.service no
exit.target no
flatpak-portal.service no
flatpak-session-helper.service no
gamemoded.service yes
glib-pacrunner.service no
gnome-remote-desktop.service no yes
gnome-shell.service no
gnome-shell-wayland.target no
gnome-shell-x11.target no
gnome-terminal-server.service no
gnome-user-share-webdav.service no
graphical-session-pre.target no
graphical-session.target no
grive-changes@.service yes
grive-timer@.service no
grive-timer@.timer yes
grub-boot-success.service no
grub-boot-success.timer no needs preset (<a href="https://src.fedoraproject.org/rpms/fedora-release/pull-request/80" title="https://src.fedoraproject.org/rpms/fedora-release/pull-request/80">https://src.fedoraproject.org/rpms/fedora-release/pull-request/80</a>)
timers.target.wants/grub-boot-success.timer <a href="https://src.fedoraproject.org/fork/zbyszek/rpms/grub2/tree/use-scriptlets" title="https://src.fedoraproject.org/fork/zbyszek/rpms/grub2/tree/use-scriptlets">https://src.fedoraproject.org/fork/zbyszek/rpms/grub2/tree/use-scriptlets</a> (why are PRs disabled??)
gvfs-afc-volume-monitor.service no
gvfs-daemon.service no
gvfs-goa-volume-monitor.service no
gvfs-gphoto2-volume-monitor.service no
gvfs-metadata.service no
gvfs-mtp-volume-monitor.service no
gvfs-udisks2-volume-monitor.service no
mpDris2.service yes
mpris-scrobbler.service yes yes not adding preset
obex.service yes yes needs preset (<a href="https://src.fedoraproject.org/rpms/fedora-release/pull-request/80" title="https://src.fedoraproject.org/rpms/fedora-release/pull-request/80">https://src.fedoraproject.org/rpms/fedora-release/pull-request/80</a>)
onedrive.service yes
org.gnome.Evince.service no
org.gnome.GPaste.service no yes
org.gnome.GPaste.Ui.service no yes
p11-kit-client.service yes no not a real service?
p11-kit-remote@.service no no handled by p11-kit-server.socket
p11-kit-remote.socket yes no
sockets.target.wants/p11-kit-remote.socket <a href="https://src.fedoraproject.org/rpms/p11-remote/pull-request/1" title="https://src.fedoraproject.org/rpms/p11-remote/pull-request/1">https://src.fedoraproject.org/rpms/p11-remote/pull-request/1</a>
p11-kit-server.service yes
p11-kit-server.socket yes
paths.target
pipewire.service yes no handled by pipewire.socket
pipewire.socket yes 90-default-user.preset no
sockets.target.wants/pipewire.socket <a href="https://src.fedoraproject.org/rpms/pipewire/pull-request/4" title="https://src.fedoraproject.org/rpms/pipewire/pull-request/4">https://src.fedoraproject.org/rpms/pipewire/pull-request/4</a>
pulseaudio.service yes yes handled by pulseaudio.socket
pulseaudio.socket yes yes
sockets.target.wants/pulseaudio.socket <a href="https://src.fedoraproject.org/rpms/pulseaudio/pull-request/2" title="https://src.fedoraproject.org/rpms/pulseaudio/pull-request/2">https://src.fedoraproject.org/rpms/pulseaudio/pull-request/2</a>
redshift-gtk.service yes
redshift.service yes
reportd.service yes
rtags.service yes
rtags.socket yes
rygel.service yes no not enabled
sommelier@.service yes yes not adding preset
sommelier-x@.service yes yes not adding preset
squeezelite.service yes
syncevo-dbus-server.service
syncthing.service yes 90-syncthing.preset custom preset should be dropped [#1708297]
systemd-exit.service
systemd-tmpfiles-clean.service
systemd-tmpfiles-clean.timer yes 90-systemd.preset needs preset
systemd-tmpfiles-setup.service yes 90-systemd.preset needs preset
termy-server.service yes
termy-server.socket yes
thunar.service
tracker-extract.service
tracker-miner-fs.service
tracker-miner-rss.service
tracker-store.service
tracker-writeback.service
unity-gtk-module.service yes
default.target.wants/unity-gtk-module.service <a href="https://src.fedoraproject.org/rpms/unity-gtk-module/pull-request/1" title="https://src.fedoraproject.org/rpms/unity-gtk-module/pull-request/1">https://src.fedoraproject.org/rpms/unity-gtk-module/pull-request/1</a>
vino-server.service
xdg-desktop-portal-gtk.service
xdg-desktop-portal.service
xdg-document-portal.service
xdg-permission-store.service
xfce4-notifyd.service
zeitgeist-fts.service
zeitgeist.service

legend:
- unit name / static symlink: the unit name. If the package installs a
static enablement symlink, it is also listed here.
- [Install]: whether the unit file has an [Install] section
- preset: if there's a preset for this unit, the name of the file that contains it
- scriptlets: whether the package has installation scriptlets for the unit
- notes:
not adding preset → I don't think the unit should be enabled by default
not wanted by default → package has been mostly deprecated by something else
needs preset → I think the unit should be enabled by default

Note that unless the unit has "yes" in both "[Install]" and "preset" columns,
it'll not be affected by any preset changes, because either 'systemd preset' is
not called for it, or it has no effect.

I expect that this might not be very clear ;) Sorry. Please post any questions,
I'll try to provide more information.

Zbyszek