3
0

- 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/package/show/Base:System/systemd-rpm-macros?expand=0&rev=59
This commit is contained in:
Franck Bui 2021-02-12 11:01:43 +00:00 committed by Git OBS Bridge
parent e45618db9a
commit 988d319a8f
3 changed files with 39 additions and 16 deletions

View File

@ -1,4 +1,4 @@
# -*- Mode: makefile; indent-tabs-mode: t -*- */
# -*- Mode: rpm-spec; indent-tabs-mode: t -*- */
# RPM macros for packages installing systemd unit files
#
###
@ -68,8 +68,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 +89,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 \
\
rm -f /run/systemd/rpm/needs-preset/$service \
else \
/usr/lib/systemd/systemd-sysv-convert --apply %{?*} || : \
fi \
done \
fi \
%{nil}

View File

@ -1,3 +1,21 @@
-------------------------------------------------------------------
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