public inbox for gentoo-commits@lists.gentoo.org
 help / color / mirror / Atom feed
From: "Arfrever Frehtes Taifersar Arahesis" <arfrever@gentoo.org>
To: gentoo-commits@lists.gentoo.org
Subject: [gentoo-commits] proj/portage:master commit in: man/, bin/
Date: Sun,  1 May 2011 01:23:59 +0000 (UTC)	[thread overview]
Message-ID: <81354e43b5acf25cadc42f6c093d52acf8f832fb.arfrever@gentoo> (raw)

commit:     81354e43b5acf25cadc42f6c093d52acf8f832fb
Author:     Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Gentoo <DOT> Org>
AuthorDate: Sun May  1 01:21:57 2011 +0000
Commit:     Arfrever Frehtes Taifersar Arahesis <arfrever <AT> gentoo <DOT> org>
CommitDate: Sun May  1 01:21:57 2011 +0000
URL:        http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=81354e43

Bug #365439: Add set_unless_changed() and unset_unless_changed().

---
 bin/ebuild.sh             |   28 ++++++++++++++++++++++++++++
 bin/isolated-functions.sh |    4 ++--
 man/portage.5             |   20 +++++++++++++++++---
 3 files changed, 47 insertions(+), 5 deletions(-)

diff --git a/bin/ebuild.sh b/bin/ebuild.sh
index c79d4c3..e652cb5 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 2f144a0..24443ac 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}

diff --git a/man/portage.5 b/man/portage.5
index fc51481..a210e8d 100644
--- a/man/portage.5
+++ b/man/portage.5
@@ -1,4 +1,4 @@
-.TH "PORTAGE" "5" "Feb 2011" "Portage VERSION" "Portage"
+.TH "PORTAGE" "5" "May 2011" "Portage VERSION" "Portage"
 .SH NAME
 portage \- the heart of Gentoo
 .SH "DESCRIPTION"
@@ -674,8 +674,22 @@ In this directory additional package\-specific bashrc files can be created.
 Note that if package\-specific environment variable settings are all that's
 needed, then \fB/etc/portage/package.env\fR should be used instead of the
 bashrc approach that is described here.
-Portage will source all of them after \fB/etc/portage/bashrc\fR in the following
-order:
+
+set_unless_changed and unset_unless_changed functions can be used to set or
+unset given variables only if these variable have not been set to values
+different than values set in make.conf. This functionality can be useful for
+temporary overriding of these variables during emerge invocation. Variables
+set in the usual VARIABLE=VALUE style will unconditionally override variables
+set during emerge invocation.
+
+.I Syntax:
+.nf
+set_unless_changed VARIABLE VALUE
+unset_unless_changed VALUE
+.fi
+
+Portage will source all of these bashrc files after \fB/etc/portage/bashrc\fR
+in the following order:
 .nr step 1 1
 .IP \n[step]. 3
 /etc/portage/env/${CATEGORY}/${PN}



             reply	other threads:[~2011-05-01  1:24 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-05-01  1:23 Arfrever Frehtes Taifersar Arahesis [this message]
  -- strict thread matches above, loose matches on Subject: below --
2011-05-01 14:52 [gentoo-commits] proj/portage:master commit in: man/, bin/ Arfrever Frehtes Taifersar Arahesis
2011-05-01 15:58 Zac Medico
2011-06-24 10:23 Zac Medico
2011-08-11  3:00 Zac Medico
2011-08-13 13:52 Zac Medico
2011-08-31  3:05 Zac Medico
2011-10-14 18:06 Zac Medico
2011-10-17  4:22 Zac Medico
2011-12-21 20:04 Zac Medico
2011-12-21 20:08 Zac Medico
2011-12-22 23:43 Zac Medico
2012-01-02  7:48 Zac Medico
2012-03-11  2:44 Mike Frysinger
2012-03-11  2:56 Mike Frysinger
2012-03-17 21:33 Zac Medico
2012-06-17 15:46 Zac Medico
2012-09-24  3:47 Mike Frysinger
2012-09-24 20:26 Zac Medico
2012-10-11  3:10 Zac Medico
2012-10-31 21:32 Zac Medico
2013-04-28 22:06 Zac Medico
2013-05-18 18:47 Zac Medico
2013-07-13  9:35 Arfrever Frehtes Taifersar Arahesis
2013-07-23 20:42 Arfrever Frehtes Taifersar Arahesis
2013-08-04 20:51 Zac Medico
2013-08-22  2:01 Zac Medico
2013-08-22  4:06 Zac Medico
2019-08-30 17:05 Zac Medico

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=81354e43b5acf25cadc42f6c093d52acf8f832fb.arfrever@gentoo \
    --to=arfrever@gentoo.org \
    --cc=gentoo-commits@lists.gentoo.org \
    --cc=gentoo-dev@lists.gentoo.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox