From 35441a3b44d11f38c6f374738e0fa72eefeafc192712741f42c5748bb10aaeb3 Mon Sep 17 00:00:00 2001 From: "Dr. Werner Fink" Date: Thu, 3 Mar 2016 10:09:49 +0000 Subject: [PATCH] . OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd-rpm-macros?expand=0&rev=14 --- macros.systemd | 83 +++++++++++++++++++++++++++++--------- systemd-rpm-macros.changes | 7 ++++ 2 files changed, 70 insertions(+), 20 deletions(-) diff --git a/macros.systemd b/macros.systemd index 4e9dca2..0fe4c5e 100644 --- a/macros.systemd +++ b/macros.systemd @@ -50,19 +50,33 @@ Requires(postun): systemd \ %_ntpunitsdir /usr/lib/systemd/ntp-units.d %_binfmtdir /usr/lib/binfmt.d -%_restart_check_systemctl \ - test "$DISABLE_RESTART_ON_UPDATE" = yes && exit 0 \ - test -f /etc/sysconfig/services && . /etc/sysconfig/services \ - test "$YAST_IS_RUNNING" = instsys && exit 0 \ - test "$DISABLE_RESTART_ON_UPDATE" = yes && exit 0 \ - /usr/bin/systemctl try-restart %{nil} +%_restart_on_update_force() (\ + test "$YAST_IS_RUNNING" = instsys && exit 0 \ + %{?*:/usr/bin/systemctl try-restart %{*}} \ + ) || : %{nil} +%_restart_on_update_never() %{?*:# Restart of %{*} skipped} %{nil} +%_restart_on_update() (\ + test "$YAST_IS_RUNNING" = instsys && exit 0\ + test -f /etc/sysconfig/services -a \\\ + -z "$DISABLE_RESTART_ON_UPDATE" && . /etc/sysconfig/services\ + test "$DISABLE_RESTART_ON_UPDATE" = yes -o \\\ + "$DISABLE_RESTART_ON_UPDATE" = 1 && exit 0\ + %{?*:/usr/bin/systemctl try-restart %{*}}\ + ) || : %{nil} -%_stop_check_systemctl \ - test "$DISABLE_STOP_ON_REMOVAL" = yes && exit 0 \ - test -f /etc/sysconfig/services && . /etc/sysconfig/services \ - test "$YAST_IS_RUNNING" = instsys && exit 0 \ - test "$DISABLE_STOP_ON_REMOVAL" = yes && exit 0 \ - /usr/bin/systemctl stop %{nil} +%_stop_on_removal_force() ( \ + test "$YAST_IS_RUNNING" = instsys && exit 0\ + %{?*:/usr/bin/systemctl stop %{*}}\ + ) || : %{nil} +%_stop_on_removal_never() %{?*:# Stop of %{*} skipped} %{nil} +%_stop_on_removal() (\ + test "$YAST_IS_RUNNING" = instsys && exit 0\ + test -f /etc/sysconfig/services -a \\\ + -z "$DISABLE_STOP_ON_REMOVAL" && . /etc/sysconfig/services\ + test "$DISABLE_STOP_ON_REMOVAL" = yes -o \\\ + "$DISABLE_STOP_ON_REMOVAL" = 1 && exit 0\ + %{?*:/usr/bin/systemctl stop %{*}}\ + ) || : %{nil} %service_add_pre() \ test -n "$FIRST_ARG" || FIRST_ARG="$1" \ @@ -130,23 +144,38 @@ fi \ %{nil} # On uninstall, disable and stop services -%service_del_preun() \ +# +# Options used if not in an installation systems +# -f that is fore service stop in removal +# -n that do not touch active service +# the default is to check for DISABLE_STOP_ON_REMOVAL environment +# variable if not found use the value read from /etc/sysconfig/services +# +%service_del_preun(fn) \ test -n "$FIRST_ARG" || FIRST_ARG="$1" \ if [ "$FIRST_ARG" -eq 0 -a -x /usr/bin/systemctl ]; then \ # Package removal, not upgrade \ /usr/bin/systemctl --no-reload disable %{?*} || : \ - ( %_stop_check_systemctl %{?*} || : ) \ + %{expand:%%_stop_on_removal%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \ fi \ %{nil} # On uninstall, tell systemd to reload its unit files -%service_del_postun() \ +# +# Options used if not in an installation systems +# -f that is fore service restart in removal +# -n that do not touch active service +# the default is to check for DISABLE_RESTART_ON_UPDATE environment +# variable if not found use the value read from /etc/sysconfig/services +# + +%service_del_postun(fn) \ test -n "$FIRST_ARG" || FIRST_ARG="$1" \ if [ "$FIRST_ARG" -ge 1 ]; then \ # Package upgrade, not uninstall \ if [ -x /usr/bin/systemctl ]; then \ /usr/bin/systemctl daemon-reload || : \ - ( %_restart_check_systemctl %{?*} || : ) \ + %{expand:%%_restart_on_update%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \ fi \ else # package uninstall \ for service in %{?*} ; do \ @@ -159,21 +188,35 @@ else # package uninstall \ fi \ %{nil} -%systemd_post() \ +# +# Options used if not in an installation systems +# -f that is fore service stop in removal +# -n that do not touch active service +# the default is to check for DISABLE_STOP_ON_REMOVAL environment +# variable if not found use the value read from /etc/sysconfig/services +# +%systemd_post(fn) \ if [ "$1" -eq 0 -a -x /usr/bin/systemctl ]; then \ # Package removal, not upgrade \ /usr/bin/systemctl --no-reload disable %{?*} || : \ - ( %_stop_check_systemctl %{?*} || : ) \ + %{expand:%%_stop_on_removal%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \ fi \ %{nil} %systemd_user_post() %systemd_post --user --global %{?*} -%systemd_preun() \ +# +# Options used if not in an installation systems +# -f that is fore service stop in removal +# -n that do not touch active service +# the default is to check for DISABLE_STOP_ON_REMOVAL environment +# variable if not found use the value read from /etc/sysconfig/services +# +%systemd_preun(fn) \ if [ "$1" -eq 0 -a -x /usr/bin/systemctl ]; then \ # Package removal, not upgrade \ /usr/bin/systemctl --no-reload disable %{?*} || : \ - ( %_stop_check_systemctl %{?*} || : ) \ + %{expand:%%_stop_on_removal%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \ fi \ %{nil} diff --git a/systemd-rpm-macros.changes b/systemd-rpm-macros.changes index cc55a14..1a4f55b 100644 --- a/systemd-rpm-macros.changes +++ b/systemd-rpm-macros.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Thu Mar 3 10:01:52 UTC 2016 - werner@suse.de + +- Allow the packagers to specify the options -f and -n on the + macros %service_del_preun(), %service_del_postun(), %systemd_post(), + and %systemd_preun() (boo#968405) + ------------------------------------------------------------------- Sat Feb 27 10:18:55 UTC 2016 - dimstar@opensuse.org