Gentoo Archives: gentoo-portage-dev

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

Replies