From b0ca72658523957be421b86902eb620ccdc1d401 Mon Sep 17 00:00:00 2001 From: Jan Engelhardt Date: Wed, 20 Mar 2019 10:58:41 +0100 Subject: [PATCH] rpm: avoid hiding errors from systemd commands Humans are susceptible to making orthographic errors sometimes. A misspelled "%systemd_post caek.service" would go unnoticed due to all output from systemctl being discarded if and when %post runs. To alleviate this, cease hiding outputs. Then, to account for the potential absence of systemd from the system, add file checks so as to not generate a "command not found" error. --- src/core/macros.systemd.in | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/core/macros.systemd.in b/src/core/macros.systemd.in index a5b7f67e368..9b310c48465 100644 --- a/src/core/macros.systemd.in +++ b/src/core/macros.systemd.in @@ -45,9 +45,9 @@ OrderWithRequires(postun): systemd \ %systemd_post() \ %{expand:%%{?__systemd_someargs_%#}} \ -if [ $1 -eq 1 ] ; then \ +if [ $1 -eq 1 ] && [ -x @bindir@/systemctl ] ; then \ # Initial installation \ - systemctl --no-reload preset %{?*} >/dev/null 2>&1 || : \ + @bindir@/systemctl --no-reload preset %{?*} || : \ fi \ %{nil} @@ -55,17 +55,17 @@ fi \ %systemd_preun() \ %{expand:%%{?__systemd_someargs_%#}} \ -if [ $1 -eq 0 ] ; then \ +if [ $1 -eq 0 ] && [ -x @bindir@/systemctl ] ; then \ # Package removal, not upgrade \ - systemctl --no-reload disable --now %{?*} >/dev/null 2>&1 || : \ + @bindir@/systemctl --no-reload disable --now %{?*} || : \ fi \ %{nil} %systemd_user_preun() \ %{expand:%%{?__systemd_someargs_%#}} \ -if [ $1 -eq 0 ] ; then \ +if [ $1 -eq 0 ] && [ -x @bindir@/systemctl ] ; then \ # Package removal, not upgrade \ - systemctl --global disable %{?*} >/dev/null 2>&1 || : \ + @bindir@/systemctl --global disable %{?*} || : \ fi \ %{nil} @@ -75,9 +75,9 @@ fi \ %systemd_postun_with_restart() \ %{expand:%%{?__systemd_someargs_%#}} \ -if [ $1 -ge 1 ] ; then \ +if [ $1 -ge 1 ] && [ -x @bindir@/systemctl ] ; then \ # Package upgrade, not uninstall \ - systemctl try-restart %{?*} >/dev/null 2>&1 || : \ + @bindir@/systemctl try-restart %{?*} || : \ fi \ %{nil} @@ -92,17 +92,17 @@ fi \ # Deprecated. Use %tmpfiles_create_package instead %tmpfiles_create() \ %{expand:%%{?__systemd_someargs_%#}} \ -systemd-tmpfiles --create %{?*} >/dev/null 2>&1 || : \ +[ -x @bindir@/systemd-tmpfiles ] && @bindir@/systemd-tmpfiles --create %{?*} || : \ %{nil} # Deprecated. Use %sysusers_create_package instead %sysusers_create() \ %{expand:%%{?__systemd_someargs_%#}} \ -systemd-sysusers %{?*} >/dev/null 2>&1 || : \ +[ -x @bindir@/systemd-sysusers ] && @bindir@/systemd-sysusers %{?*} || : \ %{nil} %sysusers_create_inline() \ -systemd-sysusers - </dev/null 2>&1 || : \ +[ -x @bindir@/systemd-sysusers ] && @bindir@/systemd-sysusers - </dev/null 2>&1 || : \ +[ -x @rootlibexecdir@/systemd-sysctl ] && @rootlibexecdir@/systemd-sysctl %{?*} || : \ %{nil} %binfmt_apply() \ %{expand:%%{?__systemd_someargs_%#}} \ -@rootlibexecdir@/systemd-binfmt %{?*} >/dev/null 2>&1 || : \ +[ -x @rootlibexecdir@/systemd-binfmt ] && @rootlibexecdir@/systemd-binfmt %{?*} || : \ %{nil} -- 2.47.3