1 # -*- Mode: rpm-spec; indent-tabs-mode: nil -*- */
2 # SPDX-License-Identifier: LGPL-2.1+
4 # This file is part of systemd.
6 # Copyright © 2015 Zbigniew Jędrzejewski-Szmek
7 # Copyright © 2018 Neal Gompa
9 # The contents of this are an example to be copied into systemd.spec.
11 # Minimum rpm version supported: 4.13.0
13 %transfiletriggerin -P 900900 -p <lua> -- @systemunitdir@ /etc/systemd/system
14 -- This script will run after any package is initially installed or
15 -- upgraded. We care about the case where a package is initially
16 -- installed, because other cases are covered by the *un scriptlets,
17 -- so sometimes we will reload needlessly.
19 if posix.access("/run/systemd/system") then
22 assert(posix.exec("%{_bindir}/systemctl", "daemon-reload"))
28 %transfiletriggerun -p <lua> -- @systemunitdir@ /etc/systemd/system
29 -- On removal, we need to run daemon-reload after any units have been
30 -- removed. %transfiletriggerpostun would be ideal, but it does not get
31 -- executed for some reason.
32 -- On upgrade, we need to run daemon-reload after any new unit files
33 -- have been installed, but before %postun scripts in packages get
34 -- executed. %transfiletriggerun gets the right list of files
35 -- but it is invoked too early (before changes happen).
36 -- %filetriggerpostun happens at the right time, but it fires for
38 -- To execute the reload at the right time, we create a state
39 -- file in %transfiletriggerun and execute the daemon-reload in
40 -- the first %filetriggerpostun.
42 if posix.access("/run/systemd/system") then
43 posix.mkdir("%{_localstatedir}/lib")
44 posix.mkdir("%{_localstatedir}/lib/rpm-state")
45 posix.mkdir("%{_localstatedir}/lib/rpm-state/systemd")
46 io.open("%{_localstatedir}/lib/rpm-state/systemd/needs-reload", "w")
49 %filetriggerpostun -P 1000100 -p <lua> -- @systemunitdir@ /etc/systemd/system
50 if posix.access("%{_localstatedir}/lib/rpm-state/systemd/needs-reload") then
51 posix.unlink("%{_localstatedir}/lib/rpm-state/systemd/needs-reload")
52 posix.rmdir("%{_localstatedir}/lib/rpm-state/systemd")
55 assert(posix.exec("%{_bindir}/systemctl", "daemon-reload"))
61 %transfiletriggerin -P 100700 -p <lua> -- @sysusersdir@
62 -- This script will process files installed in @sysusersdir@ to create
63 -- specified users automatically. The priority is set such that it
64 -- will run before the tmpfiles file trigger.
65 if posix.access("/run/systemd/system") then
68 assert(posix.exec("%{_bindir}/systemd-sysusers"))
74 %transfiletriggerin -P 100500 -p <lua> -- @tmpfilesdir@
75 -- This script will process files installed in @tmpfilesdir@ to create
76 -- tmpfiles automatically. The priority is set such that it will run
77 -- after the sysusers file trigger, but before any other triggers.
78 if posix.access("/run/systemd/system") then
81 assert(posix.exec("%{_bindir}/systemd-tmpfiles", "--create"))
87 %transfiletriggerin -p <lua> -- @udevhwdbdir@
88 -- This script will automatically invoke hwdb update if files have been
89 -- installed or updated in @udevhwdbdir@.
90 if posix.access("/run/systemd/system") then
93 assert(posix.exec("%{_bindir}/systemd-hwdb", "update"))
99 %transfiletriggerin -p <lua> -- @catalogdir@
100 -- This script will automatically invoke journal catalog update if files
101 -- have been installed or updated in @catalogdir@.
102 if posix.access("/run/systemd/system") then
105 assert(posix.exec("%{_bindir}/journalctl", "--update-catalog"))
111 %transfiletriggerin -p <lua> -- @udevrulesdir@
112 -- This script will automatically update udev with new rules if files
113 -- have been installed or updated in @udevrulesdir@.
114 if posix.access("/run/systemd/system") then
117 assert(posix.exec("%{_bindir}/udevadm", "control", "--reload"))
123 %transfiletriggerin -p <lua> -- @sysctldir@
124 -- This script will automatically apply sysctl rules if files have been
125 -- installed or updated in @sysctldir@.
126 if posix.access("/run/systemd/system") then
129 assert(posix.exec("@rootlibexecdir@/systemd-sysctl"))
135 %transfiletriggerin -p <lua> -- @binfmtdir@
136 -- This script will automatically apply binfmt rules if files have been
137 -- installed or updated in @binfmtdir@.
138 if posix.access("/run/systemd/system") then
141 assert(posix.exec("@rootlibexecdir@/systemd-binfmt"))