From a4d73fe80973953e460c7b0f10309f9b5016244f221b31a83be281379bff0acc Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Fri, 12 Feb 2021 11:45:54 +0000 Subject: [PATCH] - Make upstream %systemd_{pre,post,preun,postun} aliases to their SUSE counterparts Packagers can now choose to use the upstream or the SUSE variants indifferently. For consistency the SUSE variants should be preferred since almost all SUSE packages already use them but the upstream versions might be usefull in certain cases where packages need to support multiple distros based on RPM. OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd-rpm-macros?expand=0&rev=60 --- macros.systemd | 41 ++++++++++---------------------------- systemd-rpm-macros.changes | 12 +++++++++++ 2 files changed, 23 insertions(+), 30 deletions(-) diff --git a/macros.systemd b/macros.systemd index 586b1e8..3d756b5 100644 --- a/macros.systemd +++ b/macros.systemd @@ -3,7 +3,8 @@ # ### # -# When a package install systemd unit files, it should use the following macros: +# When a package install systemd unit files, it should use the +# following macros: # # add %systemd_requires in the specfile # @@ -20,6 +21,10 @@ # %service_del_postun demo.service # %service_del_postun_without_restart demo.service # +# Note: the upstream variants are also available and are aliases to +# their SUSE counterparts. However for consistency the SUSE macros +# should be preferred unless the package is intended to be portable +# across multiple distributions based on RPM. %_unitdir /usr/lib/systemd/system %_userunitdir /usr/lib/systemd/user @@ -161,22 +166,14 @@ fi \ # Upstream variants # -%systemd_post() \ -if [ $1 -eq 1 -a -x /usr/bin/systemctl ] ; then \ - # Initial installation \ - /usr/bin/systemctl --no-reload preset %{?*} || : \ -fi \ -%{nil} +%systemd_pre() %{expand::%%service_add_pre %{?**}} +%systemd_post() %{expand::%%service_add_post %{?**}} +%systemd_preun() %{expand::%%service_del_preun %{?**}} +%systemd_postun() %{expand::%%service_del_postun_without_restart %{?**}} +%systemd_postun_with_restart() %{expand::%%service_del_postun %{?**}} %systemd_user_post() %{expand:%systemd_post \\--global %%{?*}} -%systemd_preun() \ -if [ $1 -eq 0 -a -x /usr/bin/systemctl ]; then \ - # Package removal, not upgrade \ - /usr/bin/systemctl --no-reload disable --now %{?*} || : \ -fi \ -%{nil} - %systemd_user_preun() \ if [ $1 -eq 0 -a -x /usr/bin/systemctl ]; then \ # Package removal, not upgrade \ @@ -184,25 +181,9 @@ if [ $1 -eq 0 -a -x /usr/bin/systemctl ]; then \ fi \ %{nil} -%systemd_postun() \ -if [ -x /usr/bin/systemctl ]; then \ - /usr/bin/systemctl daemon-reload || : \ -fi \ -%{nil} - %systemd_user_postun() %{nil} %systemd_user_postun_with_restart() %{nil} -%systemd_postun_with_restart() \ -if [ -x /usr/bin/systemctl ]; then \ - /usr/bin/systemctl daemon-reload || : \ -fi \ -if [ $1 -ge 1 -a -x /usr/bin/systemctl ]; then \ - # Package upgrade, not uninstall \ - /usr/bin/systemctl try-restart %{?*} || : \ -fi \ -%{nil} - %udev_hwdb_update() \ [ -x /usr/bin/udevadm ] && /usr/bin/udevadm hwdb --update || : \ %{nil} diff --git a/systemd-rpm-macros.changes b/systemd-rpm-macros.changes index 51206a1..b719ee0 100644 --- a/systemd-rpm-macros.changes +++ b/systemd-rpm-macros.changes @@ -1,3 +1,15 @@ +------------------------------------------------------------------- +Fri Feb 12 11:02:57 UTC 2021 - Franck Bui + +- Make upstream %systemd_{pre,post,preun,postun} aliases to their SUSE + counterparts + + Packagers can now choose to use the upstream or the SUSE variants + indifferently. For consistency the SUSE variants should be preferred + since almost all SUSE packages already use them but the upstream + versions might be usefull in certain cases where packages need to + support multiple distros based on RPM. + ------------------------------------------------------------------- Fri Feb 12 10:23:35 UTC 2021 - Franck Bui