1 # -*- Mode: rpm-spec; indent-tabs-mode: nil -*- */
3 # This file is part of systemd.
5 # Copyright 2015 Zbigniew Jędrzejewski-Szmek
7 # systemd is free software; you can redistribute it and/or modify it
8 # under the terms of the GNU Lesser General Public License as published by
9 # the Free Software Foundation; either version 2.1 of the License, or
10 # (at your option) any later version.
12 # systemd is distributed in the hope that it will be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 # Lesser General Public License for more details.
17 # You should have received a copy of the GNU Lesser General Public License
18 # along with systemd; If not, see <http://www.gnu.org/licenses/>.
20 # The contents of this are an example to be copied into systemd.spec.
22 # Minimum rpm version supported: 4.13.0
24 %transfiletriggerin -P 900900 -p <lua> -- @systemunitdir@ /etc/systemd/system
25 -- This script will run after any package is initially installed or
26 -- upgraded. We care about the case where a package is initially
27 -- installed, because other cases are covered by the *un scriptlets,
28 -- so sometimes we will reload needlessly.
32 assert(posix.exec("%{_bindir}/systemctl", "daemon-reload"))
37 %transfiletriggerun -p <lua> -- @systemunitdir@ /etc/systemd/system
38 -- On removal, we need to run daemon-reload after any units have been
39 -- removed. %transfiletriggerpostun would be ideal, but it does not get
40 -- executed for some reason.
41 -- On upgrade, we need to run daemon-reload after any new unit files
42 -- have been installed, but before %postun scripts in packages get
43 -- executed. %transfiletriggerun gets the right list of files
44 -- but it is invoked too early (before changes happen).
45 -- %filetriggerpostun happens at the right time, but it fires for
47 -- To execute the reload at the right time, we create a state
48 -- file in %transfiletriggerun and execute the daemon-reload in
49 -- the first %filetriggerpostun.
51 posix.mkdir("%{_localstatedir}/lib")
52 posix.mkdir("%{_localstatedir}/lib/rpm-state")
53 posix.mkdir("%{_localstatedir}/lib/rpm-state/systemd")
54 io.open("%{_localstatedir}/lib/rpm-state/systemd/needs-reload", "w")
56 %filetriggerpostun -P 1000100 -p <lua> -- @systemunitdir@ /etc/systemd/system
57 if posix.access("%{_localstatedir}/lib/rpm-state/systemd/needs-reload") then
58 posix.unlink("%{_localstatedir}/lib/rpm-state/systemd/needs-reload")
59 posix.rmdir("%{_localstatedir}/lib/rpm-state/systemd")
62 assert(posix.exec("%{_bindir}/systemctl", "daemon-reload"))