Gentoo Archives: gentoo-dev

From: Georgy Yakovlev <gyakovlev@g.o>
To: gentoo-dev@l.g.o
Subject: Re: [gentoo-dev] [PATCH] metadata/install-qa-check.d: add 60tmpfiles-path QA check
Date: Mon, 02 Aug 2021 08:28:57
Message-Id: 7124197.LvFx2qVVIh@cerberus
In Reply to: [gentoo-dev] [PATCH] metadata/install-qa-check.d: add 60tmpfiles-path QA check by Sam James
1 On Saturday, July 31, 2021 4:56:34 PM PDT 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
19 > b/metadata/install-qa-check.d/60tmpfiles-paths 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
28 > the eclass +# 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
33 > the eclass +# (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
37 location
38 > + if [[ -d "${ED}"/etc/tmpfiles.d/ ]] ; then
39 > + eqawarn "QA Notice: files installed to the deprecated /etc/
40 tmpfiles.d
41 > location" + eqawarn "tmpfiles configuration files must be
42 installed to
43 > /usr/lib/tmpfiles.d!" + fi
44 > +
45 > + # Check 2
46 > + # We're now going to check for whether we install files to
47 > /usr/lib/tmpfiles.d without + # inheriting the eclass (weak catch for
48 > ebuilds not calling tmpfiles_process in pkg_postinst) +
49 > + # No need to carry on if we're inheriting the eclass
50 > + if has tmpfiles ${INHERITED} ; then
51 > + return
52
53 it can actually check if ebuild calls tmpfiles_process, not only inherit.
54 something like:
55
56 local pkg_postinst_body="$(declare -fp pkg_postinst)"
57 if [[ ! ${pkg_postinst_body} == *tmpfiles_process* ]]; then
58 eqawarn "QA Notice: package is installing tmpfiles without calling
59 eqawarn "tmpfiles_process in pkg_postinst phase"
60 fi
61
62 ofc accounting for edge cases floppym mentioned.
63
64 > + fi
65 > +
66 > + if [[ -d "${ED}"/usr/lib/tmpfiles.d/ ]] ; then
67 > + eqawarn "QA Notice: package is installing tmpfiles without
68 inheriting
69 > tmpfiles.eclass!" + eqawarn "Packages must inherit tmpfiles.eclass
70 then
71 > call tmpfiles_process in pkg_postinst." + fi
72 > +}
73 > +
74 > +tmpfiles_check
75 > +: # guarantee successful exit
76 > +
77 > +# vim:ft=sh
78
79
80 --
81 Best regards,
82 Georgy

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies