12
0

Accepting request 871420 from Base:System

- Bump version to 10

- Make upstream %systemd_{pre,post,preun,postun} aliases to their SUSE
  counterparts
  Packagers can now choose to use the upstream or the SUSE variants
  indifferently. For consistency the SUSE variants should be preferred
  since almost all SUSE packages already use them but the upstream
  versions might be usefull in certain cases where packages need to
  support multiple distros based on RPM.

- Improve the logic used to apply the presets (bsc#1177039)
  Before presests were applied at a) package installation b) new units
  introduced via a package update (but after making sure that it was
  not a SysV initscript being converted).
  The problem is that a) didn't handle package a renaming or split
  properly since the package with the new name is installed rather
  being updated and therefore the presets were applied even if they
  were already with the old name.
  We now cover this case (and the other ones) by applying presets only
  if the units are new and the services are not being migrated. This
  regardless of whether this happens during an install or an update.

OBS-URL: https://build.opensuse.org/request/show/871420
OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/systemd-rpm-macros?expand=0&rev=33
This commit is contained in:
2021-02-17 17:09:42 +00:00
committed by Git OBS Bridge
3 changed files with 68 additions and 47 deletions

View File

@@ -1,9 +1,10 @@
# -*- Mode: makefile; indent-tabs-mode: t -*- */
# -*- Mode: rpm-spec; indent-tabs-mode: t -*- */
# RPM macros for packages installing systemd unit files
#
###
#
# When a package install systemd unit files, it should use the following macros:
# When a package install systemd unit files, it should use the
# following macros:
#
# add %systemd_requires in the specfile
#
@@ -20,6 +21,10 @@
# %service_del_postun demo.service
# %service_del_postun_without_restart demo.service
#
# Note: the upstream variants are also available and are aliases to
# their SUSE counterparts. However for consistency the SUSE macros
# should be preferred unless the package is intended to be portable
# across multiple distributions based on RPM.
%_unitdir /usr/lib/systemd/system
%_userunitdir /usr/lib/systemd/user
@@ -68,8 +73,17 @@ OrderWithRequires(postun): systemd \
fi \
%{nil}
# Figure out when presets need to be applied. This information is only
# recorded during %pre and is actually applied during %post.
#
# Presets might need to be applied during package install but also
# during package update. On update, packages might introduce new
# services but we need to make sure that's not happening during the
# migration of SysV initscripts. On package install, presets might
# have been already applied because of package renaming or split.
#
%service_add_pre() \
if [ $1 -gt 1 -a -x /usr/bin/systemctl ]; then \
if [ -x /usr/bin/systemctl ]; then \
for service in %{?*} ; do \
if [ ! -e "/usr/lib/systemd/system/$service" ] && \
[ ! -e "/etc/init.d/${service%.*}" ]; then \
@@ -80,22 +94,18 @@ if [ $1 -gt 1 -a -x /usr/bin/systemctl ]; then \
fi \
%{nil}
# On install, tell systemd to reload its unit files
# Apply the presets if %pre told us to do so.
#
%service_add_post() \
if [ -x /usr/bin/systemctl ]; then \
if [ $1 -eq 1 ]; then \
/usr/bin/systemctl preset %{?*} || : \
else \
for service in %{?*} ; do \
if [ -e "/run/systemd/rpm/needs-preset/$service" ]; then \
/usr/bin/systemctl preset "$service" || : \
fi \
done \
rm -fr /run/systemd/rpm/needs-preset \
\
/usr/lib/systemd/systemd-sysv-convert --apply %{?*} || : \
fi \
for service in %{?*} ; do \
if [ -e "/run/systemd/rpm/needs-preset/$service" ]; then \
/usr/bin/systemctl preset "$service" || : \
rm -f /run/systemd/rpm/needs-preset/$service \
else \
/usr/lib/systemd/systemd-sysv-convert --apply %{?*} || : \
fi \
done \
fi \
%{nil}
@@ -156,22 +166,14 @@ fi \
# Upstream variants
#
%systemd_post() \
if [ $1 -eq 1 -a -x /usr/bin/systemctl ] ; then \
# Initial installation \
/usr/bin/systemctl --no-reload preset %{?*} || : \
fi \
%{nil}
%systemd_pre() %{expand::%%service_add_pre %{?**}}
%systemd_post() %{expand::%%service_add_post %{?**}}
%systemd_preun() %{expand::%%service_del_preun %{?**}}
%systemd_postun() %{expand::%%service_del_postun_without_restart %{?**}}
%systemd_postun_with_restart() %{expand::%%service_del_postun %{?**}}
%systemd_user_post() %{expand:%systemd_post \\--global %%{?*}}
%systemd_preun() \
if [ $1 -eq 0 -a -x /usr/bin/systemctl ]; then \
# Package removal, not upgrade \
/usr/bin/systemctl --no-reload disable --now %{?*} || : \
fi \
%{nil}
%systemd_user_preun() \
if [ $1 -eq 0 -a -x /usr/bin/systemctl ]; then \
# Package removal, not upgrade \
@@ -179,25 +181,9 @@ if [ $1 -eq 0 -a -x /usr/bin/systemctl ]; then \
fi \
%{nil}
%systemd_postun() \
if [ -x /usr/bin/systemctl ]; then \
/usr/bin/systemctl daemon-reload || : \
fi \
%{nil}
%systemd_user_postun() %{nil}
%systemd_user_postun_with_restart() %{nil}
%systemd_postun_with_restart() \
if [ -x /usr/bin/systemctl ]; then \
/usr/bin/systemctl daemon-reload || : \
fi \
if [ $1 -ge 1 -a -x /usr/bin/systemctl ]; then \
# Package upgrade, not uninstall \
/usr/bin/systemctl try-restart %{?*} || : \
fi \
%{nil}
%udev_hwdb_update() \
[ -x /usr/bin/udevadm ] && /usr/bin/udevadm hwdb --update || : \
%{nil}

View File

@@ -1,3 +1,38 @@
-------------------------------------------------------------------
Fri Feb 12 11:46:17 UTC 2021 - Franck Bui <fbui@suse.com>
- Bump version to 10
-------------------------------------------------------------------
Fri Feb 12 11:02:57 UTC 2021 - Franck Bui <fbui@suse.com>
- Make upstream %systemd_{pre,post,preun,postun} aliases to their SUSE
counterparts
Packagers can now choose to use the upstream or the SUSE variants
indifferently. For consistency the SUSE variants should be preferred
since almost all SUSE packages already use them but the upstream
versions might be usefull in certain cases where packages need to
support multiple distros based on RPM.
-------------------------------------------------------------------
Fri Feb 12 10:23:35 UTC 2021 - Franck Bui <fbui@suse.com>
- Improve the logic used to apply the presets (bsc#1177039)
Before presests were applied at a) package installation b) new units
introduced via a package update (but after making sure that it was
not a SysV initscript being converted).
The problem is that a) didn't handle package a renaming or split
properly since the package with the new name is installed rather
being updated and therefore the presets were applied even if they
were already with the old name.
We now cover this case (and the other ones) by applying presets only
if the units are new and the services are not being migrated. This
regardless of whether this happens during an install or an update.
-------------------------------------------------------------------
Mon Nov 23 20:33:21 UTC 2020 - Franck Bui <fbui@suse.com>

View File

@@ -1,7 +1,7 @@
#
# spec file for package systemd-rpm-macros
#
# Copyright (c) 2020 SUSE LLC
# Copyright (c) 2021 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
@@ -17,7 +17,7 @@
Name: systemd-rpm-macros
Version: 9
Version: 10
Release: 0
Summary: RPM macros for systemd
License: LGPL-2.1-or-later