Generate a pruned version of ACCEPT_LICENSE, by intersection with
authorZac Medico <zmedico@gentoo.org>
Thu, 30 Apr 2009 05:21:22 +0000 (05:21 -0000)
committerZac Medico <zmedico@gentoo.org>
Thu, 30 Apr 2009 05:21:22 +0000 (05:21 -0000)
LICENSE. This is required since otherwise ACCEPT_LICENSE might be too
big (bigger than ARG_MAX), causing execve() calls to fail with E2BIG
errors as in bug #262647.

svn path=/main/trunk/; revision=13417

pym/portage/__init__.py

index 7e7ff8139161bc3c007518cef419be48cb05b688..43a3dfad8f14a6cac33a84b210039c5f326e463c 100644 (file)
@@ -2073,6 +2073,31 @@ class config(object):
                        DeprecationWarning)
                return 1
 
+       class _lazy_accept_license(object):
+               """
+               Generate a pruned version of ACCEPT_LICENSE, by intersection with
+               LICENSE. This is required since otherwise ACCEPT_LICENSE might be too
+               big (bigger than ARG_MAX), causing execve() calls to fail with E2BIG
+               errors as in bug #262647.
+               """
+               __slots__ = ('settings',)
+
+               def __init__(self, settings):
+                       self.settings = settings
+
+               def __call__(self):
+                       settings = self.settings
+                       try:
+                               licenses = set(flatten(
+                                       dep.use_reduce(dep.paren_reduce(
+                                       settings['LICENSE']),
+                                       uselist=settings['PORTAGE_USE'].split())))
+                       except exception.InvalidDependString:
+                               licenses = set()
+                       if '*' not in settings._accept_license:
+                               licenses.intersection_update(settings._accept_license)
+                       return ' '.join(sorted(licenses))
+
        class _lazy_use_expand(object):
                """
                Lazily evaluate USE_EXPAND variables since they are only needed when
@@ -2288,6 +2313,9 @@ class config(object):
                if has_changed:
                        self.reset(keeping_pkg=1,use_cache=use_cache)
 
+               env_configdict.addLazySingleton('ACCEPT_LICENSE',
+                       self._lazy_accept_license(self))
+
                # If reset() has not been called, it's safe to return
                # early if IUSE has not changed.
                if not has_changed and previous_iuse == iuse: