1 # -*- Mode: rpm-spec; indent-tabs-mode: nil -*- */
2 # SPDX-License-Identifier: LGPL-2.1+
4 # This file is part of systemd.
5 # Copyright © 2018 Neal Gompa
7 # The contents of this are an example to be copied into systemd.spec.
9 # Minimum rpm version supported: 4.13.0
11 %transfiletriggerin -P 900900 -p <lua> -- @systemunitdir@ /etc/systemd/system
12 -- This script will run after any package is initially installed or
13 -- upgraded. We care about the case where a package is initially
14 -- installed, because other cases are covered by the *un scriptlets,
15 -- so sometimes we will reload needlessly.
17 if posix.access("/run/systemd/system") then
20 assert(posix.exec("%{_bindir}/systemctl", "daemon-reload"))
26 %transfiletriggerun -p <lua> -- @systemunitdir@ /etc/systemd/system
27 -- On removal, we need to run daemon-reload after any units have been
28 -- removed. %transfiletriggerpostun would be ideal, but it does not get
29 -- executed for some reason.
30 -- On upgrade, we need to run daemon-reload after any new unit files
31 -- have been installed, but before %postun scripts in packages get
32 -- executed. %transfiletriggerun gets the right list of files
33 -- but it is invoked too early (before changes happen).
34 -- %filetriggerpostun happens at the right time, but it fires for
36 -- To execute the reload at the right time, we create a state
37 -- file in %transfiletriggerun and execute the daemon-reload in
38 -- the first %filetriggerpostun.
40 if posix.access("/run/systemd/system") then
41 posix.mkdir("%{_localstatedir}/lib")
42 posix.mkdir("%{_localstatedir}/lib/rpm-state")
43 posix.mkdir("%{_localstatedir}/lib/rpm-state/systemd")
44 io.open("%{_localstatedir}/lib/rpm-state/systemd/needs-reload", "w")
47 %filetriggerpostun -P 1000100 -p <lua> -- @systemunitdir@ /etc/systemd/system
48 if posix.access("%{_localstatedir}/lib/rpm-state/systemd/needs-reload") then
49 posix.unlink("%{_localstatedir}/lib/rpm-state/systemd/needs-reload")
50 posix.rmdir("%{_localstatedir}/lib/rpm-state/systemd")
53 assert(posix.exec("%{_bindir}/systemctl", "daemon-reload"))
59 %transfiletriggerin -P 100700 -p <lua> -- @sysusersdir@
60 -- This script will process files installed in @sysusersdir@ to create
61 -- specified users automatically. The priority is set such that it
62 -- will run before the tmpfiles file trigger.
63 if posix.access("/run/systemd/system") then
66 assert(posix.exec("%{_bindir}/systemd-sysusers"))
72 %transfiletriggerin -P 100500 -p <lua> -- @tmpfilesdir@
73 -- This script will process files installed in @tmpfilesdir@ to create
74 -- tmpfiles automatically. The priority is set such that it will run
75 -- after the sysusers file trigger, but before any other triggers.
76 if posix.access("/run/systemd/system") then
79 assert(posix.exec("%{_bindir}/systemd-tmpfiles", "--create"))
85 %transfiletriggerin -p <lua> -- @udevhwdbdir@
86 -- This script will automatically invoke hwdb update if files have been
87 -- installed or updated in @udevhwdbdir@.
88 if posix.access("/run/systemd/system") then
91 assert(posix.exec("%{_bindir}/systemd-hwdb", "update"))
97 %transfiletriggerin -p <lua> -- @catalogdir@
98 -- This script will automatically invoke journal catalog update if files
99 -- have been installed or updated in @catalogdir@.
100 if posix.access("/run/systemd/system") then
103 assert(posix.exec("%{_bindir}/journalctl", "--update-catalog"))
109 %transfiletriggerin -p <lua> -- @udevrulesdir@
110 -- This script will automatically update udev with new rules if files
111 -- have been installed or updated in @udevrulesdir@.
112 if posix.access("/run/systemd/system") then
115 assert(posix.exec("%{_bindir}/udevadm", "control", "--reload"))
121 %transfiletriggerin -p <lua> -- @sysctldir@
122 -- This script will automatically apply sysctl rules if files have been
123 -- installed or updated in @sysctldir@.
124 if posix.access("/run/systemd/system") then
127 assert(posix.exec("@rootlibexecdir@/systemd-sysctl"))
133 %transfiletriggerin -p <lua> -- @binfmtdir@
134 -- This script will automatically apply binfmt rules if files have been
135 -- installed or updated in @binfmtdir@.
136 if posix.access("/run/systemd/system") then
139 assert(posix.exec("@rootlibexecdir@/systemd-binfmt"))