From 8fac5fa9ed202177ea073f64f25c6631b92fcff672f0bdf04295ee441607cd64 Mon Sep 17 00:00:00 2001 From: Franck Bui Date: Tue, 12 Mar 2019 08:20:41 +0000 Subject: [PATCH] Accepting request 684198 from home:fbui:branches:Base:System - $1 can never be empty or it's an rpm bug - Get rid of $FIRST_ARG $FIRST_ARG was probably introduced because the %service_* macros were playing tricks on the shell positional parameters. This is bad practice and error prone so let's assume that no macros should do that anymore and hence it's safe to assume that positional parameters remains unchanged after any rpm macro call. All users of $FIRST_ARG should have been fixed by now and in most cases the use of the variable was unneeded (since the macros don't change the shell parameters) and thus confusing. 'net-snmp' has a different use of FIRST_ARG though as it tried to fake an update during a package installation. Fortunately this could have been fixed too. OBS-URL: https://build.opensuse.org/request/show/684198 OBS-URL: https://build.opensuse.org/package/show/Base:System/systemd-rpm-macros?expand=0&rev=37 --- macros.systemd | 23 +++++++++-------------- systemd-rpm-macros.changes | 24 ++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/macros.systemd b/macros.systemd index be35537..0fe1dc2 100644 --- a/macros.systemd +++ b/macros.systemd @@ -72,10 +72,9 @@ OrderWithRequires(postun): systemd \ %{nil} %service_add_pre() \ -test -n "$FIRST_ARG" || FIRST_ARG="$1" \ # disable migration if initial install under systemd \ [ -d /var/lib/systemd/migrated ] || mkdir -p /var/lib/systemd/migrated || : \ -if [ "$FIRST_ARG" -eq 1 ]; then \ +if [ $1 -eq 1 ]; then \ for service in %{?*} ; do \ sysv_service="${service%%.*}" \ touch "/var/lib/systemd/migrated/$sysv_service" || : \ @@ -105,18 +104,17 @@ fi \ # On install, tell systemd to reload its unit files %service_add_post() \ -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 [ $1 -eq 1 ]; then \ if [ -x /usr/bin/systemctl ]; then \ /usr/bin/systemctl preset %{?*} || : \ fi \ -elif [ "$FIRST_ARG" -gt 1 ]; then \ +elif [ $1 -gt 1 ]; then \ for service in %{?*} ; do \ if [ ! -e "/run/rpm-%{name}-update-$service-new-in-upgrade" ]; then \ continue \ @@ -150,8 +148,7 @@ fi \ # 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 \ +if [ $1 -eq 0 -a -x /usr/bin/systemctl ]; then \ # Package removal, not upgrade \ /usr/bin/systemctl --no-reload disable %{?*} || : \ %{expand:%%_stop_on_removal%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \ @@ -162,8 +159,7 @@ fi \ # On update, tell systemd to reload its unit files but don't restart service. # %service_del_postun_without_restart() \ -test -n "$FIRST_ARG" || FIRST_ARG="$1" \ -if [ "$FIRST_ARG" -eq 0 ]; then \ +if [ $1 -eq 0 ]; then \ # Package removal \ for service in %{?*} ; do \ sysv_service="${service%.*}" \ @@ -184,9 +180,8 @@ fi \ # 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 \ +if [ $1 -ge 1 ]; then \ # Package upgrade, not uninstall \ if [ -x /usr/bin/systemctl ]; then \ %{expand:%%_restart_on_update%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \ @@ -215,7 +210,7 @@ fi \ # 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 \ +if [ $1 -eq 0 -a -x /usr/bin/systemctl ]; then \ # Package removal, not upgrade \ /usr/bin/systemctl --no-reload disable %{?*} || : \ %{expand:%%_stop_on_removal%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \ @@ -223,7 +218,7 @@ fi \ %{nil} %systemd_user_preun() \ -if [ "$1" -eq 0 -a -x /usr/bin/systemctl ]; then \ +if [ $1 -eq 0 -a -x /usr/bin/systemctl ]; then \ # Package removal, not upgrade \ /usr/bin/systemctl --global disable %{?*} || : \ fi \ @@ -242,7 +237,7 @@ fi \ if [ -x /usr/bin/systemctl ]; then \ /usr/bin/systemctl daemon-reload || : \ fi \ -if [ "$1" -ge 1 -a -x /usr/bin/systemctl ]; then \ +if [ $1 -ge 1 -a -x /usr/bin/systemctl ]; then \ # Package upgrade, not uninstall \ /usr/bin/systemctl try-restart %{?*} || : \ fi \ diff --git a/systemd-rpm-macros.changes b/systemd-rpm-macros.changes index 0b42340..53584d0 100644 --- a/systemd-rpm-macros.changes +++ b/systemd-rpm-macros.changes @@ -1,3 +1,27 @@ +------------------------------------------------------------------- +Tue Mar 12 08:17:25 UTC 2019 - Franck Bui + +- $1 can never be empty or it's an rpm bug + +------------------------------------------------------------------- +Tue Mar 12 08:03:45 UTC 2019 - Franck Bui + +- Get rid of $FIRST_ARG + + $FIRST_ARG was probably introduced because the %service_* macros + were playing tricks on the shell positional parameters. This is bad + practice and error prone so let's assume that no macros should do + that anymore and hence it's safe to assume that positional + parameters remains unchanged after any rpm macro call. + + All users of $FIRST_ARG should have been fixed by now and in most + cases the use of the variable was unneeded (since the macros don't + change the shell parameters) and thus confusing. + + 'net-snmp' has a different use of FIRST_ARG though as it tried to + fake an update during a package installation. Fortunately this could + have been fixed too. + ------------------------------------------------------------------- Fri Mar 1 08:18:07 UTC 2019 - Franck Bui