Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: William Hubbs <williamh@g.o>
Cc: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] new eclass: tmpfiles.eclass round 2
Date: Wed, 16 Nov 2016 21:35:09
Message-Id: 20161116223447.7c8bf951.mgorny@gentoo.org
In Reply to: [gentoo-dev] new eclass: tmpfiles.eclass round 2 by William Hubbs
1 On Tue, 15 Nov 2016 17:17:46 -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 > # This eclass provides functionality related to installing and
18 > # creating volatile and temporary files based on configuration files$and
19 > # locations defined at this URL:
20 > #
21 > # https://www.freedesktop.org/software/systemd/man/tmpfiles.d.html
22 > #
23 > # the dotmpfiles.d and newtmpfiles.d functions are used to install
24 > # configuration files into /usr/lib, then in pkg_postinst, the
25 > # tmpfiles.d_create function can be called to process the newly
26 > # installed tmpfiles.d entries.
27 > #
28 > # @EXAMPLE:
29 > # Typical usage of this eclass:
30 > #
31 > # @CODE
32 > # EAPI=6
33 > # inherit tmpfiles
34 > #
35 > # ...
36 > #
37 > # src_install() {
38 > # ...
39 > # dotmpfiles.d "${FILESDIR}"/file1.conf "${FILESDIR}"/file2.conf
40 > # newtmpfiles.d "${FILESDIR}"/file3 file3.conf
41
42 Maybe something more realistic:
43
44 newtmpfiles.d "${FILESDIR}"/file3.conf-r1 file3.conf
45
46 > # @FUNCTION: tmpfiles.d_create
47
48 I still don't like the function name. It suggests that it creates
49 a tmpfiles.d file which is going to be confusing.
50
51 Furthermore, I'm not convinced about the 'tmpfiles.d' prefix here.
52 The eclass is named 'tmpfiles' after all.
53
54 So... tmpfiles_apply?
55
56 > # @USAGE: tmpfiles.d_create <filename> <filename> ...
57
58 By the way, are we going to allow passing additional options here?
59 Maybe we should assert for that.
60
61 > # @DESCRIPTION:
62 > # Call a tmpfiles.d implementation to create new volatile and temporary
63 > # files and directories.
64 > tmpfiles.d_create() {
65 > debug-print-function "${FUNCNAME}" "$@"
66 >
67 > [[ ${EBUILD_PHASE} == postinst ]] || die "${FUNCNAME}: Only valid in pkg_postinst"
68 > [[ ${#} -gt 0 ]] || die "${FUNCNAME}: Must specify at least one filename"
69 > [[ ${ROOT} == / ]] || return 0
70 >
71 > if type systemd-tmpfiles &> /dev/null; then
72 > systemd-tmpfiles --create "$@"
73 > elif type opentmptmpfiles &> /dev/null; then
74 > opentmpfiles --create "$@"
75 > fi
76 > }
77 >
78 > fi
79
80
81
82 --
83 Best regards,
84 Michał Górny
85 <http://dev.gentoo.org/~mgorny/>