From: Mike Gilbert Date: Sun, 9 Oct 2016 17:40:43 +0000 (-0400) Subject: systemd.eclass: Add systemd_tmpfiles_create function X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=b480b389a39dc6b8d9cdaf99c0e554ab82ef5ca8;p=gentoo.git systemd.eclass: Add systemd_tmpfiles_create function Bug: https://bugs.gentoo.org/462118 --- diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass index f6cc004257c0..b00668e023a7 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: ... +# @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 "${@}" +}