From dc105f307e4f4e67daef3a487472ea62447271cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 21 Nov 2015 21:08:43 -0500 Subject: [PATCH] Improve filetriggers to run in all required situations --- systemd.spec | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/systemd.spec b/systemd.spec index dd5e09c..cd10f9a 100644 --- a/systemd.spec +++ b/systemd.spec @@ -346,11 +346,37 @@ test -z "$(grep -L xml:lang %{buildroot}%{_datadir}/polkit-1/actions/org.freedes ############################################################################################# +# This will run after any package is initially installed or +# upgraded. We care about the case where a package is initially +# installed, because other cases are covered by the scriptlets below, +# so sometimes we will reload needlessly. + %transfiletriggerin -- /usr/lib/systemd/system /etc/systemd/system systemctl daemon-reload &>/dev/null || : +# On removal, we need to run daemon-reload after any units have been +# removed. %transfilepostun would be ideal, but it does not get +# executed for some reason. +# On upgrade, we need to run daemon-reload after any new unit files +# have been installed, but before %postun scripts in packages get +# executed. %transfiletriggerun gets the right list of files +# but it is invoked too early (before changes happen). +# %filetriggerpostun happens at the right time, but it fires for +# every package. +# To execute the reload at the right time, we create a state +# file in %transfiletriggerun and execute the daemon-reload in +# the first %filetriggerpostun. + %transfiletriggerun -- /usr/lib/systemd/system /etc/systemd/system -systemctl daemon-reload &>/dev/null || : +mkdir -p %{_localstatedir}/lib/rpm-state/systemd +touch %{_localstatedir}/lib/rpm-state/systemd/needs-reload + +%filetriggerpostun -- /usr/lib/systemd/system /etc/systemd/system +if [ -e %{_localstatedir}/lib/rpm-state/systemd/needs-reload ]; then + rm %{_localstatedir}/lib/rpm-state/systemd/needs-reload || : + rmdir %{_localstatedir}/lib/rpm-state/systemd || : + systemctl daemon-reload || : +fi %pre getent group cdrom >/dev/null 2>&1 || groupadd -r -g 11 cdrom >/dev/null 2>&1 || : @@ -715,6 +741,8 @@ getent passwd systemd-journal-upload >/dev/null 2>&1 || useradd -r -l -g systemd %{pkgdir}/boot/efi/*.stub %endif +%ghost %dir %{_localstatedir}/lib/rpm-state/systemd + %files libs %{_libdir}/security/pam_systemd.so %{_libdir}/libnss_myhostname.so.2