Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: [gentoo-dev] [PATCH 1/3] tmpfiles.eclass: Support using on non-Linux systems
Date: Sun, 30 Apr 2017 19:07:13
Message-Id: 20170430190655.9946-1-mgorny@gentoo.org
1 Fix the eclass code to remove the misguided Linux conditionals.
2 The whole purpose of the eclass was to avoid having to implement
3 fallback logic for systems not having service manager tmpfiles.d
4 support. Making it conditional to Linux implied that for non-Linux
5 systems (Prefix, FreeBSD) we would have to implement explicit fallback
6 to create the necessary directories.
7
8 While systemd (and therefore systemd-tmpfilesd) is indeed
9 Linux-specific, the opentmpfiles implementation should be pretty
10 portable and there is no reason to restrict it to Linux only, or to
11 prevent using it on non-Linux OpenRC (and non-OpenRC) systems.
12 ---
13 eclass/tmpfiles.eclass | 17 ++++++++++-------
14 1 file changed, 10 insertions(+), 7 deletions(-)
15
16 diff --git a/eclass/tmpfiles.eclass b/eclass/tmpfiles.eclass
17 index 2a158c482a58..9cf040de987f 100644
18 --- a/eclass/tmpfiles.eclass
19 +++ b/eclass/tmpfiles.eclass
20 @@ -1,4 +1,4 @@
21 -# Copyright 1999-2016 Gentoo Foundation
22 +# Copyright 1999-2017 Gentoo Foundation
23 # Distributed under the terms of the GNU General Public License v2
24
25 # @ECLASS: tmpfiles.eclass
26 @@ -17,10 +17,16 @@
27 # https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html
28 #
29 # The dotmpfiles and newtmpfiles functions are used to install
30 -# configuration files into /usr/lib/tmpfiles.d, then in pkg_postinst, the
31 -# tmpfiles_process function can be called to process the newly
32 +# configuration files into /usr/lib/tmpfiles.d, then in pkg_postinst,
33 +# the tmpfiles_process function must be called to process the newly
34 # installed tmpfiles.d entries.
35 #
36 +# The tmpfiles.d files can be used by service managers to recreate/clean
37 +# up temporary directories on boot or periodically. Additionally,
38 +# the pkg_postinst() call ensures that the directories are created
39 +# on systems that do not support tmpfiles.d natively, without a need
40 +# for explicit fallback.
41 +#
42 # @EXAMPLE:
43 # Typical usage of this eclass:
44 #
45 @@ -53,7 +59,7 @@ case "${EAPI}" in
46 *) die "API is undefined for EAPI ${EAPI}" ;;
47 esac
48
49 -RDEPEND="kernel_linux? ( virtual/tmpfiles )"
50 +RDEPEND="virtual/tmpfiles"
51
52 # @FUNCTION: dotmpfiles
53 # @USAGE: dotmpfiles <tmpfiles.d_file> ...
54 @@ -62,7 +68,6 @@ RDEPEND="kernel_linux? ( virtual/tmpfiles )"
55 dotmpfiles() {
56 debug-print-function "${FUNCNAME}" "$@"
57
58 - use kernel_linux || return 0
59 local f
60 for f; do
61 if [[ ${f} != *.conf ]]; then
62 @@ -83,7 +88,6 @@ dotmpfiles() {
63 newtmpfiles() {
64 debug-print-function "${FUNCNAME}" "$@"
65
66 - use kernel_linux || return 0
67 if [[ $2 != *.conf ]]; then
68 die "tmpfiles.d files must end with .conf"
69 fi
70 @@ -102,7 +106,6 @@ newtmpfiles() {
71 tmpfiles_process() {
72 debug-print-function "${FUNCNAME}" "$@"
73
74 - use kernel_linux || return 0
75 [[ ${EBUILD_PHASE} == postinst ]] || die "${FUNCNAME}: Only valid in pkg_postinst"
76 [[ ${#} -gt 0 ]] || die "${FUNCNAME}: Must specify at least one filename"
77
78 --
79 2.13.0.rc1

Replies