From 281014b73ee044e83b9df8706adf2e324f08f746 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 14 Jul 2020 16:25:32 +0200 Subject: rpm: adjust various macros to print macro name in the error message Based on initial patch by Jan Engelhardt . Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1856122. --- src/core/macros.systemd.in | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) (limited to 'src/core') diff --git a/src/core/macros.systemd.in b/src/core/macros.systemd.in index 80827b6ea4..df87b6eff0 100644 --- a/src/core/macros.systemd.in +++ b/src/core/macros.systemd.in @@ -40,12 +40,12 @@ OrderWithRequires(preun): systemd \ OrderWithRequires(postun): systemd \ %{nil} -%__systemd_someargs_0() %{error:This macro requires some arguments} +%__systemd_someargs_0(:) %{error:The %%%1 macro requires some arguments} %__systemd_twoargs_2() %{nil} %systemd_post() \ -%{expand:%%{?__systemd_someargs_%#}} \ -if [ $1 -eq 1 ] && [ -x @bindir@/systemctl ] ; then \ +%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# systemd_post}} \ +if [ $1 -eq 1 ] && [ -x @bindir@/systemctl ]; then \ # Initial installation \ @bindir@/systemctl --no-reload preset %{?*} || : \ fi \ @@ -54,34 +54,40 @@ fi \ %systemd_user_post() %{expand:%systemd_post \\--global %%{?*}} %systemd_preun() \ -%{expand:%%{?__systemd_someargs_%#}} \ -if [ $1 -eq 0 ] && [ -x @bindir@/systemctl ] ; then \ +%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# systemd_preun}} \ +if [ $1 -eq 0 ] && [ -x @bindir@/systemctl ]; then \ # Package removal, not upgrade \ @bindir@/systemctl --no-reload disable --now %{?*} || : \ fi \ %{nil} %systemd_user_preun() \ -%{expand:%%{?__systemd_someargs_%#}} \ -if [ $1 -eq 0 ] && [ -x @bindir@/systemctl ] ; then \ +%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# systemd_user_preun}} \ +if [ $1 -eq 0 ] && [ -x @bindir@/systemctl ]; then \ # Package removal, not upgrade \ @bindir@/systemctl --global disable %{?*} || : \ fi \ %{nil} -%systemd_postun() %{expand:%%{?__systemd_someargs_%#}}%{nil} +%systemd_postun() \ +%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# systemd_postun}} \ +%{nil} -%systemd_user_postun() %{expand:%%{?__systemd_someargs_%#}}%{nil} +%systemd_user_postun() \ +%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# systemd_user_postun}} \ +%{nil} %systemd_postun_with_restart() \ -%{expand:%%{?__systemd_someargs_%#}} \ -if [ $1 -ge 1 ] && [ -x @bindir@/systemctl ] ; then \ +%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# systemd_postun_with_restart}} \ +if [ $1 -ge 1 ] && [ -x @bindir@/systemctl ]; then \ # Package upgrade, not uninstall \ @bindir@/systemctl try-restart %{?*} || : \ fi \ %{nil} -%systemd_user_postun_with_restart() %{expand:%%{?__systemd_someargs_%#}}%{nil} +%systemd_user_postun_with_restart() \ +%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# systemd_postun_with_restart}} \ +%{nil} %udev_hwdb_update() %{nil} @@ -91,13 +97,13 @@ fi \ # Deprecated. Use %tmpfiles_create_package instead %tmpfiles_create() \ -%{expand:%%{?__systemd_someargs_%#}} \ +%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# tmpfiles_create}} \ [ -x @bindir@/systemd-tmpfiles ] && @bindir@/systemd-tmpfiles --create %{?*} || : \ %{nil} # Deprecated. Use %sysusers_create_package instead %sysusers_create() \ -%{expand:%%{?__systemd_someargs_%#}} \ +%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# sysusers_create}} \ [ -x @bindir@/systemd-sysusers ] && @bindir@/systemd-sysusers %{?*} || : \ %{nil} @@ -148,11 +154,11 @@ SYSTEMD_INLINE_EOF\ %{nil} %sysctl_apply() \ -%{expand:%%{?__systemd_someargs_%#}} \ +%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# sysctl_apply}} \ [ -x @rootlibexecdir@/systemd-sysctl ] && @rootlibexecdir@/systemd-sysctl %{?*} || : \ %{nil} %binfmt_apply() \ -%{expand:%%{?__systemd_someargs_%#}} \ +%{expand:%%{?__systemd_someargs_%#:%%__systemd_someargs_%# binfmt_apply}} \ [ -x @rootlibexecdir@/systemd-binfmt ] && @rootlibexecdir@/systemd-binfmt %{?*} || : \ %{nil} -- cgit v1.2.1 From 1061fc1c1734ae67afe015fb6adbf25fa247b407 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Tue, 14 Jul 2020 16:30:46 +0200 Subject: rpm: include macro name in errors for two args macros too --- src/core/macros.systemd.in | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/core') diff --git a/src/core/macros.systemd.in b/src/core/macros.systemd.in index df87b6eff0..8832c4a6f4 100644 --- a/src/core/macros.systemd.in +++ b/src/core/macros.systemd.in @@ -127,7 +127,7 @@ SYSTEMD_INLINE_EOF\ # %files # %{_sysusersdir}/%{name}.conf %sysusers_create_package() \ -%{expand:%%{?!__systemd_twoargs_%#:%%{error:This macro requires two arguments}}} \ +%{expand:%%{?!__systemd_twoargs_%#:%%{error:The %%%%sysusers_create_package macro requires two arguments}}} \ systemd-sysusers --replace=%_sysusersdir/%1.conf - <