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 2/2] Allow inheriting utility eclasses in QA checks
Date: Thu, 11 Sep 2014 17:31:36
Message-Id: 1410456683-10843-2-git-send-email-mgorny@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH 1/2] Run install-qa-check.d scripts from repositories by "Michał Górny"
1 Allow inheriting utility eclasses for use in QA checks. The eclasses can
2 be used e.g. to obtain paths or other data needed for the check.
3 However, the eclasses must not export phases or set ebuild metadata.
4 ---
5 bin/ebuild.sh | 131 ++++++++++++++++++++++++++------------------------
6 bin/misc-functions.sh | 2 +
7 2 files changed, 70 insertions(+), 63 deletions(-)
8
9 diff --git a/bin/ebuild.sh b/bin/ebuild.sh
10 index be044e0..b980caa 100755
11 --- a/bin/ebuild.sh
12 +++ b/bin/ebuild.sh
13 @@ -230,10 +230,10 @@ inherit() {
14 __export_funcs_var=__export_functions_$ECLASS_DEPTH
15 unset $__export_funcs_var
16
17 - if [ "${EBUILD_PHASE}" != "depend" ] && \
18 - [ "${EBUILD_PHASE}" != "nofetch" ] && \
19 - [[ ${EBUILD_PHASE} != *rm ]] && \
20 - [[ ${EMERGE_FROM} != "binary" ]] ; then
21 + if [[ ${EBUILD_PHASE} != depend && ${EBUILD_PHASE} != nofetch && \
22 + ${EBUILD_PHASE} != *rm && ${EMERGE_FROM} != "binary" && \
23 + -z ${_IN_INSTALL_QA_CHECK} ]]
24 + then
25 # This is disabled in the *rm phases because they frequently give
26 # false alarms due to INHERITED in /var/db/pkg being outdated
27 # in comparison the the eclasses from the portage tree. It's
28 @@ -256,70 +256,75 @@ inherit() {
29 debug-print "inherit: $1 -> $location"
30 [[ -z ${location} ]] && die "${1}.eclass could not be found by inherit()"
31
32 - #We need to back up the values of *DEPEND to B_*DEPEND
33 - #(if set).. and then restore them after the inherit call.
34 -
35 - #turn off glob expansion
36 - set -f
37 -
38 - # Retain the old data and restore it later.
39 - unset B_IUSE B_REQUIRED_USE B_DEPEND B_RDEPEND B_PDEPEND B_HDEPEND
40 - [ "${IUSE+set}" = set ] && B_IUSE="${IUSE}"
41 - [ "${REQUIRED_USE+set}" = set ] && B_REQUIRED_USE="${REQUIRED_USE}"
42 - [ "${DEPEND+set}" = set ] && B_DEPEND="${DEPEND}"
43 - [ "${RDEPEND+set}" = set ] && B_RDEPEND="${RDEPEND}"
44 - [ "${PDEPEND+set}" = set ] && B_PDEPEND="${PDEPEND}"
45 - [ "${HDEPEND+set}" = set ] && B_HDEPEND="${HDEPEND}"
46 - unset IUSE REQUIRED_USE DEPEND RDEPEND PDEPEND HDEPEND
47 - #turn on glob expansion
48 - set +f
49 + # inherits in QA checks can't handle metadata assignments
50 + if [[ -z ${_IN_INSTALL_QA_CHECK} ]]; then
51 + #We need to back up the values of *DEPEND to B_*DEPEND
52 + #(if set).. and then restore them after the inherit call.
53 +
54 + #turn off glob expansion
55 + set -f
56 +
57 + # Retain the old data and restore it later.
58 + unset B_IUSE B_REQUIRED_USE B_DEPEND B_RDEPEND B_PDEPEND B_HDEPEND
59 + [ "${IUSE+set}" = set ] && B_IUSE="${IUSE}"
60 + [ "${REQUIRED_USE+set}" = set ] && B_REQUIRED_USE="${REQUIRED_USE}"
61 + [ "${DEPEND+set}" = set ] && B_DEPEND="${DEPEND}"
62 + [ "${RDEPEND+set}" = set ] && B_RDEPEND="${RDEPEND}"
63 + [ "${PDEPEND+set}" = set ] && B_PDEPEND="${PDEPEND}"
64 + [ "${HDEPEND+set}" = set ] && B_HDEPEND="${HDEPEND}"
65 + unset IUSE REQUIRED_USE DEPEND RDEPEND PDEPEND HDEPEND
66 + #turn on glob expansion
67 + set +f
68 + fi
69
70 __qa_source "$location" || die "died sourcing $location in inherit()"
71
72 - #turn off glob expansion
73 - set -f
74 -
75 - # If each var has a value, append it to the global variable E_* to
76 - # be applied after everything is finished. New incremental behavior.
77 - [ "${IUSE+set}" = set ] && E_IUSE+="${E_IUSE:+ }${IUSE}"
78 - [ "${REQUIRED_USE+set}" = set ] && E_REQUIRED_USE+="${E_REQUIRED_USE:+ }${REQUIRED_USE}"
79 - [ "${DEPEND+set}" = set ] && E_DEPEND+="${E_DEPEND:+ }${DEPEND}"
80 - [ "${RDEPEND+set}" = set ] && E_RDEPEND+="${E_RDEPEND:+ }${RDEPEND}"
81 - [ "${PDEPEND+set}" = set ] && E_PDEPEND+="${E_PDEPEND:+ }${PDEPEND}"
82 - [ "${HDEPEND+set}" = set ] && E_HDEPEND+="${E_HDEPEND:+ }${HDEPEND}"
83 -
84 - [ "${B_IUSE+set}" = set ] && IUSE="${B_IUSE}"
85 - [ "${B_IUSE+set}" = set ] || unset IUSE
86 -
87 - [ "${B_REQUIRED_USE+set}" = set ] && REQUIRED_USE="${B_REQUIRED_USE}"
88 - [ "${B_REQUIRED_USE+set}" = set ] || unset REQUIRED_USE
89 -
90 - [ "${B_DEPEND+set}" = set ] && DEPEND="${B_DEPEND}"
91 - [ "${B_DEPEND+set}" = set ] || unset DEPEND
92 -
93 - [ "${B_RDEPEND+set}" = set ] && RDEPEND="${B_RDEPEND}"
94 - [ "${B_RDEPEND+set}" = set ] || unset RDEPEND
95 -
96 - [ "${B_PDEPEND+set}" = set ] && PDEPEND="${B_PDEPEND}"
97 - [ "${B_PDEPEND+set}" = set ] || unset PDEPEND
98 -
99 - [ "${B_HDEPEND+set}" = set ] && HDEPEND="${B_HDEPEND}"
100 - [ "${B_HDEPEND+set}" = set ] || unset HDEPEND
101 -
102 - #turn on glob expansion
103 - set +f
104 + if [[ -z ${_IN_INSTALL_QA_CHECK} ]]; then
105 + #turn off glob expansion
106 + set -f
107 +
108 + # If each var has a value, append it to the global variable E_* to
109 + # be applied after everything is finished. New incremental behavior.
110 + [ "${IUSE+set}" = set ] && E_IUSE+="${E_IUSE:+ }${IUSE}"
111 + [ "${REQUIRED_USE+set}" = set ] && E_REQUIRED_USE+="${E_REQUIRED_USE:+ }${REQUIRED_USE}"
112 + [ "${DEPEND+set}" = set ] && E_DEPEND+="${E_DEPEND:+ }${DEPEND}"
113 + [ "${RDEPEND+set}" = set ] && E_RDEPEND+="${E_RDEPEND:+ }${RDEPEND}"
114 + [ "${PDEPEND+set}" = set ] && E_PDEPEND+="${E_PDEPEND:+ }${PDEPEND}"
115 + [ "${HDEPEND+set}" = set ] && E_HDEPEND+="${E_HDEPEND:+ }${HDEPEND}"
116 +
117 + [ "${B_IUSE+set}" = set ] && IUSE="${B_IUSE}"
118 + [ "${B_IUSE+set}" = set ] || unset IUSE
119 +
120 + [ "${B_REQUIRED_USE+set}" = set ] && REQUIRED_USE="${B_REQUIRED_USE}"
121 + [ "${B_REQUIRED_USE+set}" = set ] || unset REQUIRED_USE
122 +
123 + [ "${B_DEPEND+set}" = set ] && DEPEND="${B_DEPEND}"
124 + [ "${B_DEPEND+set}" = set ] || unset DEPEND
125 +
126 + [ "${B_RDEPEND+set}" = set ] && RDEPEND="${B_RDEPEND}"
127 + [ "${B_RDEPEND+set}" = set ] || unset RDEPEND
128 +
129 + [ "${B_PDEPEND+set}" = set ] && PDEPEND="${B_PDEPEND}"
130 + [ "${B_PDEPEND+set}" = set ] || unset PDEPEND
131 +
132 + [ "${B_HDEPEND+set}" = set ] && HDEPEND="${B_HDEPEND}"
133 + [ "${B_HDEPEND+set}" = set ] || unset HDEPEND
134 +
135 + #turn on glob expansion
136 + set +f
137 +
138 + if [[ -n ${!__export_funcs_var} ]] ; then
139 + for x in ${!__export_funcs_var} ; do
140 + debug-print "EXPORT_FUNCTIONS: $x -> ${ECLASS}_$x"
141 + declare -F "${ECLASS}_$x" >/dev/null || \
142 + die "EXPORT_FUNCTIONS: ${ECLASS}_$x is not defined"
143 + eval "$x() { ${ECLASS}_$x \"\$@\" ; }" > /dev/null
144 + done
145 + fi
146 + unset $__export_funcs_var
147
148 - if [[ -n ${!__export_funcs_var} ]] ; then
149 - for x in ${!__export_funcs_var} ; do
150 - debug-print "EXPORT_FUNCTIONS: $x -> ${ECLASS}_$x"
151 - declare -F "${ECLASS}_$x" >/dev/null || \
152 - die "EXPORT_FUNCTIONS: ${ECLASS}_$x is not defined"
153 - eval "$x() { ${ECLASS}_$x \"\$@\" ; }" > /dev/null
154 - done
155 + has $1 $INHERITED || export INHERITED="$INHERITED $1"
156 fi
157 - unset $__export_funcs_var
158 -
159 - has $1 $INHERITED || export INHERITED="$INHERITED $1"
160
161 shift
162 done
163 diff --git a/bin/misc-functions.sh b/bin/misc-functions.sh
164 index bd43360..cc652a9 100755
165 --- a/bin/misc-functions.sh
166 +++ b/bin/misc-functions.sh
167 @@ -189,6 +189,8 @@ install_qa_check() {
168 for f in "${repo_location}"/metadata/install-qa-check.d/*; do
169 if [[ -f ${f} ]]; then
170 (
171 + # allow inheriting eclasses
172 + _IN_INSTALL_QA_CHECK=1
173 source "${f}" || eerror "Post-install QA check ${f##*/} failed to run"
174 )
175 fi
176 --
177 2.1.0