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