diff --git a/bin/ebuild.sh b/bin/ebuild.sh index c38f9b923..1949a1e78 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -214,6 +214,18 @@ fi # (not secretive, but not stupid) umask 022 +# Assigns the caller's ___names array with the names of the metadata variables +# whose values accumulate across eclasses. +__accumulating_names() { + ___names=( BDEPEND DEPEND IDEPEND IUSE PDEPEND RDEPEND REQUIRED_USE ) + if ___eapi_accumulates_PROPERTIES; then + ___names+=( PROPERTIES ) + fi + if ___eapi_accumulates_RESTRICT; then + ___names+=( RESTRICT ) + fi +} + # Sources all eclasses in parameters inherit() { if (( ___state[eclass-depth]++ > 0 )); then @@ -228,10 +240,12 @@ inherit() { fi fi - local B_REQUIRED_USE B_PROPERTIES B_RESTRICT B_BDEPEND B_IDEPEND B_PDEPEND B_RDEPEND B_DEPEND B_IUSE - local ___potential_location ___export_funcs_var ___repo_location ___phase_func ___location + local ___potential_location ___export_funcs_var ___repo_location ___phase_func ___location ___restore + local -a ___names local -x ECLASS + __accumulating_names + while (( $# )); do ___location= ___potential_location= @@ -269,29 +283,15 @@ inherit() { # Inherits in QA checks can't handle metadata assignments if (( ! ___state[in-qa-check] )); then - # We need to back up the values of *DEPEND to B_*DEPEND - # (if set).. and then restore them after the inherit call. - - # Retain the old data and restore it later. - unset -v B_IUSE B_REQUIRED_USE B_DEPEND B_RDEPEND B_PDEPEND - unset -v B_BDEPEND B_IDEPEND B_PROPERTIES B_RESTRICT - [[ -v IUSE ]] && B_IUSE="${IUSE}" - [[ -v REQUIRED_USE ]] && B_REQUIRED_USE="${REQUIRED_USE}" - [[ -v DEPEND ]] && B_DEPEND="${DEPEND}" - [[ -v RDEPEND ]] && B_RDEPEND="${RDEPEND}" - [[ -v PDEPEND ]] && B_PDEPEND="${PDEPEND}" - [[ -v BDEPEND ]] && B_BDEPEND="${BDEPEND}" - [[ -v IDEPEND ]] && B_IDEPEND="${IDEPEND}" - unset -v IUSE REQUIRED_USE DEPEND RDEPEND PDEPEND BDEPEND IDEPEND - - if ___eapi_accumulates_PROPERTIES; then - [[ -v PROPERTIES ]] && B_PROPERTIES=${PROPERTIES} - unset -v PROPERTIES - fi - if ___eapi_accumulates_RESTRICT; then - [[ -v RESTRICT ]] && B_RESTRICT=${RESTRICT} - unset -v RESTRICT - fi + # Set the metadata variables aside, so that only the + # values assigned by the eclass are seen afterwards. + ___restore= + for _ in "${___names[@]}"; do + if [[ -v $_ ]]; then + ___restore+=$_=${!_@Q}$'\n' + fi + done + unset -v "${___names[@]}" fi if ! __qa_source "${___location}"; then @@ -299,53 +299,16 @@ inherit() { fi if (( ! ___state[in-qa-check] )); then - # If each var has a value, append it to the global variable E_* to - # be applied after everything is finished. New incremental behavior. - [[ -v IUSE ]] && E_IUSE+="${E_IUSE:+ }${IUSE}" - [[ -v REQUIRED_USE ]] && E_REQUIRED_USE+="${E_REQUIRED_USE:+ }${REQUIRED_USE}" - [[ -v DEPEND ]] && E_DEPEND+="${E_DEPEND:+ }${DEPEND}" - [[ -v RDEPEND ]] && E_RDEPEND+="${E_RDEPEND:+ }${RDEPEND}" - [[ -v PDEPEND ]] && E_PDEPEND+="${E_PDEPEND:+ }${PDEPEND}" - [[ -v BDEPEND ]] && E_BDEPEND+="${E_BDEPEND:+ }${BDEPEND}" - [[ -v IDEPEND ]] && E_IDEPEND+="${E_IDEPEND:+ }${IDEPEND}" - - [[ -v B_IUSE ]] && IUSE="${B_IUSE}" - [[ -v B_IUSE ]] || unset -v IUSE - - [[ -v B_REQUIRED_USE ]] && REQUIRED_USE="${B_REQUIRED_USE}" - [[ -v B_REQUIRED_USE ]] || unset -v REQUIRED_USE - - [[ -v B_DEPEND ]] && DEPEND="${B_DEPEND}" - [[ -v B_DEPEND ]] || unset -v DEPEND - - [[ -v B_RDEPEND ]] && RDEPEND="${B_RDEPEND}" - [[ -v B_RDEPEND ]] || unset -v RDEPEND - - [[ -v B_PDEPEND ]] && PDEPEND="${B_PDEPEND}" - [[ -v B_PDEPEND ]] || unset -v PDEPEND - - [[ -v B_BDEPEND ]] && BDEPEND="${B_BDEPEND}" - [[ -v B_BDEPEND ]] || unset -v BDEPEND - - [[ -v B_IDEPEND ]] && IDEPEND="${B_IDEPEND}" - [[ -v B_IDEPEND ]] || unset -v IDEPEND - - if ___eapi_accumulates_PROPERTIES; then - [[ -v PROPERTIES ]] && - E_PROPERTIES+=${E_PROPERTIES:+ }${PROPERTIES} - [[ -v B_PROPERTIES ]] && - PROPERTIES=${B_PROPERTIES} - [[ -v B_PROPERTIES ]] || - unset -v PROPERTIES - fi - if ___eapi_accumulates_RESTRICT; then - [[ -v RESTRICT ]] && - E_RESTRICT+=${E_RESTRICT:+ }${RESTRICT} - [[ -v B_RESTRICT ]] && - RESTRICT=${B_RESTRICT} - [[ -v B_RESTRICT ]] || - unset -v RESTRICT - fi + # Append whatever the eclass assigned to the values + # accumulated thus far, to be applied once the ebuild + # has been sourced. Then restore the prior values. + for _ in "${___names[@]}"; do + if [[ -v $_ ]]; then + ___state[eclass-$_]+=${___state[eclass-$_]:+ }${!_} + fi + done + unset -v "${___names[@]}" + eval "${___restore}" if [[ ${!___export_funcs_var} ]]; then for ___phase_func in ${!___export_funcs_var}; do @@ -372,6 +335,17 @@ inherit() { return 0 } +# Appends the metadata accumulated from eclasses to the variables of the same +# names, as assigned by the ebuild. +__append_eclass_metadata() { + local -a ___names + + __accumulating_names + for _ in "${___names[@]}"; do + eval "$_"+='${!_:+ }${___state[eclass-$_]}' + done +} + # Exports stub functions that call the eclass's functions, thereby making them default. # For example, if ECLASS="base" and you call "EXPORT_FUNCTIONS src_unpack", the following # code will be eval'd: @@ -623,11 +597,10 @@ if [[ ${EBUILD_PHASE} != clean?(rm) ]]; then # In order to ensure correct interaction between ebuilds and # eclasses, they need to be unset before this process of # interaction begins. - unset -v BDEPEND DEPEND EAPI ECLASS E_BDEPEND E_DEPEND E_IDEPEND - unset -v E_IUSE E_PDEPEND E_PROPERTIES E_RDEPEND E_REQUIRED_USE - unset -v E_RESTRICT IDEPEND INHERITED IUSE PDEPEND - unset -v PORTAGE_EXPLICIT_INHERIT PROPERTIES PROVIDES_EXCLUDE - unset -v RDEPEND REQUIRED_USE REQUIRES_EXCLUDE RESTRICT + unset -v BDEPEND DEPEND EAPI ECLASS IDEPEND INHERITED IUSE + unset -v PDEPEND PORTAGE_EXPLICIT_INHERIT PROPERTIES + unset -v PROVIDES_EXCLUDE RDEPEND REQUIRED_USE REQUIRES_EXCLUDE + unset -v RESTRICT pre_source_sandbox() { export SANDBOX_ON=1 @@ -692,23 +665,9 @@ if [[ ${EBUILD_PHASE} != clean?(rm) ]]; then fi # Add in dependency info from eclasses - IUSE+="${IUSE:+ }${E_IUSE}" - DEPEND+="${DEPEND:+ }${E_DEPEND}" - RDEPEND+="${RDEPEND:+ }${E_RDEPEND}" - PDEPEND+="${PDEPEND:+ }${E_PDEPEND}" - BDEPEND+="${BDEPEND:+ }${E_BDEPEND}" - IDEPEND+="${IDEPEND:+ }${E_IDEPEND}" - REQUIRED_USE+="${REQUIRED_USE:+ }${E_REQUIRED_USE}" - - if ___eapi_accumulates_PROPERTIES; then - PROPERTIES+=${PROPERTIES:+ }${E_PROPERTIES} - fi - if ___eapi_accumulates_RESTRICT; then - RESTRICT+=${RESTRICT:+ }${E_RESTRICT} - fi + __append_eclass_metadata - unset -v ECLASS E_IUSE E_REQUIRED_USE E_DEPEND E_RDEPEND E_PDEPEND - unset -v E_BDEPEND E_PROPERTIES E_RESTRICT '___state[cached-inherited]' + unset -v ECLASS '___state[cached-inherited]' if [[ "${EBUILD_PHASE}" != "depend" ]] ; then PROPERTIES=${PORTAGE_PROPERTIES}