Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r13569 - main/trunk/pym/portage
Date: Thu, 30 Apr 2009 21:02:43
Message-Id: E1LzdOy-0005fC-WD@stork.gentoo.org
1 Author: zmedico
2 Date: 2009-04-30 21:02:40 +0000 (Thu, 30 Apr 2009)
3 New Revision: 13569
4
5 Modified:
6 main/trunk/pym/portage/__init__.py
7 Log:
8 Move PORTAGE_RESTRICT calculation to config.setcpv() (lazy evaluation) and
9 fix it to work correctly for pre-built packages.
10
11
12 Modified: main/trunk/pym/portage/__init__.py
13 ===================================================================
14 --- main/trunk/pym/portage/__init__.py 2009-04-30 19:48:31 UTC (rev 13568)
15 +++ main/trunk/pym/portage/__init__.py 2009-04-30 21:02:40 UTC (rev 13569)
16 @@ -2073,29 +2073,43 @@
17 DeprecationWarning)
18 return 1
19
20 - class _lazy_accept_license(object):
21 - """
22 - Generate a pruned version of ACCEPT_LICENSE, by intersection with
23 - LICENSE. This is required since otherwise ACCEPT_LICENSE might be too
24 - big (bigger than ARG_MAX), causing execve() calls to fail with E2BIG
25 - errors as in bug #262647.
26 - """
27 - __slots__ = ('built_use', 'settings',)
28 + class _lazy_vars(object):
29
30 + __slots__ = ('built_use', 'settings', 'values')
31 +
32 def __init__(self, built_use, settings):
33 self.built_use = built_use
34 self.settings = settings
35 + self.values = None
36
37 - def __call__(self):
38 + def __getitem__(self, k):
39 + if self.values is None:
40 + self.values = self._init_values()
41 + return self.values[k]
42 +
43 + def _init_values(self):
44 + values = {}
45 settings = self.settings
46 use = self.built_use
47 if use is None:
48 use = settings['PORTAGE_USE']
49 + use = set(use.split())
50 + values['ACCEPT_LICENSE'] = self._accept_license(use, settings)
51 + values['PORTAGE_RESTRICT'] = self._restrict(use, settings)
52 + return values
53 +
54 + def _accept_license(self, use, settings):
55 + """
56 + Generate a pruned version of ACCEPT_LICENSE, by intersection with
57 + LICENSE. This is required since otherwise ACCEPT_LICENSE might be
58 + too big (bigger than ARG_MAX), causing execve() calls to fail with
59 + E2BIG errors as in bug #262647.
60 + """
61 try:
62 licenses = set(flatten(
63 dep.use_reduce(dep.paren_reduce(
64 settings['LICENSE']),
65 - uselist=use.split())))
66 + uselist=use)))
67 except exception.InvalidDependString:
68 licenses = set()
69 licenses.discard('||')
70 @@ -2103,6 +2117,16 @@
71 licenses.intersection_update(settings._accept_license)
72 return ' '.join(sorted(licenses))
73
74 + def _restrict(self, use, settings):
75 + try:
76 + restrict = set(flatten(
77 + dep.use_reduce(dep.paren_reduce(
78 + settings['RESTRICT']),
79 + uselist=use)))
80 + except exception.InvalidDependString:
81 + restrict = set()
82 + return ' '.join(sorted(restrict))
83 +
84 class _lazy_use_expand(object):
85 """
86 Lazily evaluate USE_EXPAND variables since they are only needed when
87 @@ -2325,8 +2349,11 @@
88 if k != 'USE':
89 env_configdict.pop(k, None)
90
91 + lazy_vars = self._lazy_vars(built_use, self)
92 env_configdict.addLazySingleton('ACCEPT_LICENSE',
93 - self._lazy_accept_license(built_use, self))
94 + lazy_vars.__getitem__, 'ACCEPT_LICENSE')
95 + env_configdict.addLazySingleton('PORTAGE_RESTRICT',
96 + lazy_vars.__getitem__, 'PORTAGE_RESTRICT')
97
98 # If reset() has not been called, it's safe to return
99 # early if IUSE has not changed.
100 @@ -5341,14 +5368,6 @@
101 if not eapi_is_supported(eapi):
102 # can't do anything with this.
103 raise portage.exception.UnsupportedAPIException(mycpv, eapi)
104 - try:
105 - mysettings["PORTAGE_RESTRICT"] = " ".join(flatten(
106 - portage.dep.use_reduce(portage.dep.paren_reduce(
107 - mysettings["RESTRICT"]),
108 - uselist=mysettings["PORTAGE_USE"].split())))
109 - except portage.exception.InvalidDependString:
110 - # RESTRICT is validated again inside doebuild, so let this go
111 - mysettings["PORTAGE_RESTRICT"] = ""
112
113 if mysplit[2] == "r0":
114 mysettings["PVR"]=mysplit[1]