summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--eclass/systemd.eclass21
1 files changed, 21 insertions, 0 deletions
diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass
index f6cc004257c..b00668e023a 100644
--- a/eclass/systemd.eclass
+++ b/eclass/systemd.eclass
@@ -398,3 +398,24 @@ systemd_is_booted() {
debug-print "${FUNCNAME}: [[ -d /run/systemd/system ]] -> ${ret}"
return ${ret}
}
+
+# @FUNCTION: systemd_tmpfiles_create
+# @USAGE: <tmpfilesd> ...
+# @DESCRIPTION:
+# Invokes systemd-tmpfiles --create with given arguments.
+# Does nothing if ROOT != / or systemd-tmpfiles is not in PATH.
+# This function should be called from pkg_postinst.
+#
+# Generally, this function should be called with the names of any tmpfiles
+# fragments which have been installed, either by the build system or by a
+# previous call to systemd_dotmpfilesd. This ensures that any tmpfiles are
+# created without the need to reboot the system.
+systemd_tmpfiles_create() {
+ debug-print-function ${FUNCNAME} "${@}"
+
+ [[ ${EBUILD_PHASE} == postinst ]] || die "${FUNCNAME}: Only valid in pkg_postinst"
+ [[ ${#} -gt 0 ]] || die "${FUNCNAME}: Must specify at least one filename"
+ [[ ${ROOT} == / ]] || return 0
+ type systemd-tmpfiles &> /dev/null || return 0
+ systemd-tmpfiles --create "${@}"
+}