From 163b073fa13414324270613fcbaa4b7ac8633f1cefcc0a886f3150d8dd3ebdee Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Tue, 10 Nov 2020 11:04:59 +0000 Subject: [PATCH] - Introduce %service_del_postun_with_restart() It's the counterpart of %service_del_postun_without_restart() and replaces the '-f' option of %service_del_postun(). - Expand %service_del_postun_without_restart in %service_del_postun OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd-rpm-macros?expand=0&rev=52 --- macros.systemd | 33 ++++++++++++++++++++++++++------- systemd-rpm-macros.changes | 10 ++++++++++ 2 files changed, 36 insertions(+), 7 deletions(-) diff --git a/macros.systemd b/macros.systemd index 8a36a59..7d24898 100644 --- a/macros.systemd +++ b/macros.systemd @@ -118,25 +118,44 @@ fi \ # On uninstall, tell systemd to reload its unit files. # On update, tell systemd to reload its unit files but don't restart service. # +# It ignores the content of /etc/sysconfig/services +# %service_del_postun_without_restart() \ if [ -x /usr/bin/systemctl ]; then \ /usr/bin/systemctl daemon-reload || : \ fi \ %{nil} +# On uninstall, tell systemd to reload its unit files. +# On update, tell systemd to reload its unit files and restart service. +# +# It ignores the content of /etc/sysconfig/services +# +%service_del_postun_with_restart() \ +if [ -x /usr/bin/systemctl ]; then \ + /usr/bin/systemctl daemon-reload || : \ + if [ $1 -ge 1 ]; then \ + # Package upgrade, not uninstall \ + /usr/bin/systemctl try-restart %{?*} || : \ + fi \ +fi \ +%{nil} + # On uninstall, tell systemd to reload its unit files # -# Options used if not in an installation systems -# -f : force service restart on update (deprecated) -# -n : do not touch active service (deprecated, replaced by %service_del_postun_without_restart) +# Deprecated options, please do not use in new code: +# -f : force restart on update (replaced by %service_del_postun_with_restart) +# -n : don't restart on update (replaced by %service_del_postun_without_restart) # # The default is to read DISABLE_RESTART_ON_UPDATE from /etc/sysconfig/services # %service_del_postun(fn) \ -%service_del_postun_without_restart %{?*} \ -if [ $1 -ge 1 -a -x /usr/bin/systemctl ]; then \ - # Package upgrade, not uninstall \ - %{expand:%%_restart_on_update%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \ +if [ -x /usr/bin/systemctl ]; then \ + /usr/bin/systemctl daemon-reload || : \ + if [ $1 -ge 1 ]; then \ + # Package upgrade, not uninstall \ + %{expand:%%_restart_on_update%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \ + fi \ fi \ %{nil} diff --git a/systemd-rpm-macros.changes b/systemd-rpm-macros.changes index f95d94f..27cd914 100644 --- a/systemd-rpm-macros.changes +++ b/systemd-rpm-macros.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Tue Nov 10 09:32:31 UTC 2020 - Franck Bui + +- Introduce %service_del_postun_with_restart() + + It's the counterpart of %service_del_postun_without_restart() and + replaces the '-f' option of %service_del_postun(). + +- Expand %service_del_postun_without_restart in %service_del_postun + ------------------------------------------------------------------- Tue Nov 10 09:13:03 UTC 2020 - Franck Bui