commit:     cbe6f8cac95f5db7b35018a01c56dc3d9c76bb21
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Mon Aug 20 21:54:14 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Mon Aug 20 22:13:59 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=cbe6f8ca

config: regenerate USE for conditional RESTRICT (bug 664104)

When the features USE state changes due to package.env settings,
regenerate USE for correct evaluation of conditional RESTRICT.

Fixes: 45986341a80c ("Support !test? conditionals in RESTRICT (bug 663278)")
Bug: https://bugs.gentoo.org/664104

 lib/portage/package/ebuild/config.py | 39 ++++++++++++++++++------------------
 1 file changed, 20 insertions(+), 19 deletions(-)

diff --git a/lib/portage/package/ebuild/config.py 
b/lib/portage/package/ebuild/config.py
index 9fbf7e8fc..a68df5807 100644
--- a/lib/portage/package/ebuild/config.py
+++ b/lib/portage/package/ebuild/config.py
@@ -1666,8 +1666,22 @@ class config(object):
                        has_changed = True
 
                if has_changed:
+                       # This can modify self.features due to package.env 
settings.
                        self.reset(keeping_pkg=1)
 
+               if "test" in self.features:
+                       # This is independent of IUSE and RESTRICT, so that the 
same
+                       # value can be shared between packages with different 
settings,
+                       # which is important when evaluating USE conditional 
RESTRICT.
+                       feature_use.append("test")
+
+               feature_use = " ".join(feature_use)
+               if feature_use != self.configdict["features"]["USE"]:
+                       # Regenerate USE for evaluation of conditional RESTRICT.
+                       self.configdict["features"]["USE"] = feature_use
+                       self.reset(keeping_pkg=1)
+                       has_changed = True
+
                if explicit_iuse is None:
                        explicit_iuse = frozenset(x.lstrip("+-") for x in 
iuse.split())
                if eapi_attrs.iuse_effective:
@@ -1696,25 +1710,12 @@ class config(object):
                        else:
                                restrict_test = "test" in restrict
 
-               pkginternaluse_before = pkginternaluse
-               if "test" in self.features:
-                       # This is independent of IUSE and RESTRICT, so that the 
same
-                       # value can be shared between packages with different 
settings,
-                       # which is important when evaluating USE conditional 
RESTRICT
-                       # above.
-                       feature_use.append("test")
-
-                       if restrict_test:
-                               # Handle it like IUSE="-test", since features 
USE is
-                               # independent of RESTRICT.
-                               pkginternaluse_list.append("-test")
-                               pkginternaluse = " ".join(pkginternaluse_list)
-                               self.configdict["pkginternal"]["USE"] = 
pkginternaluse
-
-               feature_use = " ".join(feature_use)
-               if (feature_use != self.configdict["features"].get("USE", "") or
-                       pkginternaluse is not pkginternaluse_before):
-                       self.configdict["features"]["USE"] = feature_use
+               if restrict_test and "test" in self.features:
+                       # Handle it like IUSE="-test", since features USE is
+                       # independent of RESTRICT.
+                       pkginternaluse_list.append("-test")
+                       pkginternaluse = " ".join(pkginternaluse_list)
+                       self.configdict["pkginternal"]["USE"] = pkginternaluse
                        # TODO: can we avoid that?
                        self.reset(keeping_pkg=1)
                        has_changed = True

Reply via email to