1 |
On Tue, 15 Nov 2016 13:42:00 -0600 |
2 |
William Hubbs <williamh@g.o> wrote: |
3 |
|
4 |
> # Copyright 1999-2016 Gentoo Foundation |
5 |
> # Distributed under the terms of the GNU General Public License v2 |
6 |
> # $Id$ |
7 |
> |
8 |
> # @ECLASS: tmpfiles.eclass |
9 |
> # @MAINTAINER: |
10 |
> # Gentoo systemd project <systemd@g.o> |
11 |
> # William Hubbs <williamh@g.o> |
12 |
> # @AUTHOR: |
13 |
> # Mike Gilbert <floppym@g.o> |
14 |
> # William Hubbs <williamh@g.o> |
15 |
> # @BLURB: Functions related to tmpfiles.d files |
16 |
> # @DESCRIPTION: |
17 |
> # Provides common functionality related to installation an processing |
18 |
|
19 |
Typo: 'and' |
20 |
|
21 |
> # of tmpfiles snippets. |
22 |
|
23 |
Honestly, I would like to see here either a more complete description |
24 |
(with example!) on what purpose does this eclass serve and how it's |
25 |
supposed to be used. |
26 |
|
27 |
It would probably make sense to explain that it can be used to |
28 |
*reliably* create temporary directories, i.e. without a need for |
29 |
an explicit fallback in ebuild. After all, that's the main goal of |
30 |
the whole effort. |
31 |
|
32 |
It may also be worth it to note that full support requires OpenRC or |
33 |
systemd. People not using either of the two will only get directories |
34 |
created in postinst, and can't use volatile filesystems. |
35 |
|
36 |
> if [[ -z $tmpfiles_eclass ]]; then |
37 |
|
38 |
1. Don't indent the whole eclass. |
39 |
|
40 |
2. Use capitals for global variables. |
41 |
|
42 |
3. Use ${} with braces. |
43 |
|
44 |
> tmpfiles_eclass=1 |
45 |
> |
46 |
> case "${EAPI}" in |
47 |
> 5|6) ;; |
48 |
> *) die "API is undefined for EAPI ${EAPI}" ;; |
49 |
> esac |
50 |
> |
51 |
> DEPEND="virtual/tmpfiles" |
52 |
|
53 |
You don't need build-time dependency on it. It's not used before pkg_*. |
54 |
|
55 |
> RDEPEND="virtual/tmpfiles" |
56 |
|
57 |
1. I'm wondering if there's a case for making this optional |
58 |
(I'm pretty sure we have USE-conditional installs of tmpfiles, however |
59 |
I'm not sure if we care for 100% exact deps). |
60 |
|
61 |
2. I think it would be reasonable to match virtual versions to |
62 |
'versions' of tmpfiles.d support, i.e. to be able to e.g. >=230 when |
63 |
the file needs new feature that was introduced in systemd-230. But |
64 |
maybe it'd good enough to have additional dependency in ebuild then. |
65 |
|
66 |
> |
67 |
... |
68 |
> # @FUNCTION: tmpfiles_create |
69 |
|
70 |
Maybe tmpfiles_process? |
71 |
|
72 |
> # @USAGE: tmpfiles_create |
73 |
|
74 |
I think you actually want to pass filenames here. |
75 |
|
76 |
> # @DESCRIPTION: |
77 |
> # Call a tmpfiles implementation to process newly installed tmpfiles.d |
78 |
> # snippets. Does nothing if no tmpfiles implementation is available. |
79 |
|
80 |
I think it should error out when no implementation is available. We |
81 |
want to be able to reliably create temporary directories. |
82 |
|
83 |
> tmpfiles_create() { |
84 |
> debug-print-function "${FUNCNAME}" "$@" |
85 |
> |
86 |
> [[ ${EBUILD_PHASE} == postinst ]] || die "${FUNCNAME}: Only valid in pkg_postinst" |
87 |
> [[ ${#} -gt 0 ]] || die "${FUNCNAME}: Must specify at least one filename" |
88 |
> [[ ${ROOT} == / ]] || return 0 |
89 |
> |
90 |
> if type systemd-tmpfiles &> /dev/null; then |
91 |
> systemd-tmpfiles --create "$@" |
92 |
> elif type opentmptmpfiles &> /dev/null; then |
93 |
> opentmpfiles --create "$@" |
94 |
> fi |
95 |
> } |
96 |
> |
97 |
> fi |
98 |
|
99 |
I'm wondering if we could go for some cleanup in prerm. But that's |
100 |
probably a far-away future goal. |
101 |
|
102 |
-- |
103 |
Best regards, |
104 |
Michał Górny |
105 |
<http://dev.gentoo.org/~mgorny/> |