From cd7def807ec54de5f66806c22d8281a0d66530a9 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Sep 12 2023 15:06:17 +0000 Subject: [PATCH 1/2] systemd: describe %systemd_postun_with_reload and user variants Those were added based on discussion on fedora-devel [1]. Systemd implementation in [2]. The new macros are available in f39+ (systemd >= 254.1-8). I'll do a backport for f38/f37 once this patch for the packaging guidelines is accepted. [1] https://lists.fedoraproject.org/archives/list/devel@lists.fedoraproject.org/message/IJSUGIEJNYZZRE53FF4YFUEBRHRAVIXR/ [2] https://github.com/systemd/systemd/pull/28521 --- diff --git a/guidelines/modules/ROOT/pages/Scriptlets.adoc b/guidelines/modules/ROOT/pages/Scriptlets.adoc index 902bffb..3a7493a 100644 --- a/guidelines/modules/ROOT/pages/Scriptlets.adoc +++ b/guidelines/modules/ROOT/pages/Scriptlets.adoc @@ -412,10 +412,19 @@ BuildRequires: systemd-rpm-macros Some services do not support being restarted (e.g. D-Bus and various storage daemons). If your service should not be restarted upon upgrade, +but should be reloaded instead, then use the following `+%postun+` scriptlet instead of the one shown above: .... %postun +%systemd_postun_with_reload apache-httpd.service +.... + +If your service should not be restarted or reloaded, +then use the following `+%postun+` scriptlet instead: + +.... +%postun %systemd_postun apache-httpd.service .... @@ -441,8 +450,17 @@ BuildRequires: systemd-rpm-macros %preun %systemd_user_preun %{name}.service + +%postun +%systemd_user_postun_with_restart %{name}.service +%systemd_user_postun_with_reload %{name}.service +%systemd_user_postun %{name}.service .... +Macros `+%systemd_user_postun_with_restart+` and `+%systemd_user_postun_with_reload+` +iterate over the running user manager instances +and request the restart and reload operations for the specified units in each one. + ===== Dependencies on the systemd package If package scriptlets call other systemd tools, for example `systemd-tmpfiles`, From 545c0808bafdb20be32a224594ef91e835cebcc7 Mon Sep 17 00:00:00 2001 From: Zbigniew Jędrzejewski-Szmek Date: Sep 12 2023 15:06:17 +0000 Subject: [PATCH 2/2] systemd: recommend using just one macro invocation --- diff --git a/guidelines/modules/ROOT/pages/Scriptlets.adoc b/guidelines/modules/ROOT/pages/Scriptlets.adoc index 3a7493a..9f9cfde 100644 --- a/guidelines/modules/ROOT/pages/Scriptlets.adoc +++ b/guidelines/modules/ROOT/pages/Scriptlets.adoc @@ -428,6 +428,9 @@ then use the following `+%postun+` scriptlet instead: %systemd_postun apache-httpd.service .... +Those macros accept multiple unit name arguments. +It is better to use a single invocation to reduce the number of calls. + If your package includes one or more systemd units that need to be enabled by default on package installation, they MUST be covered by the xref:DefaultServices.adoc[Fedora preset policy].