summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeal Gompa (ニール・ゴンパ) <ngompa13@gmail.com>2018-02-06 04:11:36 -0500
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2018-02-06 10:11:36 +0100
commit32a00a9c097cf04ec2b0fcbf9b73eba188318424 (patch)
tree808f6f5898f7b38f89910bcddaa7c47162093787
parent9207564756b8d895e3e3b6de04a6a5300944f84b (diff)
downloadsystemd-32a00a9c097cf04ec2b0fcbf9b73eba188318424.tar.gz
Add more file triggers to handle more aspects of systemd (#8090)
For quite a while now, there have been file triggers to handle automatically setting up service units in upstream systemd. However, most of the actions being done by these macros upon files can be set up as RPM file triggers. In fact, in Mageia, we had been doing this for most of these. In particular, we have file triggers in place for sysusers, tmpfiles, hwdb, and the journal. This change adds Lua versions of the original file triggers used in Mageia, based on the existing Lua-based file triggers for service units. In addition, we can also have useful file triggers for udev rules, sysctl directives, and binfmt directives. These are based on the other existing file triggers.
-rw-r--r--src/core/macros.systemd.in12
-rw-r--r--src/core/triggers.systemd.in87
2 files changed, 90 insertions, 9 deletions
diff --git a/src/core/macros.systemd.in b/src/core/macros.systemd.in
index cee9b89870..53b13a027e 100644
--- a/src/core/macros.systemd.in
+++ b/src/core/macros.systemd.in
@@ -84,17 +84,11 @@ fi \
%systemd_user_postun_with_restart() %{nil}
-%udev_hwdb_update() \
-systemd-hwdb update >/dev/null 2>&1 || : \
-%{nil}
+%udev_hwdb_update() %{nil}
-%udev_rules_update() \
-udevadm control --reload >/dev/null 2>&1 || : \
-%{nil}
+%udev_rules_update() %{nil}
-%journal_catalog_update() \
-journalctl --update-catalog >/dev/null 2>&1 || : \
-%{nil}
+%journal_catalog_update() %{nil}
%tmpfiles_create() \
systemd-tmpfiles --create %{?*} >/dev/null 2>&1 || : \
diff --git a/src/core/triggers.systemd.in b/src/core/triggers.systemd.in
index 985c6d8b26..c582d40977 100644
--- a/src/core/triggers.systemd.in
+++ b/src/core/triggers.systemd.in
@@ -4,6 +4,7 @@
# This file is part of systemd.
#
# Copyright 2015 Zbigniew Jędrzejewski-Szmek
+# Copyright 2018 Neal Gompa
#
# systemd is free software; you can redistribute it and/or modify it
# under the terms of the GNU Lesser General Public License as published by
@@ -69,3 +70,89 @@ if posix.access("%{_localstatedir}/lib/rpm-state/systemd/needs-reload") then
posix.wait(pid)
end
end
+
+%transfiletriggerin -P 100700 -p <lua> -- @sysusersdir@
+-- This script will process files installed in @sysusersdir@ to create
+-- specified users automatically. The priority is set such that it
+-- will run before the tmpfiles file trigger.
+if posix.access("/run/systemd/system") then
+ pid = posix.fork()
+ if pid == 0 then
+ assert(posix.exec("%{_bindir}/systemd-sysusers"))
+ elseif pid > 0 then
+ posix.wait(pid)
+ end
+end
+
+%transfiletriggerin -P 100500 -- @tmpfilesdir@
+-- This script will process files installed in @tmpfilesdir@ to create
+-- tmpfiles automatically. The priority is set such that it will run
+-- after the sysusers file trigger, but before any other triggers.
+if posix.access("/run/systemd/system") then
+ pid = posix.fork()
+ if pid == 0 then
+ assert(posix.exec("%{_bindir}/systemd-tmpfiles", "--create"))
+ elseif pid > 0 then
+ posix.wait(pid)
+ end
+end
+
+%transfiletriggerin -- @udevhwdbdir@
+-- This script will automatically invoke hwdb update if files have been
+-- installed or updated in @udevhwdbdir@.
+if posix.access("/run/systemd/system") then
+ pid = posix.fork()
+ if pid == 0 then
+ assert(posix.exec("%{_bindir}/systemd-hwdb", "update"))
+ elseif pid > 0 then
+ posix.wait(pid)
+ end
+end
+
+%transfiletriggerin -- @catalogdir@
+-- This script will automatically invoke journal catalog update if files
+-- have been installed or updated in @catalogdir@.
+if posix.access("/run/systemd/system") then
+ pid = posix.fork()
+ if pid == 0 then
+ assert(posix.exec("%{_bindir}/journalctl", "--update-catalog"))
+ elseif pid > 0 then
+ posix.wait(pid)
+ end
+end
+
+%transfiletriggerin -- @udevrulesdir@
+-- This script will automatically update udev with new rules if files
+-- have been installed or updated in @udevrulesdir@.
+if posix.access("/run/systemd/system") then
+ pid = posix.fork()
+ if pid == 0 then
+ assert(posix.exec("%{_bindir}/udevadm", "control", "--reload"))
+ elseif pid > 0 then
+ posix.wait(pid)
+ end
+end
+
+%transfiletriggerin -- @sysctldir@
+-- This script will automatically apply sysctl rules if files have been
+-- installed or updated in @sysctldir@.
+if posix.access("/run/systemd/system") then
+ pid = posix.fork()
+ if pid == 0 then
+ assert(posix.exec("@rootlibexecdir@/systemd-sysctl"))
+ elseif pid > 0 then
+ posix.wait(pid)
+ end
+end
+
+%transfiletriggerin -- @binfmtdir@
+-- This script will automatically apply binfmt rules if files have been
+-- installed or updated in @binfmtdir@.
+if posix.access("/run/systemd/system") then
+ pid = posix.fork()
+ if pid == 0 then
+ assert(posix.exec("@rootlibexecdir@/systemd-binfmt"))
+ elseif pid > 0 then
+ posix.wait(pid)
+ end
+end