commit:     784d2c19f2d62982db16af9055bdab6b595a661b
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Fri Feb 19 05:51:43 2021 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Feb 22 05:26:53 2021 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=784d2c19

make.defaults: prevent USE="${USE} ..." misbehavior

Discard parent profile USE from the expand_map variable before
it is used to evaluate a child profile. This prevents accidents
triggered by USE="${USE} ..." settings at the top of make.defaults
which caused parent profile USE to override parent profile
package.use settings.

Note that would be nice to guard the USE_EXPAND variables like
this too, but unfortunately USE_EXPAND is not known until after
make.defaults has been evaluated, so that will require some form
of make.defaults preprocessing.

Bug: https://bugs.gentoo.org/771549
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/package/ebuild/config.py | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/lib/portage/package/ebuild/config.py 
b/lib/portage/package/ebuild/config.py
index e5ec681af..690efde9d 100644
--- a/lib/portage/package/ebuild/config.py
+++ b/lib/portage/package/ebuild/config.py
@@ -612,9 +612,20 @@ class config:
 
                        mygcfg = {}
                        if profiles_complex:
-                               mygcfg_dlists = 
[getconfig(os.path.join(x.location, "make.defaults"),
-                                       tolerant=tolerant, expand=expand_map, 
recursive=x.portage1_directories)
-                                       for x in profiles_complex]
+                               mygcfg_dlists = []
+                               for x in profiles_complex:
+                                       # Prevent accidents triggered by 
USE="${USE} ..." settings
+                                       # at the top of make.defaults which 
caused parent profile
+                                       # USE to override parent profile 
package.use settings.
+                                       # It would be nice to guard USE_EXPAND 
variables like
+                                       # this too, but unfortunately 
USE_EXPAND is not known
+                                       # until after make.defaults has been 
evaluated, so that
+                                       # will require some form of 
make.defaults preprocessing.
+                                       expand_map.pop("USE", None)
+                                       mygcfg_dlists.append(
+                                               
getconfig(os.path.join(x.location, "make.defaults"),
+                                               tolerant=tolerant, 
expand=expand_map,
+                                               
recursive=x.portage1_directories))
                                self._make_defaults = mygcfg_dlists
                                mygcfg = stack_dicts(mygcfg_dlists,
                                        incrementals=self.incrementals)

Reply via email to