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__ = ('built_use', 'settings',)
+ class _lazy_vars(object):
+
+ __slots__ = ('built_use', 'settings', 'values')
def __init__(self, built_use, settings):
self.built_use = built_use
self.settings = settings
+ self.values = None
- def __call__(self):
+ def __getitem__(self, k):
+ if self.values is None:
+ self.values = self._init_values()
+ return self.values[k]
+
+ def _init_values(self):
+ values = {}
settings = self.settings
use = self.built_use
if use is None:
use = settings['PORTAGE_USE']
+ use = set(use.split())
+ values['ACCEPT_LICENSE'] = self._accept_license(use, settings)
+ values['PORTAGE_RESTRICT'] = self._restrict(use, settings)
+ return values
+
+ def _accept_license(self, use, settings):
+ """
+ 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.
+ """
try:
licenses = set(flatten(
dep.use_reduce(dep.paren_reduce(
settings['LICENSE']),
- uselist=use.split())))
+ uselist=use)))
except exception.InvalidDependString:
licenses = set()
licenses.discard('||')
licenses.intersection_update(settings._accept_license)
return ' '.join(sorted(licenses))
+ def _restrict(self, use, settings):
+ try:
+ restrict = set(flatten(
+ dep.use_reduce(dep.paren_reduce(
+ settings['RESTRICT']),
+ uselist=use)))
+ except exception.InvalidDependString:
+ restrict = set()
+ return ' '.join(sorted(restrict))
+
class _lazy_use_expand(object):
"""
Lazily evaluate USE_EXPAND variables since they are only needed when
if k != 'USE':
env_configdict.pop(k, None)
+ lazy_vars = self._lazy_vars(built_use, self)
env_configdict.addLazySingleton('ACCEPT_LICENSE',
- self._lazy_accept_license(built_use, self))
+ lazy_vars.__getitem__, 'ACCEPT_LICENSE')
+ env_configdict.addLazySingleton('PORTAGE_RESTRICT',
+ lazy_vars.__getitem__, 'PORTAGE_RESTRICT')
# If reset() has not been called, it's safe to return
# early if IUSE has not changed.
if not eapi_is_supported(eapi):
# can't do anything with this.
raise portage.exception.UnsupportedAPIException(mycpv, eapi)
- try:
- mysettings["PORTAGE_RESTRICT"] = " ".join(flatten(
- portage.dep.use_reduce(portage.dep.paren_reduce(
- mysettings["RESTRICT"]),
- uselist=mysettings["PORTAGE_USE"].split())))
- except portage.exception.InvalidDependString:
- # RESTRICT is validated again inside doebuild, so let this go
- mysettings["PORTAGE_RESTRICT"] = ""
if mysplit[2] == "r0":
mysettings["PVR"]=mysplit[1]