commit:     17cb113abf2b155b7b1f2955f7eed54f335badb0
Author:     Zac Medico <zmedico <AT> gentoo <DOT> org>
AuthorDate: Sun Dec 30 00:21:17 2018 +0000
Commit:     Zac Medico <zmedico <AT> gentoo <DOT> org>
CommitDate: Sun Dec 30 00:59:46 2018 +0000
URL:        https://gitweb.gentoo.org/proj/portage.git/commit/?id=17cb113a

ResolverPlayground: exclude internal wrappers from essential_binaries PATH

Ensure that essential_binaries symlinks do not refer to internal
wrapper scripts, in order to avoid infinite recursion. Use the
same ebuild-helpers pattern as the portageq wrapper script since
daeb75b345c4433218ab9e7a5319e8914092f048.

Fixes: 1b5edbb5ec70 ("_doebuild_path: do not use host PATH by default and 
prepend EPREFIX PATH")
Signed-off-by: Zac Medico <zmedico <AT> gentoo.org>

 lib/portage/tests/resolver/ResolverPlayground.py | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/lib/portage/tests/resolver/ResolverPlayground.py 
b/lib/portage/tests/resolver/ResolverPlayground.py
index 3997ad26e..626a1f064 100644
--- a/lib/portage/tests/resolver/ResolverPlayground.py
+++ b/lib/portage/tests/resolver/ResolverPlayground.py
@@ -108,8 +108,21 @@ class ResolverPlayground(object):
                                "uniq",
                                "xargs",
                        )
-                       for x in essential_binaries:
-                               os.symlink(find_binary(x), os.path.join(eubin, 
x))
+                       # Exclude internal wrappers from PATH lookup.
+                       orig_path = os.environ['PATH']
+                       included_paths = []
+                       for path in orig_path.split(':'):
+                               if path and not fnmatch.fnmatch(path, 
'*/portage/*/ebuild-helpers*'):
+                                       included_paths.append(path)
+                       try:
+                               os.environ['PATH'] = ':'.join(included_paths)
+                               for x in essential_binaries:
+                                       path = find_binary(x)
+                                       if path is None:
+                                               raise 
portage.exception.CommandNotFound(x)
+                                       os.symlink(path, os.path.join(eubin, x))
+                       finally:
+                               os.environ['PATH'] = orig_path
                else:
                        self.eprefix = normalize_path(eprefix)
 

Reply via email to