Gentoo Archives: gentoo-commits

From: Arfrever Frehtes Taifersar Arahesis <arfrever@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] proj/portage:master commit in: man/, bin/
Date: Sun, 01 May 2011 01:24:10
Message-Id: 81354e43b5acf25cadc42f6c093d52acf8f832fb.arfrever@gentoo
1 commit: 81354e43b5acf25cadc42f6c093d52acf8f832fb
2 Author: Arfrever Frehtes Taifersar Arahesis <Arfrever <AT> Gentoo <DOT> Org>
3 AuthorDate: Sun May 1 01:21:57 2011 +0000
4 Commit: Arfrever Frehtes Taifersar Arahesis <arfrever <AT> gentoo <DOT> org>
5 CommitDate: Sun May 1 01:21:57 2011 +0000
6 URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=81354e43
7
8 Bug #365439: Add set_unless_changed() and unset_unless_changed().
9
10 ---
11 bin/ebuild.sh | 28 ++++++++++++++++++++++++++++
12 bin/isolated-functions.sh | 4 ++--
13 man/portage.5 | 20 +++++++++++++++++---
14 3 files changed, 47 insertions(+), 5 deletions(-)
15
16 diff --git a/bin/ebuild.sh b/bin/ebuild.sh
17 index c79d4c3..e652cb5 100755
18 --- a/bin/ebuild.sh
19 +++ b/bin/ebuild.sh
20 @@ -1639,6 +1639,34 @@ _ebuild_phase_funcs() {
21 esac
22 }
23
24 +# Set given variable unless this variable has been already set (e.g. during emerge
25 +# invocation) to a value different than value set in make.conf.
26 +set_unless_changed() {
27 + if [[ $# -ne 2 ]]; then
28 + die "${FUNCNAME}() requires 2 arguments: VARIABLE VALUE"
29 + fi
30 +
31 + local variable="$1" value="$2"
32 +
33 + if eval "[[ \${${variable}} == \$(env -u ${variable} portageq envvar ${variable}) ]]"; then
34 + eval "${variable}=\"${value}\""
35 + fi
36 +}
37 +
38 +# Unset given variable unless this variable has been set (e.g. during emerge
39 +# invocation) to a value different than value set in make.conf.
40 +unset_unless_changed() {
41 + if [[ $# -ne 1 ]]; then
42 + die "${FUNCNAME}() requires 1 argument: VARIABLE"
43 + fi
44 +
45 + local variable="$1"
46 +
47 + if eval "[[ \${${variable}} == \$(env -u ${variable} portageq envvar ${variable}) ]]"; then
48 + unset ${variable}
49 + fi
50 +}
51 +
52 PORTAGE_BASHRCS_SOURCED=0
53
54 # @FUNCTION: source_all_bashrcs
55
56 diff --git a/bin/isolated-functions.sh b/bin/isolated-functions.sh
57 index 2f144a0..24443ac 100644
58 --- a/bin/isolated-functions.sh
59 +++ b/bin/isolated-functions.sh
60 @@ -585,8 +585,8 @@ save_ebuild_env() {
61 dyn_preinst dyn_help debug-print debug-print-function \
62 debug-print-section inherit EXPORT_FUNCTIONS remove_path_entry \
63 save_ebuild_env filter_readonly_variables preprocess_ebuild_env \
64 - source_all_bashrcs ebuild_main \
65 - ebuild_phase ebuild_phase_with_hooks \
66 + set_unless_changed unset_unless_changed source_all_bashrcs \
67 + ebuild_main ebuild_phase ebuild_phase_with_hooks \
68 _ebuild_arg_to_phase _ebuild_phase_funcs default \
69 _pipestatus \
70 ${QA_INTERCEPTORS}
71
72 diff --git a/man/portage.5 b/man/portage.5
73 index fc51481..a210e8d 100644
74 --- a/man/portage.5
75 +++ b/man/portage.5
76 @@ -1,4 +1,4 @@
77 -.TH "PORTAGE" "5" "Feb 2011" "Portage VERSION" "Portage"
78 +.TH "PORTAGE" "5" "May 2011" "Portage VERSION" "Portage"
79 .SH NAME
80 portage \- the heart of Gentoo
81 .SH "DESCRIPTION"
82 @@ -674,8 +674,22 @@ In this directory additional package\-specific bashrc files can be created.
83 Note that if package\-specific environment variable settings are all that's
84 needed, then \fB/etc/portage/package.env\fR should be used instead of the
85 bashrc approach that is described here.
86 -Portage will source all of them after \fB/etc/portage/bashrc\fR in the following
87 -order:
88 +
89 +set_unless_changed and unset_unless_changed functions can be used to set or
90 +unset given variables only if these variable have not been set to values
91 +different than values set in make.conf. This functionality can be useful for
92 +temporary overriding of these variables during emerge invocation. Variables
93 +set in the usual VARIABLE=VALUE style will unconditionally override variables
94 +set during emerge invocation.
95 +
96 +.I Syntax:
97 +.nf
98 +set_unless_changed VARIABLE VALUE
99 +unset_unless_changed VALUE
100 +.fi
101 +
102 +Portage will source all of these bashrc files after \fB/etc/portage/bashrc\fR
103 +in the following order:
104 .nr step 1 1
105 .IP \n[step]. 3
106 /etc/portage/env/${CATEGORY}/${PN}