Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: "Michał Górny" <mgorny@g.o>
Subject: Re: [gentoo-portage-dev] [PATCH] Support all install-qa-check.d locations and overrides
Date: Sun, 23 Nov 2014 03:24:11
Message-Id: 54715356.5030308@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] Support all install-qa-check.d locations and overrides by "Michał Górny"
1 On 11/22/2014 03:07 PM, Michał Górny wrote:
2 > Update the install-qa-check.d handling code to conform to GLEP 65.
3 > Collect files from all defined locations, order them lexically by name
4 > and run each uniquely named script once. Make scripts in higher priority
5 > locations override lower priority locations properly.
6 > ---
7 > bin/misc-functions.sh | 65 ++++++++++++++++++++++++++++++++++-----------------
8 > 1 file changed, 43 insertions(+), 22 deletions(-)
9 >
10 > diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
11 > index 6e6fcb4..632d24e 100755
12 > --- a/bin/misc-functions.sh
13 > +++ b/bin/misc-functions.sh
14 > @@ -163,40 +163,61 @@ prepcompress() {
15 > }
16 >
17 > install_qa_check() {
18 > - local f i qa_var x
19 > + local d f i qa_var x paths qa_checks=() checks_run=()
20 > if ! ___eapi_has_prefix_variables; then
21 > local EPREFIX= ED=${D}
22 > fi
23 >
24 > cd "${ED}" || die "cd failed"
25 >
26 > - # Run QA checks from install-qa-check.d.
27 > - # Note: checks need to be run *before* stripping.
28 > - local f
29 > - # TODO: handle nullglob-like
30 > - for f in "${PORTAGE_BIN_PATH}"/install-qa-check.d/*; do
31 > - # Run in a subshell to treat it like external script,
32 > - # but use 'source' to pass all variables through.
33 > - (
34 > - source "${f}" || eerror "Post-install QA check ${f##*/} failed to run"
35 > + # Collect the paths for QA checks, highest prio first.
36 > + paths=(
37 > + # sysadmin overrides
38 > + "${EPREFIX}"/usr/local/lib/install-qa-check.d
39 > + # system-wide package installs
40 > + "${EPREFIX}"/usr/lib/install-qa-check.d
41 > + )
42
43 For "cross-prefix" support, the EPREFIX usage here seems wrong. I think
44 we should use PORTAGE_OVERRIDE_EPREFIX instead of EPREFIX. For
45 reference, see has_version --host-root code in bin/phase-helpers.sh.
46
47 > +
48 > + # Now repo-specific checks.
49 > + # (yes, PORTAGE_ECLASS_LOCATIONS contains repo paths...)
50 > + for d in "${PORTAGE_ECLASS_LOCATIONS[@]}"; do
51 > + paths+=(
52 > + "${d}"/metadata/install-qa-check.d
53 > )
54 > done
55 >
56 > - # Run QA checks from repositories
57 > - # (yes, PORTAGE_ECLASS_LOCATIONS contains repo paths...)
58 > - local repo_location
59 > - for repo_location in "${PORTAGE_ECLASS_LOCATIONS[@]}"; do
60 > - for f in "${repo_location}"/metadata/install-qa-check.d/*; do
61 > - if [[ -f ${f} ]]; then
62 > - (
63 > - # allow inheriting eclasses
64 > - _IN_INSTALL_QA_CHECK=1
65 > - source "${f}" || eerror "Post-install QA check ${f##*/} failed to run"
66 > - )
67 > - fi
68 > + paths+=(
69 > + # Portage built-in checks
70 > + "${EPREFIX}"/usr/lib/portage/install-qa-check.d
71
72 EPREFIX -> PORTAGE_OVERRIDE_EPREFIX
73
74 > + "${PORTAGE_BIN_PATH}"/install-qa-check.d
75 > + )
76 > +
77 > + # Collect file names of QA checks. We need them early to support
78 > + # overrides properly.
79 > + for d in "${paths[@]}"; do
80 > + for f in "${d}"/*; do
81 > + [[ -f ${f} ]] && qa_checks+=( "${f##*/}" )
82 > done
83 > done
84 >
85 > + # Now we need to sort the filenames lexically, and process
86 > + # them in order.
87 > + while IFS= read -r -d '' f; do
88
89 I'm not sure how IFS is relevant here. Please clarify.
90
91 > + # Find highest priority file matching the basename.
92 > + for d in "${paths[@]}"; do
93 > + [[ -f ${d}/${f} ]] && break
94 > + done
95 > +
96 > + # Run in a subshell to treat it like external script,
97 > + # but use 'source' to pass all variables through.
98 > + (
99 > + # Allow inheriting eclasses.
100 > + # XXX: we want this only in repository-wide checks.
101 > + _IN_INSTALL_QA_CHECK=1
102 > + source "${d}/${f}" || eerror "Post-install QA check ${f} failed to run"
103 > + )
104 > + done < <(printf "%s\0" "${qa_checks[@]}" | LC_ALL=C sort -u -z)
105 > +
106 > export STRIP_MASK
107 > prepall
108 > ___eapi_has_docompress && prepcompress
109 >
110
111
112 --
113 Thanks,
114 Zac

Replies