diff options
author | Arfrever Frehtes Taifersar Arahesis <Arfrever@Gentoo.Org> | 2011-05-01 03:21:57 +0200 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2011-05-04 12:48:36 -0700 |
commit | eb6da843dc0ef3fcf869645dbbe479b6bb010d75 (patch) | |
tree | 93a7f1d338dce0427ff98cd3213a30cc26cb24df /bin | |
parent | 8ec7366c3099fdbfd8619704ad219239466e963e (diff) | |
download | portage-eb6da843dc0ef3fcf869645dbbe479b6bb010d75.tar.gz portage-eb6da843dc0ef3fcf869645dbbe479b6bb010d75.tar.bz2 portage-eb6da843dc0ef3fcf869645dbbe479b6bb010d75.zip |
Bug #365439: Add set_unless_changed() and unset_unless_changed().
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/ebuild.sh | 28 | ||||
-rw-r--r-- | bin/isolated-functions.sh | 4 |
2 files changed, 30 insertions, 2 deletions
diff --git a/bin/ebuild.sh b/bin/ebuild.sh index c79d4c3d0..e652cb55b 100755 --- a/bin/ebuild.sh +++ b/bin/ebuild.sh @@ -1639,6 +1639,34 @@ _ebuild_phase_funcs() { esac } +# Set given variable unless this variable has been already set (e.g. during emerge +# invocation) to a value different than value set in make.conf. +set_unless_changed() { + if [[ $# -ne 2 ]]; then + die "${FUNCNAME}() requires 2 arguments: VARIABLE VALUE" + fi + + local variable="$1" value="$2" + + if eval "[[ \${${variable}} == \$(env -u ${variable} portageq envvar ${variable}) ]]"; then + eval "${variable}=\"${value}\"" + fi +} + +# Unset given variable unless this variable has been set (e.g. during emerge +# invocation) to a value different than value set in make.conf. +unset_unless_changed() { + if [[ $# -ne 1 ]]; then + die "${FUNCNAME}() requires 1 argument: VARIABLE" + fi + + local variable="$1" + + if eval "[[ \${${variable}} == \$(env -u ${variable} portageq envvar ${variable}) ]]"; then + unset ${variable} + fi +} + PORTAGE_BASHRCS_SOURCED=0 # @FUNCTION: source_all_bashrcs diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh index 2f144a084..24443ac1b 100644 --- a/bin/isolated-functions.sh +++ b/bin/isolated-functions.sh @@ -585,8 +585,8 @@ save_ebuild_env() { dyn_preinst dyn_help debug-print debug-print-function \ debug-print-section inherit EXPORT_FUNCTIONS remove_path_entry \ save_ebuild_env filter_readonly_variables preprocess_ebuild_env \ - source_all_bashrcs ebuild_main \ - ebuild_phase ebuild_phase_with_hooks \ + set_unless_changed unset_unless_changed source_all_bashrcs \ + ebuild_main ebuild_phase ebuild_phase_with_hooks \ _ebuild_arg_to_phase _ebuild_phase_funcs default \ _pipestatus \ ${QA_INTERCEPTORS} |