From 664f945153e4859f61fd6d5a13838b6973839264c6ba5a2e91d35f2b0f60d2a7 Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Mon, 9 Nov 2020 08:43:46 +0000 Subject: [PATCH] - Test for the presence of systemd only once in %service_add_post OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd-rpm-macros?expand=0&rev=45 --- macros.systemd | 32 +++++++++++--------------------- systemd-rpm-macros.changes | 5 +++++ 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/macros.systemd b/macros.systemd index dd5cadb..c4f4748 100644 --- a/macros.systemd +++ b/macros.systemd @@ -85,26 +85,18 @@ fi \ # On install, tell systemd to reload its unit files %service_add_post() \ if [ -x /usr/bin/systemctl ]; then \ + # FIXME: why is this needed ? \ /usr/bin/systemctl daemon-reload || : \ -fi \ \ -if [ $1 -eq 1 ]; then \ - if [ -x /usr/bin/systemctl ]; then \ + if [ $1 -eq 1 ]; then \ /usr/bin/systemctl preset %{?*} || : \ - fi \ -elif [ $1 -gt 1 ]; then \ - for service in %{?*} ; do \ - if [ ! -e "/run/rpm-%{name}-update-$service-new-in-upgrade" ]; then \ - continue \ - fi \ - rm -f "/run/rpm-%{name}-update-$service-new-in-upgrade" \ - if [ ! -x /usr/bin/systemctl ]; then \ - continue \ - fi \ - /usr/bin/systemctl preset "$service" || : \ - done \ - \ - if [ -x /usr/lib/systemd/systemd-sysv-convert ]; then \ + else \ + for service in %{?*} ; do \ + if [ -e "/run/rpm-%{name}-update-$service-new-in-upgrade" ]; then \ + rm -f "/run/rpm-%{name}-update-$service-new-in-upgrade" \ + /usr/bin/systemctl preset "$service" || : \ + fi \ + done \ /usr/lib/systemd/systemd-sysv-convert --apply %{?*} || : \ fi \ fi \ @@ -141,11 +133,9 @@ fi \ # %service_del_postun(fn) \ %service_del_postun_without_restart %{?*} \ -if [ $1 -ge 1 ]; then \ +if [ $1 -ge 1 -a -x /usr/bin/systemctl ]; then \ # Package upgrade, not uninstall \ - if [ -x /usr/bin/systemctl ]; then \ - %{expand:%%_restart_on_update%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \ - fi \ + %{expand:%%_restart_on_update%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \ fi \ %{nil} diff --git a/systemd-rpm-macros.changes b/systemd-rpm-macros.changes index 05e5cba..57bf963 100644 --- a/systemd-rpm-macros.changes +++ b/systemd-rpm-macros.changes @@ -1,3 +1,8 @@ +------------------------------------------------------------------- +Mon Nov 9 07:58:01 UTC 2020 - Franck Bui + +- Test for the presence of systemd only once in %service_add_post + ------------------------------------------------------------------- Mon Nov 9 07:44:40 UTC 2020 - Franck Bui