11
0

Accepting request 365189 from Base:System

- 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) 

- Also honor DISABLE_STOP_ON_REMOVAL and DISABLE_RESTART_ON_UPDATE
  when specified by a package directly in the .spec file. Some
  package know that a restart of their service is fatal
  (boo#968405).

OBS-URL: https://build.opensuse.org/request/show/365189
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd-rpm-macros?expand=0&rev=15
This commit is contained in:
2016-03-05 12:04:54 +00:00
committed by Git OBS Bridge
3 changed files with 79 additions and 19 deletions

View File

@@ -50,17 +50,33 @@ Requires(postun): systemd \
%_ntpunitsdir /usr/lib/systemd/ntp-units.d
%_binfmtdir /usr/lib/binfmt.d
%_restart_check_systemctl \
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 -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" \
@@ -128,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 \
@@ -157,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}

View File

@@ -1,3 +1,18 @@
-------------------------------------------------------------------
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
- Also honor DISABLE_STOP_ON_REMOVAL and DISABLE_RESTART_ON_UPDATE
when specified by a package directly in the .spec file. Some
package know that a restart of their service is fatal
(boo#968405).
-------------------------------------------------------------------
Fri Nov 20 16:53:23 UTC 2015 - werner@suse.de

View File

@@ -1,7 +1,7 @@
#
# spec file for package systemd-rpm-macros
#
# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany.
# Copyright (c) 2016 SUSE LINUX GmbH, Nuernberg, Germany.
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed