Preserve variables which have been set in global scope using 'declare'.
authorArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>
Sun, 18 Oct 2009 05:27:30 +0000 (05:27 -0000)
committerArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>
Sun, 18 Oct 2009 05:27:30 +0000 (05:27 -0000)
svn path=/main/trunk/; revision=14662

bin/ebuild.sh
bin/isolated-functions.sh

index 63f8bdedb510affa0c1d59f83e442e7a3bc4e30b..4fa19f30081f600c239e06d2ac20a2eee52047c3 100755 (executable)
@@ -1633,8 +1633,8 @@ PORTAGE_MUTABLE_FILTERED_VARS="AA HOSTNAME"
 # variables out and discards them. See bug #190128.
 filter_readonly_variables() {
        local x filtered_vars
-       local readonly_bash_vars="DIRSTACK EUID FUNCNAME GROUPS
-               PIPESTATUS PPID SHELLOPTS UID"
+       local readonly_bash_vars="BASHPID DIRSTACK EUID FUNCNAME
+               GROUPS PIPESTATUS PPID SHELLOPTS UID"
        local filtered_sandbox_vars="SANDBOX_ACTIVE SANDBOX_BASHRC
                SANDBOX_DEBUG_LOG SANDBOX_DISABLED SANDBOX_LIB
                SANDBOX_LOG SANDBOX_ON"
@@ -1817,78 +1817,75 @@ if ! hasq "$EBUILD_PHASE" clean cleanrm depend && \
        [[ -n $EAPI ]] || EAPI=0
 fi
 
-_source_ebuild() {
-       # The bashrcs get an opportunity here to set aliases that will be expanded
-       # during sourcing of ebuilds and eclasses.
-       source_all_bashrcs
-
-       # *DEPEND and IUSE will be set during the sourcing of the ebuild.
-       # In order to ensure correct interaction between ebuilds and
-       # eclasses, they need to be unset before this process of
-       # interaction begins.
-       unset DEPEND RDEPEND PDEPEND IUSE
-       source "${EBUILD}" || die "error sourcing ebuild"
-
-       if [ "${EBUILD_PHASE}" != "depend" ] ; then
-               RESTRICT=${PORTAGE_RESTRICT}
-               [[ -e $PORTAGE_BUILDDIR/.ebuild_changed ]] && \
+if ! hasq "$EBUILD_PHASE" clean cleanrm ; then
+       if [[ $EBUILD_PHASE = depend || ! -f $T/environment || \
+               -f $PORTAGE_BUILDDIR/.ebuild_changed ]] || \
+               hasq noauto $FEATURES ; then
+               # The bashrcs get an opportunity here to set aliases that will be expanded
+               # during sourcing of ebuilds and eclasses.
+               source_all_bashrcs
+
+               # *DEPEND and IUSE will be set during the sourcing of the ebuild.
+               # In order to ensure correct interaction between ebuilds and
+               # eclasses, they need to be unset before this process of
+               # interaction begins.
+               unset DEPEND RDEPEND PDEPEND IUSE
+               source "${EBUILD}" || die "error sourcing ebuild"
+
+               if [[ "${EBUILD_PHASE}" != "depend" ]] ; then
+                       RESTRICT=${PORTAGE_RESTRICT}
+                       [[ -e $PORTAGE_BUILDDIR/.ebuild_changed ]] && \
                        rm "$PORTAGE_BUILDDIR/.ebuild_changed"
-       fi
+               fi
 
-       [[ -n $EAPI ]] || EAPI=0
+               [[ -n $EAPI ]] || EAPI=0
 
-       if has "$EAPI" 0 1 2 ; then
-               export RDEPEND=${RDEPEND-${DEPEND}}
-               debug-print "RDEPEND: not set... Setting to: ${DEPEND}"
-       fi
+               if has "$EAPI" 0 1 2 ; then
+                       export RDEPEND=${RDEPEND-${DEPEND}}
+                       debug-print "RDEPEND: not set... Setting to: ${DEPEND}"
+               fi
 
-       # add in dependency info from eclasses
-       IUSE="${IUSE} ${E_IUSE}"
-       DEPEND="${DEPEND} ${E_DEPEND}"
-       RDEPEND="${RDEPEND} ${E_RDEPEND}"
-       PDEPEND="${PDEPEND} ${E_PDEPEND}"
+               # add in dependency info from eclasses
+               IUSE="${IUSE} ${E_IUSE}"
+               DEPEND="${DEPEND} ${E_DEPEND}"
+               RDEPEND="${RDEPEND} ${E_RDEPEND}"
+               PDEPEND="${PDEPEND} ${E_PDEPEND}"
 
-       unset ECLASS E_IUSE E_DEPEND E_RDEPEND E_PDEPEND
+               unset ECLASS E_IUSE E_DEPEND E_RDEPEND E_PDEPEND
 
-       # alphabetically ordered by $EBUILD_PHASE value
-       local f valid_phases
-       case "$EAPI" in
-               0|1)
-                       valid_phases="src_compile pkg_config pkg_info src_install
-                               pkg_nofetch pkg_postinst pkg_postrm pkg_preinst pkg_prerm
-                               pkg_setup src_test src_unpack"
-                       ;;
-               2)
-                       valid_phases="src_compile pkg_config src_configure pkg_info
-                               src_install pkg_nofetch pkg_postinst pkg_postrm pkg_preinst
-                               src_prepare pkg_prerm pkg_setup src_test src_unpack"
-                       ;;
-               *)
-                       valid_phases="src_compile pkg_config src_configure pkg_info
-                               src_install pkg_nofetch pkg_postinst pkg_postrm pkg_preinst
-                               src_prepare pkg_prerm pkg_pretend pkg_setup src_test src_unpack"
-                       ;;
-       esac
+               # alphabetically ordered by $EBUILD_PHASE value
+               case "$EAPI" in
+                       0|1)
+                               _valid_phases="src_compile pkg_config pkg_info src_install
+                                       pkg_nofetch pkg_postinst pkg_postrm pkg_preinst pkg_prerm
+                                       pkg_setup src_test src_unpack"
+                               ;;
+                       2)
+                               _valid_phases="src_compile pkg_config src_configure pkg_info
+                                       src_install pkg_nofetch pkg_postinst pkg_postrm pkg_preinst
+                                       src_prepare pkg_prerm pkg_setup src_test src_unpack"
+                               ;;
+                       *)
+                               _valid_phases="src_compile pkg_config src_configure pkg_info
+                                       src_install pkg_nofetch pkg_postinst pkg_postrm pkg_preinst
+                                       src_prepare pkg_prerm pkg_pretend pkg_setup src_test src_unpack"
+                               ;;
+               esac
 
-       DEFINED_PHASES=
-       for f in $valid_phases ; do
-               if declare -F $f >/dev/null ; then
-                       f=${f#pkg_}
-                       DEFINED_PHASES+=" ${f#src_}"
-               fi
-       done
-       [[ -n $DEFINED_PHASES ]] || DEFINED_PHASES=-
+               DEFINED_PHASES=
+               for _f in $_valid_phases ; do
+                       if declare -F $_f >/dev/null ; then
+                               f=${f#pkg_}
+                               DEFINED_PHASES+=" ${f#src_}"
+                       fi
+               done
+               [[ -n $DEFINED_PHASES ]] || DEFINED_PHASES=-
 
-       # This needs to be exported since prepstrip is a separate shell script.
-       [[ -n $QA_PRESTRIPPED ]] && export QA_PRESTRIPPED
-       eval "[[ -n \$QA_PRESTRIPPED_${ARCH/-/_} ]] && export QA_PRESTRIPPED_${ARCH/-/_}"
-}
+               unset _f _valid_phases
 
-if ! hasq "$EBUILD_PHASE" clean cleanrm ; then
-       if [[ $EBUILD_PHASE = depend || ! -f $T/environment || \
-               -f $PORTAGE_BUILDDIR/.ebuild_changed ]] || \
-               hasq noauto $FEATURES ; then
-               _source_ebuild
+               # This needs to be exported since prepstrip is a separate shell script.
+               [[ -n $QA_PRESTRIPPED ]] && export QA_PRESTRIPPED
+               eval "[[ -n \$QA_PRESTRIPPED_${ARCH/-/_} ]] && export QA_PRESTRIPPED_${ARCH/-/_}"
        fi
 fi
 
index a3e7e3e56144b9b2a05b696efd79a43ae844548d..64f84b06413cc5b7a49dbba62aee5a898d25c8cb 100755 (executable)
@@ -573,8 +573,8 @@ save_ebuild_env() {
                # user config variables
                unset DOC_SYMLINKS_DIR INSTALL_MASK PKG_INSTALL_MASK
 
-               set
-               export
+               declare -p
+               declare -fp
        )
 }