commit: b480b389a39dc6b8d9cdaf99c0e554ab82ef5ca8 Author: Mike Gilbert <floppym <AT> gentoo <DOT> org> AuthorDate: Sun Oct 9 17:40:43 2016 +0000 Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org> CommitDate: Sun Oct 9 17:41:13 2016 +0000 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b480b389
systemd.eclass: Add systemd_tmpfiles_create function Bug: https://bugs.gentoo.org/462118 eclass/systemd.eclass | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass index f6cc004..b00668e 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 "${@}" +}
