From cc07482ca3b158f9b942531f2bbb79558007771a Mon Sep 17 00:00:00 2001 From: Mike Gilbert Date: Mon, 14 Mar 2016 10:48:44 -0400 Subject: [PATCH] systemd.eclass: Add systemd_tmpfiles_create function Bug: https://bugs.gentoo.org/462118 --- eclass/systemd.eclass | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass index f6cc004..2c17323 100644 --- a/eclass/systemd.eclass +++ b/eclass/systemd.eclass @@ -398,3 +398,23 @@ systemd_is_booted() { debug-print "${FUNCNAME}: [[ -d /run/systemd/system ]] -> ${ret}" return ${ret} } + +# @FUNCTION: systemd_tmpfiles_create +# @USAGE: ... +# @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} "${@}" + + [[ $# -gt 0 ]] || die "${FUNCNAME}: Must specify at least one filename" + [[ ${ROOT} == / ]] || return 0 + type systemd-tmpfiles > /dev/null || return 0 + systemd-tmpfiles --create "$@" +} -- 2.7.3