public inbox for gentoo-portage-dev@lists.gentoo.org
 help / color / mirror / Atom feed
* [gentoo-portage-dev] [PATCH] inherit: use local -x ECLASS (bug 676014)
@ 2019-01-22  3:49 Zac Medico
  2019-01-23  2:33 ` [gentoo-portage-dev] [PATCH v2] " Zac Medico
  0 siblings, 1 reply; 2+ messages in thread
From: Zac Medico @ 2019-01-22  3:49 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Zac Medico

Use local -x ECLASS.

Bug: https://bugs.gentoo.org/656354
Bug: https://bugs.gentoo.org/676014

Signed-off-by: Zac Medico <zmedico@gentoo.org>
---
 bin/ebuild.sh | 26 ++++++++++----------------
 1 file changed, 10 insertions(+), 16 deletions(-)

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 820db50ca..64041dff9 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -242,21 +242,13 @@ inherit() {
 		debug-print "*** Multiple Inheritence (Level: ${ECLASS_DEPTH})"
 	fi
 
-	if [[ -n $ECLASS && -n ${!__export_funcs_var} ]] ; then
-		echo "QA Notice: EXPORT_FUNCTIONS is called before inherit in" \
-			"$ECLASS.eclass. For compatibility with <=portage-2.1.6.7," \
-			"only call EXPORT_FUNCTIONS after inherit(s)." \
-			| fmt -w 75 | while read -r ; do eqawarn "$REPLY" ; done
-	fi
-
 	local repo_location
 	local location
 	local potential_location
 	local x
 
 	# These variables must be restored before returning.
-	local PECLASS=$ECLASS
-	local prev_export_funcs_var=$__export_funcs_var
+	local -x ECLASS
 
 	local B_IUSE
 	local B_REQUIRED_USE
@@ -265,11 +257,19 @@ inherit() {
 	local B_PDEPEND
 	local B_HDEPEND
 	local B_BDEPEND
+
+	if [[ -n ${ECLASS} && -n ${!__export_funcs_var} ]] ; then
+		echo "QA Notice: EXPORT_FUNCTIONS is called before inherit in" \
+			"${ECLASS}.eclass. For compatibility with <=portage-2.1.6.7," \
+			"only call EXPORT_FUNCTIONS after inherit(s)." \
+			| fmt -w 75 | while read -r ; do eqawarn "${REPLY}" ; done
+	fi
+
 	while [ "$1" ]; do
 		location=""
 		potential_location=""
 
-		export ECLASS="$1"
+		ECLASS="$1"
 		__export_funcs_var=__export_functions_$ECLASS_DEPTH
 		unset $__export_funcs_var
 
@@ -379,12 +379,6 @@ inherit() {
 		shift
 	done
 	((--ECLASS_DEPTH)) # Returns 1 when ECLASS_DEPTH reaches 0.
-	if (( ECLASS_DEPTH > 0 )) ; then
-		export ECLASS=$PECLASS
-		__export_funcs_var=$prev_export_funcs_var
-	else
-		unset ECLASS __export_funcs_var
-	fi
 	return 0
 }
 
-- 
2.18.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

* [gentoo-portage-dev] [PATCH v2] inherit: use local -x ECLASS (bug 676014)
  2019-01-22  3:49 [gentoo-portage-dev] [PATCH] inherit: use local -x ECLASS (bug 676014) Zac Medico
@ 2019-01-23  2:33 ` Zac Medico
  0 siblings, 0 replies; 2+ messages in thread
From: Zac Medico @ 2019-01-23  2:33 UTC (permalink / raw
  To: gentoo-portage-dev; +Cc: Zac Medico

Use local -x ECLASS, and also make __export_funcs_var a local variable,
since this is simpler than managing these variables as globals
(eliminates PECLASS and __export_funcs_var variables). As an additional
benefit, this prevents interference from ebuild variables as reported
in bug 656354 for the ECLASS variable.

Bug: https://bugs.gentoo.org/656354
Bug: https://bugs.gentoo.org/676014

Signed-off-by: Zac Medico <zmedico@gentoo.org>
---
[PATCH v2]
* Fix the EXPORT_FUNCTIONS eqawarn messsage, reported by Arfrever
* Also make __export_funcs_var local

 bin/ebuild.sh | 27 ++++++++++-----------------
 1 file changed, 10 insertions(+), 17 deletions(-)

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index 0ec033ae7..d3bf0fd29 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -240,23 +240,22 @@ inherit() {
 	ECLASS_DEPTH=$(($ECLASS_DEPTH + 1))
 	if [[ ${ECLASS_DEPTH} -gt 1 ]]; then
 		debug-print "*** Multiple Inheritence (Level: ${ECLASS_DEPTH})"
-	fi
 
-	if [[ -n $ECLASS && -n ${!__export_funcs_var} ]] ; then
-		eqawarn "QA Notice: EXPORT_FUNCTIONS is called before inherit in ${ECLASS}.eclass."
-		eqawarn "For compatibility with <=portage-2.1.6.7, only call EXPORT_FUNCTIONS"
-		eqawarn "after inherit(s)."
+		# Since ECLASS_DEPTH > 1, the following variables are locals from the
+		# previous inherit call in the call stack.
+		if [[ -n ${ECLASS} && -n ${!__export_funcs_var} ]] ; then
+			eqawarn "QA Notice: EXPORT_FUNCTIONS is called before inherit in ${ECLASS}.eclass."
+			eqawarn "For compatibility with <=portage-2.1.6.7, only call EXPORT_FUNCTIONS"
+			eqawarn "after inherit(s)."
+		fi
 	fi
 
+	local -x ECLASS
+	local __export_funcs_var
 	local repo_location
 	local location
 	local potential_location
 	local x
-
-	# These variables must be restored before returning.
-	local PECLASS=$ECLASS
-	local prev_export_funcs_var=$__export_funcs_var
-
 	local B_IUSE
 	local B_REQUIRED_USE
 	local B_DEPEND
@@ -268,7 +267,7 @@ inherit() {
 		location=""
 		potential_location=""
 
-		export ECLASS="$1"
+		ECLASS="$1"
 		__export_funcs_var=__export_functions_$ECLASS_DEPTH
 		unset $__export_funcs_var
 
@@ -378,12 +377,6 @@ inherit() {
 		shift
 	done
 	((--ECLASS_DEPTH)) # Returns 1 when ECLASS_DEPTH reaches 0.
-	if (( ECLASS_DEPTH > 0 )) ; then
-		export ECLASS=$PECLASS
-		__export_funcs_var=$prev_export_funcs_var
-	else
-		unset ECLASS __export_funcs_var
-	fi
 	return 0
 }
 
-- 
2.18.1



^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-01-23  2:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-01-22  3:49 [gentoo-portage-dev] [PATCH] inherit: use local -x ECLASS (bug 676014) Zac Medico
2019-01-23  2:33 ` [gentoo-portage-dev] [PATCH v2] " Zac Medico

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox