Gentoo Archives: gentoo-commits

From: Mike Gilbert <floppym@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] repo/gentoo:master commit in: eclass/
Date: Sun, 09 Oct 2016 17:41:45
Message-Id: 1476034873.b480b389a39dc6b8d9cdaf99c0e554ab82ef5ca8.floppym@gentoo
1 commit: b480b389a39dc6b8d9cdaf99c0e554ab82ef5ca8
2 Author: Mike Gilbert <floppym <AT> gentoo <DOT> org>
3 AuthorDate: Sun Oct 9 17:40:43 2016 +0000
4 Commit: Mike Gilbert <floppym <AT> gentoo <DOT> org>
5 CommitDate: Sun Oct 9 17:41:13 2016 +0000
6 URL: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=b480b389
7
8 systemd.eclass: Add systemd_tmpfiles_create function
9
10 Bug: https://bugs.gentoo.org/462118
11
12 eclass/systemd.eclass | 21 +++++++++++++++++++++
13 1 file changed, 21 insertions(+)
14
15 diff --git a/eclass/systemd.eclass b/eclass/systemd.eclass
16 index f6cc004..b00668e 100644
17 --- a/eclass/systemd.eclass
18 +++ b/eclass/systemd.eclass
19 @@ -398,3 +398,24 @@ systemd_is_booted() {
20 debug-print "${FUNCNAME}: [[ -d /run/systemd/system ]] -> ${ret}"
21 return ${ret}
22 }
23 +
24 +# @FUNCTION: systemd_tmpfiles_create
25 +# @USAGE: <tmpfilesd> ...
26 +# @DESCRIPTION:
27 +# Invokes systemd-tmpfiles --create with given arguments.
28 +# Does nothing if ROOT != / or systemd-tmpfiles is not in PATH.
29 +# This function should be called from pkg_postinst.
30 +#
31 +# Generally, this function should be called with the names of any tmpfiles
32 +# fragments which have been installed, either by the build system or by a
33 +# previous call to systemd_dotmpfilesd. This ensures that any tmpfiles are
34 +# created without the need to reboot the system.
35 +systemd_tmpfiles_create() {
36 + debug-print-function ${FUNCNAME} "${@}"
37 +
38 + [[ ${EBUILD_PHASE} == postinst ]] || die "${FUNCNAME}: Only valid in pkg_postinst"
39 + [[ ${#} -gt 0 ]] || die "${FUNCNAME}: Must specify at least one filename"
40 + [[ ${ROOT} == / ]] || return 0
41 + type systemd-tmpfiles &> /dev/null || return 0
42 + systemd-tmpfiles --create "${@}"
43 +}