Gentoo Archives: gentoo-dev

From: "Michał Górny" <mgorny@g.o>
To: gentoo-dev@l.g.o
Cc: Sam James <sam@g.o>
Subject: Re: [gentoo-dev] [PATCH] metadata/install-qa-check.d: add 60tmpfiles-path QA check
Date: Sun, 01 Aug 2021 09:49:09
Message-Id: bb773ded4b28f503d913a966ccf8f2eb021010fd.camel@gentoo.org
In Reply to: [gentoo-dev] [PATCH] metadata/install-qa-check.d: add 60tmpfiles-path QA check by Sam James
1 On Sun, 2021-08-01 at 00:56 +0100, Sam James wrote:
2 > This adds two tmpfiles related QA checks:
3 > 1) Verify packages don't install tmpfiles to /etc/tmpfiles.d, which
4 > is a deprecated location;
5 >
6 > 2) Check whether packages inherit tmpfiles.eclass if they're
7 > installing files to /usr/lib/tmpfiles.d.
8 >
9 > (This helps to catch packages not calling tmpfiles_process
10 > in pkg_postinst).
11 >
12 > Signed-off-by: Sam James <sam@g.o>
13 > ---
14 > metadata/install-qa-check.d/60tmpfiles-paths | 37 ++++++++++++++++++++
15 > 1 file changed, 37 insertions(+)
16 > create mode 100644 metadata/install-qa-check.d/60tmpfiles-paths
17 >
18 > diff --git a/metadata/install-qa-check.d/60tmpfiles-paths b/metadata/install-qa-check.d/60tmpfiles-paths
19 > new file mode 100644
20 > index 0000000000000..2c56c031bd1e3
21 > --- /dev/null
22 > +++ b/metadata/install-qa-check.d/60tmpfiles-paths
23 > @@ -0,0 +1,37 @@
24 > +# Copyright 2021 Gentoo Authors
25 > +# Distributed under the terms of the GNU General Public License v2
26 > +
27 > +# QA check: ensure that packages installing tmpfiles configuration inherit the eclass
28 > +# Maintainer: Sam James <sam@g.o>
29 > +
30 > +# Implements two checks:
31 > +# 1) Installation to /etc/tmpfiles.d (which is a deprecated location);
32 > +# 2) Installation of any tmpfiles to /usr/lib/tmpfiles.d without inheriting the eclass
33 > +# (needed for tmpfiles_process in pkg_postinst)
34 > +tmpfiles_check() {
35 > + # Check 1
36 > + # Scan image for files in /etc/tmpfiles.d which is a deprecated location
37 > + if [[ -d "${ED}"/etc/tmpfiles.d/ ]] ; then
38
39 Nit: normally quoting is not necessary inside [[ ... ]].
40
41 > + eqawarn "QA Notice: files installed to the deprecated /etc/tmpfiles.d location"
42 > + eqawarn "tmpfiles configuration files must be installed to /usr/lib/tmpfiles.d!"
43 > + fi
44 > +
45 > + # Check 2
46 > + # We're now going to check for whether we install files to /usr/lib/tmpfiles.d without
47 > + # inheriting the eclass (weak catch for ebuilds not calling tmpfiles_process in pkg_postinst)
48 > +
49 > + # No need to carry on if we're inheriting the eclass
50 > + if has tmpfiles ${INHERITED} ; then
51 > + return
52 > + fi
53 > +
54 > + if [[ -d "${ED}"/usr/lib/tmpfiles.d/ ]] ; then
55 > + eqawarn "QA Notice: package is installing tmpfiles without inheriting tmpfiles.eclass!"
56 > + eqawarn "Packages must inherit tmpfiles.eclass then call tmpfiles_process in pkg_postinst."
57 > + fi
58 > +}
59 > +
60 > +tmpfiles_check
61 > +: # guarantee successful exit
62 > +
63 > +# vim:ft=sh
64
65 --
66 Best regards,
67 Michał Górny