Gentoo Archives: gentoo-portage-dev

From: Zac Medico <zmedico@g.o>
To: gentoo-portage-dev@l.g.o
Cc: Zac Medico <zmedico@g.o>
Subject: [gentoo-portage-dev] [PATCH v2] inherit: use local -x ECLASS (bug 676014)
Date: Wed, 23 Jan 2019 02:34:09
Message-Id: 20190123023314.23310-1-zmedico@gentoo.org
In Reply to: [gentoo-portage-dev] [PATCH] inherit: use local -x ECLASS (bug 676014) by Zac Medico
1 Use local -x ECLASS, and also make __export_funcs_var a local variable,
2 since this is simpler than managing these variables as globals
3 (eliminates PECLASS and __export_funcs_var variables). As an additional
4 benefit, this prevents interference from ebuild variables as reported
5 in bug 656354 for the ECLASS variable.
6
7 Bug: https://bugs.gentoo.org/656354
8 Bug: https://bugs.gentoo.org/676014
9
10 Signed-off-by: Zac Medico <zmedico@g.o>
11 ---
12 [PATCH v2]
13 * Fix the EXPORT_FUNCTIONS eqawarn messsage, reported by Arfrever
14 * Also make __export_funcs_var local
15
16 bin/ebuild.sh | 27 ++++++++++-----------------
17 1 file changed, 10 insertions(+), 17 deletions(-)
18
19 diff --git a/bin/ebuild.sh b/bin/ebuild.sh
20 index 0ec033ae7..d3bf0fd29 100755
21 --- a/bin/ebuild.sh
22 +++ b/bin/ebuild.sh
23 @@ -240,23 +240,22 @@ inherit() {
24 ECLASS_DEPTH=$(($ECLASS_DEPTH + 1))
25 if [[ ${ECLASS_DEPTH} -gt 1 ]]; then
26 debug-print "*** Multiple Inheritence (Level: ${ECLASS_DEPTH})"
27 - fi
28
29 - if [[ -n $ECLASS && -n ${!__export_funcs_var} ]] ; then
30 - eqawarn "QA Notice: EXPORT_FUNCTIONS is called before inherit in ${ECLASS}.eclass."
31 - eqawarn "For compatibility with <=portage-2.1.6.7, only call EXPORT_FUNCTIONS"
32 - eqawarn "after inherit(s)."
33 + # Since ECLASS_DEPTH > 1, the following variables are locals from the
34 + # previous inherit call in the call stack.
35 + if [[ -n ${ECLASS} && -n ${!__export_funcs_var} ]] ; then
36 + eqawarn "QA Notice: EXPORT_FUNCTIONS is called before inherit in ${ECLASS}.eclass."
37 + eqawarn "For compatibility with <=portage-2.1.6.7, only call EXPORT_FUNCTIONS"
38 + eqawarn "after inherit(s)."
39 + fi
40 fi
41
42 + local -x ECLASS
43 + local __export_funcs_var
44 local repo_location
45 local location
46 local potential_location
47 local x
48 -
49 - # These variables must be restored before returning.
50 - local PECLASS=$ECLASS
51 - local prev_export_funcs_var=$__export_funcs_var
52 -
53 local B_IUSE
54 local B_REQUIRED_USE
55 local B_DEPEND
56 @@ -268,7 +267,7 @@ inherit() {
57 location=""
58 potential_location=""
59
60 - export ECLASS="$1"
61 + ECLASS="$1"
62 __export_funcs_var=__export_functions_$ECLASS_DEPTH
63 unset $__export_funcs_var
64
65 @@ -378,12 +377,6 @@ inherit() {
66 shift
67 done
68 ((--ECLASS_DEPTH)) # Returns 1 when ECLASS_DEPTH reaches 0.
69 - if (( ECLASS_DEPTH > 0 )) ; then
70 - export ECLASS=$PECLASS
71 - __export_funcs_var=$prev_export_funcs_var
72 - else
73 - unset ECLASS __export_funcs_var
74 - fi
75 return 0
76 }
77
78 --
79 2.18.1