From 283ce5b8549479ec8eb896730059fb0b07338a80efe2acb03793d84a55a5422f Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Thu, 21 Feb 2019 18:00:10 +0000 Subject: [PATCH 1/6] - Drop $YAST_IS_RUNNING in favor of $SYSTEMD_OFFLINE (bsc#1117489) libzypp now kindly defines SYSTEMD_OFFLINE when appropriate (see bsc#1118758). Therefore we don't need to rely on YAST_IS_RUNNING anymore. It's a tiny step to make the SUSE macros closer to their upstream counterparts. OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd-rpm-macros?expand=0&rev=31 --- macros.systemd | 7 ------- systemd-rpm-macros.changes | 10 ++++++++++ systemd-rpm-macros.spec | 2 +- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/macros.systemd b/macros.systemd index c7ae439..451c26d 100644 --- a/macros.systemd +++ b/macros.systemd @@ -51,12 +51,10 @@ OrderWithRequires(postun): systemd \ %{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 \\\ @@ -65,12 +63,10 @@ OrderWithRequires(postun): systemd \ ) || : %{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 \\\ @@ -115,9 +111,6 @@ fi \ test -n "$FIRST_ARG" || FIRST_ARG="$1" \ [ -d /var/lib/systemd/migrated ] || mkdir -p /var/lib/systemd/migrated || : \ \ -if [ "$YAST_IS_RUNNING" != "instsys" -a -x /usr/bin/systemctl ]; then \ - /usr/bin/systemctl daemon-reload || : \ -fi \ if [ "$FIRST_ARG" -eq 1 ]; then \ if [ -x /usr/bin/systemctl ]; then \ /usr/bin/systemctl preset %{?*} || : \ diff --git a/systemd-rpm-macros.changes b/systemd-rpm-macros.changes index 6ada8f7..a9e9d93 100644 --- a/systemd-rpm-macros.changes +++ b/systemd-rpm-macros.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Thu Feb 21 17:53:18 UTC 2019 - Franck Bui + +- Drop $YAST_IS_RUNNING in favor of $SYSTEMD_OFFLINE (bsc#1117489) + + libzypp now kindly defines SYSTEMD_OFFLINE when appropriate (see + bsc#1118758). Therefore we don't need to rely on YAST_IS_RUNNING + anymore. It's a tiny step to make the SUSE macros closer to their + upstream counterparts. + ------------------------------------------------------------------- Fri Nov 23 12:08:30 UTC 2018 - Franck Bui diff --git a/systemd-rpm-macros.spec b/systemd-rpm-macros.spec index a28052f..9653a4a 100644 --- a/systemd-rpm-macros.spec +++ b/systemd-rpm-macros.spec @@ -1,7 +1,7 @@ # # spec file for package systemd-rpm-macros # -# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 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 From e5d6d1a3e536865535589b4262264a07f147f26f238a6c43d84a368c17cb0bdb Mon Sep 17 00:00:00 2001 From: Thomas Blume Date: Mon, 25 Feb 2019 09:47:37 +0000 Subject: [PATCH 2/6] Accepting request 678270 from home:fbui:branches:Base:System - Introduce %service_del_postun_without_restart This is another step to make the SUSE rpm macros closer to their upstream counterparts. Introduce %service_del_postun_without_restart which should help in getting rid of '-f' and '-n' switches of %service_del_postun. OBS-URL: https://build.opensuse.org/request/show/678270 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd-rpm-macros?expand=0&rev=32 --- macros.systemd | 47 ++++++++++++++++++++++++-------------- systemd-rpm-macros.changes | 11 +++++++++ 2 files changed, 41 insertions(+), 17 deletions(-) diff --git a/macros.systemd b/macros.systemd index 451c26d..9e32daa 100644 --- a/macros.systemd +++ b/macros.systemd @@ -18,6 +18,7 @@ # # %postun # %service_del_postun demo.service +# %service_del_postun_without_restart demo.service # %_unitdir /usr/lib/systemd/system @@ -157,34 +158,46 @@ if [ "$FIRST_ARG" -eq 0 -a -x /usr/bin/systemctl ]; then \ fi \ %{nil} -# On uninstall, tell systemd to reload its unit files +# On uninstall, tell systemd to reload its unit files. +# On update, tell systemd to reload its unit files but don't restart service. # -# 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) \ +%service_del_postun_without_restart() \ 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 || : \ - %{expand:%%_restart_on_update%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \ - fi \ -else # package uninstall \ +if [ "$FIRST_ARG" -eq 0 ]; then \ + # Package removal \ for service in %{?*} ; do \ sysv_service="${service%.*}" \ rm -f "/var/lib/systemd/migrated/$sysv_service" || : \ done \ +fi \ +if [ -x /usr/bin/systemctl ]; then \ + /usr/bin/systemctl daemon-reload || : \ +fi \ +%{nil} + +# On uninstall, tell systemd to reload its unit files +# +# Options used if not in an installation systems +# -f that is force service restart in removal (deprecated) +# -n that do not touch active service (depredacted) +# 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" \ +%service_del_postun_without_restart %{?*} \ +if [ "$FIRST_ARG" -ge 1 ]; then \ + # Package upgrade, not uninstall \ if [ -x /usr/bin/systemctl ]; then \ - /usr/bin/systemctl daemon-reload || : \ + %{expand:%%_restart_on_update%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \ fi \ fi \ %{nil} +# +# Upstream variants +# + %systemd_post() \ if [ $1 -eq 1 -a -x /usr/bin/systemctl ] ; then \ # Initial installation \ diff --git a/systemd-rpm-macros.changes b/systemd-rpm-macros.changes index a9e9d93..a9ed8e6 100644 --- a/systemd-rpm-macros.changes +++ b/systemd-rpm-macros.changes @@ -1,3 +1,14 @@ +------------------------------------------------------------------- +Thu Feb 22 13:00:18 UTC 2019 - Franck Bui + +- Introduce %service_del_postun_without_restart + + This is another step to make the SUSE rpm macros closer to their + upstream counterparts. + + Introduce %service_del_postun_without_restart which should help in + getting rid of '-f' and '-n' switches of %service_del_postun. + ------------------------------------------------------------------- Thu Feb 21 17:53:18 UTC 2019 - Franck Bui From 8685313b9b17beca6540fff4668f79229d08757d36ed48ed3d2b302ed3c6db5b Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Mon, 25 Feb 2019 09:56:11 +0000 Subject: [PATCH 3/6] - Bump version to 4 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd-rpm-macros?expand=0&rev=33 --- systemd-rpm-macros.changes | 5 +++++ systemd-rpm-macros.spec | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/systemd-rpm-macros.changes b/systemd-rpm-macros.changes index a9ed8e6..79dd5ee 100644 --- a/systemd-rpm-macros.changes +++ b/systemd-rpm-macros.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Feb 25 09:55:28 UTC 2019 - Franck Bui + +- Bump version to 4 + ------------------------------------------------------------------- Thu Feb 22 13:00:18 UTC 2019 - Franck Bui diff --git a/systemd-rpm-macros.spec b/systemd-rpm-macros.spec index 9653a4a..2a2b178 100644 --- a/systemd-rpm-macros.spec +++ b/systemd-rpm-macros.spec @@ -17,7 +17,7 @@ Name: systemd-rpm-macros -Version: 3 +Version: 4 Release: 0 Summary: RPM macros for systemd License: LGPL-2.1-or-later From ec2ade1bb27eee4e501bb706e75886468a4c13a262762182f7f6dbc21a3ac280 Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Wed, 27 Feb 2019 12:21:44 +0000 Subject: [PATCH 4/6] - Restore one daemon-reload command OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd-rpm-macros?expand=0&rev=34 --- macros.systemd | 4 ++++ systemd-rpm-macros.changes | 7 +++++++ 2 files changed, 11 insertions(+) diff --git a/macros.systemd b/macros.systemd index 9e32daa..f59bf64 100644 --- a/macros.systemd +++ b/macros.systemd @@ -112,6 +112,10 @@ fi \ test -n "$FIRST_ARG" || FIRST_ARG="$1" \ [ -d /var/lib/systemd/migrated ] || mkdir -p /var/lib/systemd/migrated || : \ \ +if [ -x /usr/bin/systemctl ]; then \ + /usr/bin/systemctl daemon-reload || : \ +fi \ + \ if [ "$FIRST_ARG" -eq 1 ]; then \ if [ -x /usr/bin/systemctl ]; then \ /usr/bin/systemctl preset %{?*} || : \ diff --git a/systemd-rpm-macros.changes b/systemd-rpm-macros.changes index 79dd5ee..a53f6a7 100644 --- a/systemd-rpm-macros.changes +++ b/systemd-rpm-macros.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Wed Feb 27 12:17:18 UTC 2019 - Franck Bui + +- Restore one daemon-reload command + + It was erroneously removed during the drop of $YAST_IS_RUNNING. + ------------------------------------------------------------------- Mon Feb 25 09:55:28 UTC 2019 - Franck Bui From 7b2e3f4d22c8eedfdfafdcc9686033df3525911b64a6cbe584a18b1643fb22ea Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Wed, 27 Feb 2019 14:16:36 +0000 Subject: [PATCH 5/6] - Make sure %_restart_on_update_never and %_stop_on_removal_never don't expand to the empty string Otherwise sequences like the following would result in incorrect shell syntax: if [ ]; then %_restart_on_update_never fi OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd-rpm-macros?expand=0&rev=35 --- macros.systemd | 8 ++++++-- systemd-rpm-macros.changes | 13 +++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/macros.systemd b/macros.systemd index f59bf64..41cdf4c 100644 --- a/macros.systemd +++ b/macros.systemd @@ -54,7 +54,9 @@ OrderWithRequires(postun): systemd \ %_restart_on_update_force() (\ %{?*:/usr/bin/systemctl try-restart %{*}} \ ) || : %{nil} -%_restart_on_update_never() %{?*:# Restart of %{*} skipped} %{nil} + +%_restart_on_update_never() %{?*: : # Restart of %{*} skipped} %{nil} + %_restart_on_update() (\ test -f /etc/sysconfig/services -a \\\ -z "$DISABLE_RESTART_ON_UPDATE" && . /etc/sysconfig/services\ @@ -66,7 +68,9 @@ OrderWithRequires(postun): systemd \ %_stop_on_removal_force() ( \ %{?*:/usr/bin/systemctl stop %{*}}\ ) || : %{nil} -%_stop_on_removal_never() %{?*:# Stop of %{*} skipped} %{nil} + +%_stop_on_removal_never() %{?*: : # Stop of %{*} skipped} %{nil} + %_stop_on_removal() (\ test -f /etc/sysconfig/services -a \\\ -z "$DISABLE_STOP_ON_REMOVAL" && . /etc/sysconfig/services\ diff --git a/systemd-rpm-macros.changes b/systemd-rpm-macros.changes index a53f6a7..8e1bd71 100644 --- a/systemd-rpm-macros.changes +++ b/systemd-rpm-macros.changes @@ -1,3 +1,16 @@ +------------------------------------------------------------------- +Wed Feb 27 14:13:28 UTC 2019 - Franck Bui + +- Make sure %_restart_on_update_never and %_stop_on_removal_never + don't expand to the empty string + + Otherwise sequences like the following would result in incorrect + shell syntax: + + if [ ]; then + %_restart_on_update_never + fi + ------------------------------------------------------------------- Wed Feb 27 12:17:18 UTC 2019 - Franck Bui From f337315c0b5a579c6b14c5d001381b48bdf4051ff27b6fe7c97ce6a51ddfd8e6 Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Fri, 1 Mar 2019 09:27:15 +0000 Subject: [PATCH 6/6] Accepting request 680383 from home:fbui:branches:Base:System - Fix %_restart_on_update_force: drop one extra trailing '}' Thanks Werner for spotting. - Simplify %_restart_on_update and %_stop_on_removal There's no need to spawn sub shells when these macros are used. - Macros arguments are mandatory Especially in %_restart_on_update_never and %_stop_on_removal_never, let's assume that they always receive unit names as arguments. This allows to make them slightly simpler (less rpm macro black magic). Callers will fail earlier if no arguments are passed anyway. OBS-URL: https://build.opensuse.org/request/show/680383 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd-rpm-macros?expand=0&rev=36 --- macros.systemd | 40 +++++++++++++++----------------------- systemd-rpm-macros.changes | 25 ++++++++++++++++++++++++ 2 files changed, 41 insertions(+), 24 deletions(-) diff --git a/macros.systemd b/macros.systemd index 41cdf4c..be35537 100644 --- a/macros.systemd +++ b/macros.systemd @@ -51,33 +51,25 @@ OrderWithRequires(preun): systemd \ OrderWithRequires(postun): systemd \ %{nil} -%_restart_on_update_force() (\ - %{?*:/usr/bin/systemctl try-restart %{*}} \ - ) || : %{nil} +%_restart_on_update_force() /usr/bin/systemctl try-restart %{*} || : %{nil} +%_restart_on_update_never() : # Restart of %{*} skipped %{nil} -%_restart_on_update_never() %{?*: : # Restart of %{*} skipped} %{nil} +%_restart_on_update() \ + test -z "$DISABLE_RESTART_ON_UPDATE" -a -f /etc/sysconfig/services &&\\\ + . /etc/sysconfig/services \ + test "$DISABLE_RESTART_ON_UPDATE" != yes -a "$DISABLE_RESTART_ON_UPDATE" != 1 &&\\\ + /usr/bin/systemctl try-restart %{*} || : \ +%{nil} -%_restart_on_update() (\ - 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_on_removal_force() /usr/bin/systemctl stop %{*} || : %{nil} +%_stop_on_removal_never() : # Stop of %{*} skipped} %{nil} -%_stop_on_removal_force() ( \ - %{?*:/usr/bin/systemctl stop %{*}}\ - ) || : %{nil} - -%_stop_on_removal_never() %{?*: : # Stop of %{*} skipped} %{nil} - -%_stop_on_removal() (\ - 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} +%_stop_on_removal() \ + test -z "$DISABLE_STOP_ON_REMOVAL" -a -f /etc/sysconfig/services &&\\\ + . /etc/sysconfig/services \ + test "$DISABLE_STOP_ON_REMOVAL" != yes -a "$DISABLE_STOP_ON_REMOVAL" != 1 &&\\\ + /usr/bin/systemctl stop %{*} || : \ +%{nil} %service_add_pre() \ test -n "$FIRST_ARG" || FIRST_ARG="$1" \ diff --git a/systemd-rpm-macros.changes b/systemd-rpm-macros.changes index 8e1bd71..0b42340 100644 --- a/systemd-rpm-macros.changes +++ b/systemd-rpm-macros.changes @@ -1,3 +1,28 @@ +------------------------------------------------------------------- +Fri Mar 1 08:18:07 UTC 2019 - Franck Bui + +- Fix %_restart_on_update_force: drop one extra trailing '}' + + Thanks Werner for spotting. + +------------------------------------------------------------------- +Wed Feb 27 17:43:13 UTC 2019 - Franck Bui + +- Simplify %_restart_on_update and %_stop_on_removal + + There's no need to spawn sub shells when these macros are used. + +------------------------------------------------------------------- +Wed Feb 27 16:57:04 UTC 2019 - Franck Bui + +- Macros arguments are mandatory + + Especially in %_restart_on_update_never and %_stop_on_removal_never, + let's assume that they always receive unit names as arguments. This + allows to make them slightly simpler (less rpm macro black magic). + + Callers will fail earlier if no arguments are passed anyway. + ------------------------------------------------------------------- Wed Feb 27 14:13:28 UTC 2019 - Franck Bui