Merge PATH initialization/filtering changes from trunk r15149. v2.1.7.16
authorZac Medico <zmedico@gentoo.org>
Thu, 24 Dec 2009 05:37:52 +0000 (05:37 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 24 Dec 2009 05:37:52 +0000 (05:37 -0000)
svn path=/main/branches/2.1.7/; revision=15150

bin/ebuild.sh

index 95d4e85cc4c6d1913f482c0cfb7a77041c8060ca..2d51914672e689168328e07d27f1237f7bf019e0 100755 (executable)
@@ -1103,7 +1103,7 @@ dyn_install() {
        unset f
 
        save_ebuild_env --exclude-init-phases | filter_readonly_variables \
-               --filter-sandbox --allow-extra-vars > environment
+               --filter-path --filter-sandbox --allow-extra-vars > environment
 
        bzip2 -f9 environment
 
@@ -1637,6 +1637,11 @@ PORTAGE_MUTABLE_FILTERED_VARS="AA HOSTNAME"
 # settings should be used when loading the environment from a binary or
 # installed package.
 #
+# --filter-path causes the PATH variable to be filtered. This variable
+# should persist between phases, in case it is modified by the ebuild.
+# However, old settings should be overridden when loading the
+# environment from a binary or installed package.
+#
 # ---allow-extra-vars causes some extra vars to be allowd through, such
 # as ${PORTAGE_SAVED_READONLY_VARS} and ${PORTAGE_MUTABLE_FILTERED_VARS}.
 #
@@ -1656,7 +1661,7 @@ filter_readonly_variables() {
                SANDBOX_DEBUG_LOG SANDBOX_DISABLED SANDBOX_LIB
                SANDBOX_LOG SANDBOX_ON"
        filtered_vars="$readonly_bash_vars $bash_misc_vars
-               $READONLY_PORTAGE_VARS PATH"
+               $READONLY_PORTAGE_VARS"
 
        # Don't filter/interfere with prefix variables unless they are
        # supported by the current EAPI.
@@ -1676,6 +1681,9 @@ filter_readonly_variables() {
        if hasq --filter-features $* ; then
                filtered_vars="${filtered_vars} FEATURES"
        fi
+       if hasq --filter-path $* ; then
+               filtered_vars+=" PATH"
+       fi
        if hasq --filter-locale $* ; then
                filtered_vars+=" LANG LC_ALL LC_COLLATE
                        LC_CTYPE LC_MESSAGES LC_MONETARY
@@ -1706,7 +1714,7 @@ preprocess_ebuild_env() {
                # environment may contain stale SANDBOX_{DENY,PREDICT,READ,WRITE}
                # and FEATURES variables that should be filtered out. Between
                # phases, these variables are normally preserved.
-               filter_opts+=" --filter-sandbox --filter-features --filter-locale"
+               filter_opts+=" --filter-features --filter-locale --filter-path --filter-sandbox"
        fi
        filter_readonly_variables ${filter_opts} < "${T}"/environment \
                > "${T}"/environment.filtered || return $?
@@ -1923,6 +1931,25 @@ if ! hasq "$EBUILD_PHASE" clean cleanrm ; then
 
                unset _f _valid_phases
 
+               if [[ $EBUILD_PHASE != depend ]] ; then
+
+                       if hasq distcc $FEATURES ; then
+                               PATH="/usr/lib/distcc/bin:$PATH"
+                               [[ -n $DISTCC_LOG ]] && addwrite "${DISTCC_LOG%/*}"
+                       fi
+
+                       if hasq ccache $FEATURES ; then
+                               PATH="/usr/lib/ccache/bin:$PATH"
+
+                               if [[ -n $CCACHE_DIR ]] ; then
+                                       addread "$CCACHE_DIR"
+                                       addwrite "$CCACHE_DIR"
+                               fi
+
+                               [[ -n $CCACHE_SIZE ]] && ccache -M $CCACHE_SIZE &> /dev/null
+                       fi
+               fi
+
                # 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/-/_}"
@@ -1965,28 +1992,11 @@ fi
 ebuild_main() {
        local f x
 
-       if ! hasq $EBUILD_SH_ARGS clean depend help info nofetch ; then
-
-               if hasq distcc $FEATURES ; then
-                       export PATH="/usr/lib/distcc/bin:$PATH"
-                       [[ -n $DISTCC_LOG ]] && addwrite "${DISTCC_LOG%/*}"
-               fi
-
-               if hasq ccache $FEATURES ; then
-                       export PATH="/usr/lib/ccache/bin:$PATH"
-
-                       addread "$CCACHE_DIR"
-                       addwrite "$CCACHE_DIR"
-
-                       [[ -n $CCACHE_SIZE ]] && ccache -M $CCACHE_SIZE &> /dev/null
-               else
-                       # Force configure scripts that automatically detect ccache to
-                       # respect FEATURES="-ccache".
-                       export CCACHE_DISABLE=1
-               fi
-       fi
-
        if [[ $EBUILD_PHASE != depend ]] ; then
+               # Force configure scripts that automatically detect ccache to
+               # respect FEATURES="-ccache".
+               hasq ccache $FEATURES || export CCACHE_DISABLE=1
+
                local phase_func=$(_ebuild_arg_to_phase "$EAPI" "$EBUILD_PHASE")
                [[ -n $phase_func ]] && _ebuild_phase_funcs "$EAPI" "$phase_func"
                unset phase_func
@@ -2016,7 +2026,8 @@ ebuild_main() {
                        # Update environment.bz2 in case installation phases
                        # need to pass some variables to uninstallation phases.
                        save_ebuild_env --exclude-init-phases | \
-                               filter_readonly_variables --filter-sandbox --allow-extra-vars \
+                               filter_readonly_variables --filter-path \
+                               --filter-sandbox --allow-extra-vars \
                                | bzip2 -c -f9 > "$PORTAGE_UPDATE_ENV"
                fi
                ;;