summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2009-03-08 06:26:09 +0000
committerZac Medico <zmedico@gentoo.org>2009-03-08 06:26:09 +0000
commit63afbc1009c87071a6a66bf3f6dd26c311a81fe8 (patch)
tree676f9cf1659b689e7b2bbef9f40d50fcaece7806
parent625dfec772c783c352d0245133aaef5fc0f0e261 (diff)
downloadportage-63afbc1009c87071a6a66bf3f6dd26c311a81fe8.tar.gz
portage-63afbc1009c87071a6a66bf3f6dd26c311a81fe8.tar.bz2
portage-63afbc1009c87071a6a66bf3f6dd26c311a81fe8.zip
Make EXPORT_FUNCTIONS store it's arguments in an environment variable and
perform the function generation after the current inherit call has returned. This way an eclass can call EXPORT_FUNCTIONS either before or after it inherits other eclasses, and the result is still the same. Thanks to Donnie Berkholz <dberkholz@g.o> for reporting. svn path=/main/trunk/; revision=12782
-rwxr-xr-xbin/ebuild.sh20
1 files changed, 13 insertions, 7 deletions
diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index dac55a211..d1ff26aba 100755
--- a/bin/ebuild.sh
+++ b/bin/ebuild.sh
@@ -1159,6 +1159,7 @@ inherit() {
local location
local olocation
local PECLASS
+ local export_funcs_var x
local B_IUSE
local B_DEPEND
@@ -1171,6 +1172,8 @@ inherit() {
# PECLASS is used to restore the ECLASS var after recursion.
PECLASS="$ECLASS"
export ECLASS="$1"
+ export_funcs_var=__export_functions_${ECLASS/-/___}
+ unset $export_funcs_var
if [ "${EBUILD_PHASE}" != "depend" ] && \
[[ ${EBUILD_PHASE} != *rm ]] && \
@@ -1245,6 +1248,14 @@ inherit() {
#turn on glob expansion
set +f
+ if [[ -n ${!export_funcs_var} ]] ; then
+ for x in ${!export_funcs_var} ; do
+ debug-print "EXPORT_FUNCTIONS: $x -> ${ECLASS}_$x"
+ eval "$x() { ${ECLASS}_$x \"\$@\" ; }" > /dev/null
+ done
+ fi
+ unset $export_funcs_var
+
hasq $1 $INHERITED || export INHERITED="$INHERITED $1"
export ECLASS="$PECLASS"
@@ -1261,14 +1272,9 @@ inherit() {
# src_unpack() { base_src_unpack; }
EXPORT_FUNCTIONS() {
if [ -z "$ECLASS" ]; then
- echo "EXPORT_FUNCTIONS without a defined ECLASS" >&2
- exit 1
+ die "EXPORT_FUNCTIONS without a defined ECLASS"
fi
- while [ "$1" ]; do
- debug-print "EXPORT_FUNCTIONS: ${1} -> ${ECLASS}_${1}"
- eval "$1() { ${ECLASS}_$1 \"\$@\" ; }" > /dev/null
- shift
- done
+ eval __export_functions_${ECLASS/-/___}+=\" $*\"
}
# adds all parameters to E_DEPEND and E_RDEPEND, which get added to DEPEND