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
This commit is contained in:
Franck Bui 2019-03-12 08:20:41 +00:00 committed by Git OBS Bridge
parent f337315c0b
commit 8fac5fa9ed
2 changed files with 33 additions and 14 deletions

View File

@ -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 \

View File

@ -1,3 +1,27 @@
-------------------------------------------------------------------
Tue Mar 12 08:17:25 UTC 2019 - Franck Bui <fbui@suse.com>
- $1 can never be empty or it's an rpm bug
-------------------------------------------------------------------
Tue Mar 12 08:03:45 UTC 2019 - Franck Bui <fbui@suse.com>
- 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 <fbui@suse.com>