Accepting request 847458 from Base:System

- Bump version to 8

- Introduce %service_del_postun_with_restart()
  It's the counterpart of %service_del_postun_without_restart() and
  replaces the '-f' option of %service_del_postun().
- Expand %service_del_postun_without_restart in %service_del_postun

- Add a missing space in %_restart_on_update()

- Bump version to 7

- Dont apply presets when migrating from a disabled initscript (bsc#1178481)

- Bump version to 6

- Test for the presence of systemd only once in %service_add_post

- No need to run 'systemd-sysv-convert --save' in %service_add_pre anymore
  Due to the fact that the initscripts being removed during package
  updates are still available in %post, systemd-sysv-convert has been
  reworked so it's only needed to call it in %post.

- Make rpmbuild load our own macros.systemd to import %{%_unitdir} properly
  Ideally we should also own other %{_*dir} paths...
- Stop owning /usr/lib/systemd directory as no package other than
  systemd is supposed to put files there.

- DISABLE_RESTART_ON_UDPATE is no more read from the (build) environment
  %service_del_postun_without_restart is the interface that should be
  used by packages that need to prevent theirs services from being

OBS-URL: https://build.opensuse.org/request/show/847458
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd-rpm-macros?expand=0&rev=31
This commit is contained in:
Dominique Leuenberger 2020-11-23 14:36:32 +00:00 committed by Git OBS Bridge
commit b24f8bd8f8
3 changed files with 141 additions and 99 deletions

View File

@ -58,135 +58,102 @@ OrderWithRequires(postun): systemd \
%_restart_on_update_never() : # Restart of %{*} skipped %{nil}
%_restart_on_update() \
test -z "$DISABLE_RESTART_ON_UPDATE" -a -f /etc/sysconfig/services &&\\\
if [ -e /etc/sysconfig/services ]; then \
DISABLE_RESTART_ON_UPDATE= \
. /etc/sysconfig/services \
test "$DISABLE_RESTART_ON_UPDATE" != yes -a "$DISABLE_RESTART_ON_UPDATE" != 1 &&\\\
/usr/bin/systemctl try-restart %{*} || : \
%{nil}
%_stop_on_removal_force() /usr/bin/systemctl stop %{*} || : %{nil}
%_stop_on_removal_never() : # Stop of %{*} skipped} %{nil}
%_stop_on_removal() \
test -z "$DISABLE_STOP_ON_REMOVAL" -a -f /etc/sysconfig/services &&\\\
. /etc/sysconfig/services \
test "$DISABLE_STOP_ON_REMOVAL" != yes -a "$DISABLE_STOP_ON_REMOVAL" != 1 &&\\\
/usr/bin/systemctl stop %{*} || : \
case "$DISABLE_RESTART_ON_UPDATE" in \
yes|1) ;; \
*) /usr/bin/systemctl try-restart %{*} || : \
esac \
fi \
%{nil}
%service_add_pre() \
# disable migration if initial install under systemd \
[ -d /var/lib/systemd/migrated ] || mkdir -p /var/lib/systemd/migrated || : \
if [ $1 -eq 1 ]; then \
for service in %{?*} ; do \
sysv_service="${service%%.*}" \
touch "/var/lib/systemd/migrated/$sysv_service" || : \
done \
else \
if [ $1 -gt 1 -a -x /usr/bin/systemctl ]; then \
for service in %{?*} ; do \
# The tag file might have been left by a preceding \
# update (see 1059627) \
# update (see bsc#1059627) \
rm -f "/run/rpm-%{name}-update-$service-new-in-upgrade" \
\
if [ ! -e "/usr/lib/systemd/system/$service" ]; then \
if [ ! -e "/usr/lib/systemd/system/$service" ] && \
[ ! -e "/etc/init.d/${service%.*}" ]; then \
touch "/run/rpm-%{name}-update-$service-new-in-upgrade" \
fi \
done \
for service in %{?*} ; do \
sysv_service="${service%%.*}" \
if [ -e /var/lib/systemd/migrated/$sysv_service ]; then \
continue \
fi \
if [ ! -x /usr/lib/systemd/systemd-sysv-convert ]; then \
continue \
fi \
/usr/lib/systemd/systemd-sysv-convert --save $sysv_service || : \
done \
fi \
%{nil}
# On install, tell systemd to reload its unit files
%service_add_post() \
[ -d /var/lib/systemd/migrated ] || mkdir -p /var/lib/systemd/migrated || : \
\
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 %{?*} || : \
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 \
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 \
for service in %{?*} ; do \
sysv_service=${service%%.*} \
if [ -e /var/lib/systemd/migrated/$sysv_service ]; then \
continue \
fi \
if [ ! -x /usr/lib/systemd/systemd-sysv-convert ]; then \
continue \
fi \
/usr/lib/systemd/systemd-sysv-convert --apply $sysv_service || : \
touch /var/lib/systemd/migrated/$sysv_service || : \
done \
fi \
%{nil}
# On uninstall, disable and stop services
#
# Options used if not in an installation systems
# -f that is fore service stop in removal
# -n that do not touch active service
# the default is to check for DISABLE_STOP_ON_REMOVAL environment
# variable if not found use the value read from /etc/sysconfig/services
# Note: '-n' and '-f' options are still allowed to keep backward compatibility
# with SLE
#
%service_del_preun(fn) \
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}} %{?*}} \
/usr/bin/systemctl --no-reload disable --now %{?*} || : \
fi \
%{nil}
# On uninstall, tell systemd to reload its unit files.
# On update, tell systemd to reload its unit files but don't restart service.
#
# It ignores the content of /etc/sysconfig/services
#
%service_del_postun_without_restart() \
if [ $1 -eq 0 ]; then \
# Package removal \
for service in %{?*} ; do \
sysv_service="${service%.*}" \
rm -f "/var/lib/systemd/migrated/$sysv_service" || : \
done \
fi \
if [ -x /usr/bin/systemctl ]; then \
/usr/bin/systemctl daemon-reload || : \
fi \
%{nil}
# On uninstall, tell systemd to reload its unit files.
# On update, tell systemd to reload its unit files and restart service.
#
# It ignores the content of /etc/sysconfig/services
#
%service_del_postun_with_restart() \
if [ -x /usr/bin/systemctl ]; then \
/usr/bin/systemctl daemon-reload || : \
if [ $1 -ge 1 ]; then \
# Package upgrade, not uninstall \
/usr/bin/systemctl try-restart %{?*} || : \
fi \
fi \
%{nil}
# On uninstall, tell systemd to reload its unit files
#
# Options used if not in an installation systems
# -f that is force service restart in removal (deprecated)
# -n that do not touch active service (depredacted)
# the default is to check for DISABLE_RESTART_ON_UPDATE environment
# variable if not found use the value read from /etc/sysconfig/services
# Deprecated options, please do not use in new code:
# -f : force restart on update (replaced by %service_del_postun_with_restart)
# -n : don't restart on update (replaced by %service_del_postun_without_restart)
#
# The default is to read DISABLE_RESTART_ON_UPDATE from /etc/sysconfig/services
#
%service_del_postun(fn) \
%service_del_postun_without_restart %{?*} \
if [ $1 -ge 1 ]; then \
# Package upgrade, not uninstall \
if [ -x /usr/bin/systemctl ]; then \
if [ -x /usr/bin/systemctl ]; then \
/usr/bin/systemctl daemon-reload || : \
if [ $1 -ge 1 ]; then \
# Package upgrade, not uninstall \
%{expand:%%_restart_on_update%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \
fi \
fi \
@ -205,18 +172,10 @@ fi \
%systemd_user_post() %{expand:%systemd_post \\--global %%{?*}}
#
# Options used if not in an installation systems
# -f that is fore service stop in removal
# -n that do not touch active service
# the default is to check for DISABLE_STOP_ON_REMOVAL environment
# 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 \
# Package removal, not upgrade \
/usr/bin/systemctl --no-reload disable %{?*} || : \
%{expand:%%_stop_on_removal%{-f:_force}%{!-f:%{-n:_never}} %{?*}} \
/usr/bin/systemctl --no-reload disable --now %{?*} || : \
fi \
%{nil}

View File

@ -1,3 +1,86 @@
-------------------------------------------------------------------
Tue Nov 10 11:21:44 UTC 2020 - Franck Bui <fbui@suse.com>
- Bump version to 8
-------------------------------------------------------------------
Tue Nov 10 09:32:31 UTC 2020 - Franck Bui <fbui@suse.com>
- Introduce %service_del_postun_with_restart()
It's the counterpart of %service_del_postun_without_restart() and
replaces the '-f' option of %service_del_postun().
- Expand %service_del_postun_without_restart in %service_del_postun
-------------------------------------------------------------------
Tue Nov 10 09:13:03 UTC 2020 - Franck Bui <fbui@suse.com>
- Add a missing space in %_restart_on_update()
-------------------------------------------------------------------
Mon Nov 9 11:38:23 UTC 2020 - Franck Bui <fbui@suse.com>
- Bump version to 7
-------------------------------------------------------------------
Mon Nov 9 11:36:56 UTC 2020 - Franck Bui <fbui@suse.com>
- Dont apply presets when migrating from a disabled initscript (bsc#1178481)
-------------------------------------------------------------------
Mon Nov 9 08:47:04 UTC 2020 - Franck Bui <fbui@suse.com>
- Bump version to 6
-------------------------------------------------------------------
Mon Nov 9 07:58:01 UTC 2020 - Franck Bui <fbui@suse.com>
- Test for the presence of systemd only once in %service_add_post
-------------------------------------------------------------------
Mon Nov 9 07:44:40 UTC 2020 - Franck Bui <fbui@suse.com>
- No need to run 'systemd-sysv-convert --save' in %service_add_pre anymore
Due to the fact that the initscripts being removed during package
updates are still available in %post, systemd-sysv-convert has been
reworked so it's only needed to call it in %post.
-------------------------------------------------------------------
Mon Nov 9 07:35:12 UTC 2020 - Franck Bui <fbui@suse.com>
- Make rpmbuild load our own macros.systemd to import %{%_unitdir} properly
Ideally we should also own other %{_*dir} paths...
- Stop owning /usr/lib/systemd directory as no package other than
systemd is supposed to put files there.
-------------------------------------------------------------------
Mon Nov 2 14:36:43 UTC 2020 - Franck Bui <fbui@suse.com>
- DISABLE_RESTART_ON_UDPATE is no more read from the (build) environment
%service_del_postun_without_restart is the interface that should be
used by packages that need to prevent theirs services from being
restarted.
-------------------------------------------------------------------
Fri Oct 30 17:39:01 UTC 2020 - Franck Bui <fbui@suse.com>
- Bump version to 5
-------------------------------------------------------------------
Fri Oct 30 17:37:54 UTC 2020 - Franck Bui <fbui@suse.com>
- Drop DISABLE_STOP_ON_REMOVAL support (jsc#SLE-8968)
%service_del_preun still accepts '-n' and '-f' options to keep
backward compatibility with SLE (as some packages share the same
devel project between SLE and openSUSE) but these options are now
ignored on Factory.
-------------------------------------------------------------------
Fri Sep 25 09:25:44 UTC 2020 - Franck Bui <fbui@suse.com>

View File

@ -17,7 +17,7 @@
Name: systemd-rpm-macros
Version: 4.1
Version: 8
Release: 0
Summary: RPM macros for systemd
License: LGPL-2.1-or-later
@ -30,6 +30,9 @@ BuildArch: noarch
#!BuildIgnore: util-linux
#!BuildIgnore: %{name}
# We need our own definition of %{_unitdir}.
%{?load:%{S:0}}
%description
Starting with openSUSE 12.1, several RPM macros must be used to package systemd
services files. This package provides these macros.
@ -40,14 +43,11 @@ services files. This package provides these macros.
%install
install -Dm644 %{S:0} %{buildroot}%{_rpmconfigdir}/macros.d/macros.systemd
UNITDIR="$(sed -n 's/.*_unitdir[[:blank:]]*//p' %{S:0})"
for i in $UNITDIR `dirname $UNITDIR`; do
mkdir -p %{buildroot}$i
echo $i >> unitdir
done
mkdir -p %{buildroot}%{_unitdir}
%files -f unitdir
%files
%defattr(-,root,root)
%{_rpmconfigdir}/macros.d/macros.systemd
%dir %{_unitdir}
%changelog