summaryrefslogtreecommitdiffstats
path: root/bin/ebuild.sh
diff options
context:
space:
mode:
authorArfrever Frehtes Taifersar Arahesis <Arfrever@Gentoo.Org>2011-05-01 03:21:57 +0200
committerArfrever Frehtes Taifersar Arahesis <Arfrever@Gentoo.Org>2011-05-01 03:21:57 +0200
commit81354e43b5acf25cadc42f6c093d52acf8f832fb (patch)
tree757d1bf204efd80030ee88fa477bbeb0f2dfe70f /bin/ebuild.sh
parentd6080afba243844083838b5779afbe0ebbb81626 (diff)
downloadportage-81354e43b5acf25cadc42f6c093d52acf8f832fb.tar.gz
portage-81354e43b5acf25cadc42f6c093d52acf8f832fb.tar.bz2
portage-81354e43b5acf25cadc42f6c093d52acf8f832fb.zip
Bug #365439: Add set_unless_changed() and unset_unless_changed().
Diffstat (limited to 'bin/ebuild.sh')
-rwxr-xr-xbin/ebuild.sh28
1 files changed, 28 insertions, 0 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