1 |
Author: grobian |
2 |
Date: 2009-06-28 13:10:08 +0000 (Sun, 28 Jun 2009) |
3 |
New Revision: 13718 |
4 |
|
5 |
Modified: |
6 |
main/branches/prefix/pym/_emerge/EbuildFetchonly.py |
7 |
main/branches/prefix/pym/_emerge/Package.py |
8 |
main/branches/prefix/pym/_emerge/Scheduler.py |
9 |
main/branches/prefix/pym/_emerge/depgraph.py |
10 |
main/branches/prefix/pym/_emerge/visible.py |
11 |
main/branches/prefix/pym/portage/__init__.py |
12 |
main/branches/prefix/pym/portage/dbapi/__init__.py |
13 |
Log: |
14 |
Merged from trunk -r13690:13696 |
15 |
|
16 |
| 13691 | * Add a Package.invalid attribute to store messages about | |
17 |
| zmedico | invalid LICENSE, PROPERTIES, PROVIDE, and RESTRICT metadata. | |
18 |
| | Use it to mask invalid packages when necessary. * Evaluate | |
19 |
| | USE conditional values in Package.metadata when the are | |
20 |
| | accessed. | |
21 |
|
22 |
| 13692 | Add a Package.metadata.properties attribute containing a | |
23 |
| zmedico | list of enabled PROPERTIES values. | |
24 |
|
25 |
| 13693 | Add a Package.metadata.restrict attribute containing a list | |
26 |
| zmedico | of enabled RESTRICT values. | |
27 |
|
28 |
| 13694 | Make config.regenerate() detect api-level updates to | |
29 |
| zmedico | ACCEPT_LICENSE, for use in implementing the "free" filter | |
30 |
| | for the packagekit backend. | |
31 |
|
32 |
| 13695 | Make dbapi.cp_list() raise NotImplementedError. | |
33 |
| zmedico | | |
34 |
|
35 |
| 13696 | Use @property instead of __getattribute__ to implement lazy | |
36 |
| zmedico | Package.iuse.regex initialization. | |
37 |
|
38 |
|
39 |
Modified: main/branches/prefix/pym/_emerge/EbuildFetchonly.py |
40 |
=================================================================== |
41 |
--- main/branches/prefix/pym/_emerge/EbuildFetchonly.py 2009-06-28 08:08:54 UTC (rev 13717) |
42 |
+++ main/branches/prefix/pym/_emerge/EbuildFetchonly.py 2009-06-28 13:10:08 UTC (rev 13718) |
43 |
@@ -24,9 +24,8 @@ |
44 |
ebuild_path = portdb.findname(pkg.cpv) |
45 |
settings.setcpv(pkg) |
46 |
debug = settings.get("PORTAGE_DEBUG") == "1" |
47 |
- restrict_fetch = 'fetch' in settings['PORTAGE_RESTRICT'].split() |
48 |
|
49 |
- if restrict_fetch: |
50 |
+ if 'fetch' in pkg.metadata.restrict: |
51 |
rval = self._execute_with_builddir() |
52 |
else: |
53 |
rval = portage.doebuild(ebuild_path, "fetch", |
54 |
|
55 |
Modified: main/branches/prefix/pym/_emerge/Package.py |
56 |
=================================================================== |
57 |
--- main/branches/prefix/pym/_emerge/Package.py 2009-06-28 08:08:54 UTC (rev 13717) |
58 |
+++ main/branches/prefix/pym/_emerge/Package.py 2009-06-28 13:10:08 UTC (rev 13718) |
59 |
@@ -26,7 +26,7 @@ |
60 |
"installed", "metadata", "onlydeps", "operation", |
61 |
"root_config", "type_name", |
62 |
"category", "counter", "cp", "cpv_split", |
63 |
- "inherited", "iuse", "mtime", |
64 |
+ "inherited", "invalid", "iuse", "mtime", |
65 |
"pf", "pv_split", "root", "slot", "slot_atom",) + \ |
66 |
("_use",) |
67 |
|
68 |
@@ -54,6 +54,11 @@ |
69 |
self.cpv_split = portage.catpkgsplit(self.cpv) |
70 |
self.pv_split = self.cpv_split[1:] |
71 |
|
72 |
+ def _invalid_metadata(self, msg): |
73 |
+ if self.invalid is None: |
74 |
+ self.invalid = [] |
75 |
+ self.invalid.append(msg) |
76 |
+ |
77 |
class _use_class(object): |
78 |
|
79 |
__slots__ = ("__weakref__", "enabled") |
80 |
@@ -69,7 +74,9 @@ |
81 |
|
82 |
class _iuse(object): |
83 |
|
84 |
- __slots__ = ("__weakref__", "all", "enabled", "disabled", "iuse_implicit", "regex", "tokens") |
85 |
+ __slots__ = ("__weakref__", "all", "enabled", "disabled", |
86 |
+ "iuse_implicit", "tokens") + \ |
87 |
+ ('_regex',) |
88 |
|
89 |
def __init__(self, tokens, iuse_implicit): |
90 |
self.tokens = tuple(tokens) |
91 |
@@ -89,20 +96,23 @@ |
92 |
self.disabled = frozenset(disabled) |
93 |
self.all = frozenset(chain(enabled, disabled, other)) |
94 |
|
95 |
- def __getattribute__(self, name): |
96 |
- if name == "regex": |
97 |
- try: |
98 |
- return object.__getattribute__(self, "regex") |
99 |
- except AttributeError: |
100 |
- all = object.__getattribute__(self, "all") |
101 |
- iuse_implicit = object.__getattribute__(self, "iuse_implicit") |
102 |
- # Escape anything except ".*" which is supposed |
103 |
- # to pass through from _get_implicit_iuse() |
104 |
- regex = (re.escape(x) for x in chain(all, iuse_implicit)) |
105 |
- regex = "^(%s)$" % "|".join(regex) |
106 |
- regex = regex.replace("\\.\\*", ".*") |
107 |
- self.regex = re.compile(regex) |
108 |
- return object.__getattribute__(self, name) |
109 |
+ @property |
110 |
+ def regex(self): |
111 |
+ """ |
112 |
+ @returns: A regular expression that matches valid USE values which |
113 |
+ may be specified in USE dependencies. |
114 |
+ """ |
115 |
+ try: |
116 |
+ return self._regex |
117 |
+ except AttributeError: |
118 |
+ # Escape anything except ".*" which is supposed |
119 |
+ # to pass through from _get_implicit_iuse() |
120 |
+ regex = (re.escape(x) for x in \ |
121 |
+ chain(self.all, self.iuse_implicit)) |
122 |
+ regex = "^(%s)$" % "|".join(regex) |
123 |
+ regex = re.compile(regex.replace("\\.\\*", ".*")) |
124 |
+ self._regex = regex |
125 |
+ return regex |
126 |
|
127 |
def _get_hash_key(self): |
128 |
hash_key = getattr(self, "_hash_key", None) |
129 |
@@ -158,6 +168,8 @@ |
130 |
__slots__ = ("_pkg",) |
131 |
_wrapped_keys = frozenset( |
132 |
["COUNTER", "INHERITED", "IUSE", "SLOT", "_mtime_"]) |
133 |
+ _use_conditional_keys = frozenset( |
134 |
+ ['LICENSE', 'PROPERTIES', 'PROVIDE', 'RESTRICT',]) |
135 |
|
136 |
def __init__(self, pkg, metadata): |
137 |
_PackageMetadataWrapperBase.__init__(self) |
138 |
@@ -172,11 +184,17 @@ |
139 |
|
140 |
def __getitem__(self, k): |
141 |
v = _PackageMetadataWrapperBase.__getitem__(self, k) |
142 |
- if k in ('PROVIDE', 'LICENSE',): |
143 |
+ if k in self._use_conditional_keys: |
144 |
if '?' in v: |
145 |
- v = paren_enclose(paren_normalize(use_reduce( |
146 |
- paren_reduce(v), uselist=self._pkg.use.enabled))) |
147 |
- self[k] = v |
148 |
+ try: |
149 |
+ v = paren_enclose(paren_normalize(use_reduce( |
150 |
+ paren_reduce(v), uselist=self._pkg.use.enabled))) |
151 |
+ except portage.exception.InvalidDependString: |
152 |
+ # This error should already have been registered via |
153 |
+ # self._pkg._invalid_metadata(). |
154 |
+ pass |
155 |
+ else: |
156 |
+ self[k] = v |
157 |
|
158 |
elif k == 'USE' and not self._pkg.built: |
159 |
if not v: |
160 |
@@ -193,6 +211,11 @@ |
161 |
_PackageMetadataWrapperBase.__setitem__(self, k, v) |
162 |
if k in self._wrapped_keys: |
163 |
getattr(self, "_set_" + k.lower())(k, v) |
164 |
+ elif k in self._use_conditional_keys: |
165 |
+ try: |
166 |
+ use_reduce(paren_reduce(v), matchall=1) |
167 |
+ except portage.exception.InvalidDependString, e: |
168 |
+ self._pkg._invalid_metadata("%s: %s" % (k, e)) |
169 |
|
170 |
def _set_inherited(self, k, v): |
171 |
if isinstance(v, basestring): |
172 |
@@ -221,3 +244,11 @@ |
173 |
except ValueError: |
174 |
v = 0 |
175 |
self._pkg.mtime = v |
176 |
+ |
177 |
+ @property |
178 |
+ def properties(self): |
179 |
+ return self['PROPERTIES'].split() |
180 |
+ |
181 |
+ @property |
182 |
+ def restrict(self): |
183 |
+ return self['RESTRICT'].split() |
184 |
|
185 |
Modified: main/branches/prefix/pym/_emerge/Scheduler.py |
186 |
=================================================================== |
187 |
--- main/branches/prefix/pym/_emerge/Scheduler.py 2009-06-28 08:08:54 UTC (rev 13717) |
188 |
+++ main/branches/prefix/pym/_emerge/Scheduler.py 2009-06-28 13:10:08 UTC (rev 13718) |
189 |
@@ -330,14 +330,7 @@ |
190 |
if not (isinstance(task, Package) and \ |
191 |
task.operation == "merge"): |
192 |
continue |
193 |
- try: |
194 |
- properties = flatten(use_reduce(paren_reduce( |
195 |
- task.metadata["PROPERTIES"]), uselist=task.use.enabled)) |
196 |
- except portage.exception.InvalidDependString, e: |
197 |
- show_invalid_depstring_notice(task, |
198 |
- task.metadata["PROPERTIES"], str(e)) |
199 |
- raise self._unknown_internal_error() |
200 |
- if "interactive" in properties: |
201 |
+ if 'interactive' in task.metadata.properties: |
202 |
interactive_tasks.append(task) |
203 |
return interactive_tasks |
204 |
|
205 |
|
206 |
Modified: main/branches/prefix/pym/_emerge/depgraph.py |
207 |
=================================================================== |
208 |
--- main/branches/prefix/pym/_emerge/depgraph.py 2009-06-28 08:08:54 UTC (rev 13717) |
209 |
+++ main/branches/prefix/pym/_emerge/depgraph.py 2009-06-28 13:10:08 UTC (rev 13718) |
210 |
@@ -3711,18 +3711,8 @@ |
211 |
else: |
212 |
repo_path_real = portdb.getRepositoryPath(repo_name) |
213 |
pkg_use = list(pkg.use.enabled) |
214 |
- try: |
215 |
- restrict = flatten(use_reduce(paren_reduce( |
216 |
- pkg.metadata["RESTRICT"]), uselist=pkg_use)) |
217 |
- except portage.exception.InvalidDependString, e: |
218 |
- if not pkg.installed: |
219 |
- show_invalid_depstring_notice(x, |
220 |
- pkg.metadata["RESTRICT"], str(e)) |
221 |
- del e |
222 |
- return 1 |
223 |
- restrict = [] |
224 |
- if "ebuild" == pkg_type and x[3] != "nomerge" and \ |
225 |
- "fetch" in restrict: |
226 |
+ if not pkg.built and pkg.operation == 'merge' and \ |
227 |
+ 'fetch' in pkg.metadata.restrict: |
228 |
fetch = red("F") |
229 |
if ordered: |
230 |
counters.restrict_fetch += 1 |
231 |
@@ -4009,18 +3999,8 @@ |
232 |
else: |
233 |
return colorize("PKG_NOMERGE", pkg_str) |
234 |
|
235 |
- try: |
236 |
- properties = flatten(use_reduce(paren_reduce( |
237 |
- pkg.metadata["PROPERTIES"]), uselist=pkg.use.enabled)) |
238 |
- except portage.exception.InvalidDependString, e: |
239 |
- if not pkg.installed: |
240 |
- show_invalid_depstring_notice(pkg, |
241 |
- pkg.metadata["PROPERTIES"], str(e)) |
242 |
- del e |
243 |
- return 1 |
244 |
- properties = [] |
245 |
- interactive = "interactive" in properties |
246 |
- if interactive and pkg.operation == "merge": |
247 |
+ if 'interactive' in pkg.metadata.properties and \ |
248 |
+ pkg.operation == 'merge': |
249 |
addl = colorize("WARN", "I") + addl[1:] |
250 |
if ordered: |
251 |
counters.interactive += 1 |
252 |
@@ -4912,6 +4892,9 @@ |
253 |
if not pkgsettings._accept_chost(pkg.cpv, pkg.metadata): |
254 |
mreasons.append("CHOST: %s" % \ |
255 |
pkg.metadata["CHOST"]) |
256 |
+ if pkg.invalid: |
257 |
+ for msg in pkg.invalid: |
258 |
+ mreasons.append("invalid: %s" % (msg,)) |
259 |
|
260 |
if pkg.built and not pkg.installed: |
261 |
if not "EPREFIX" in pkg.metadata or not pkg.metadata["EPREFIX"]: |
262 |
|
263 |
Modified: main/branches/prefix/pym/_emerge/visible.py |
264 |
=================================================================== |
265 |
--- main/branches/prefix/pym/_emerge/visible.py 2009-06-28 08:08:54 UTC (rev 13717) |
266 |
+++ main/branches/prefix/pym/_emerge/visible.py 2009-06-28 13:10:08 UTC (rev 13718) |
267 |
@@ -22,6 +22,8 @@ |
268 |
if not pkg.metadata["SLOT"]: |
269 |
return False |
270 |
if not pkg.installed: |
271 |
+ if pkg.invalid: |
272 |
+ return False |
273 |
if not pkgsettings._accept_chost(pkg.cpv, pkg.metadata): |
274 |
return False |
275 |
if pkg.built and not pkg.installed: |
276 |
|
277 |
Modified: main/branches/prefix/pym/portage/__init__.py |
278 |
=================================================================== |
279 |
--- main/branches/prefix/pym/portage/__init__.py 2009-06-28 08:08:54 UTC (rev 13717) |
280 |
+++ main/branches/prefix/pym/portage/__init__.py 2009-06-28 13:10:08 UTC (rev 13718) |
281 |
@@ -1209,6 +1209,7 @@ |
282 |
self.uvlist = [] |
283 |
self._accept_chost_re = None |
284 |
self._accept_license = None |
285 |
+ self._accept_license_str = None |
286 |
|
287 |
self.virtuals = {} |
288 |
self.virts_p = {} |
289 |
@@ -2876,17 +2877,19 @@ |
290 |
# ACCEPT_LICENSE is a lazily evaluated incremental, so that * can be |
291 |
# used to match all licenses without every having to explicitly expand |
292 |
# it to all licenses. |
293 |
- if self._accept_license is None: |
294 |
- if self.local_config: |
295 |
- mysplit = [] |
296 |
- for curdb in mydbs: |
297 |
- mysplit.extend(curdb.get('ACCEPT_LICENSE', '').split()) |
298 |
- if mysplit: |
299 |
- self.configlist[-1]['ACCEPT_LICENSE'] = ' '.join(mysplit) |
300 |
+ if self.local_config: |
301 |
+ mysplit = [] |
302 |
+ for curdb in mydbs: |
303 |
+ mysplit.extend(curdb.get('ACCEPT_LICENSE', '').split()) |
304 |
+ accept_license_str = ' '.join(mysplit) |
305 |
+ if accept_license_str: |
306 |
+ self.configlist[-1]['ACCEPT_LICENSE'] = accept_license_str |
307 |
+ if accept_license_str != self._accept_license_str: |
308 |
+ self._accept_license_str = accept_license_str |
309 |
self._accept_license = tuple(self.expandLicenseTokens(mysplit)) |
310 |
- else: |
311 |
- # repoman will accept any license |
312 |
- self._accept_license = () |
313 |
+ else: |
314 |
+ # repoman will accept any license |
315 |
+ self._accept_license = () |
316 |
|
317 |
for mykey in myincrementals: |
318 |
|
319 |
|
320 |
Modified: main/branches/prefix/pym/portage/dbapi/__init__.py |
321 |
=================================================================== |
322 |
--- main/branches/prefix/pym/portage/dbapi/__init__.py 2009-06-28 08:08:54 UTC (rev 13717) |
323 |
+++ main/branches/prefix/pym/portage/dbapi/__init__.py 2009-06-28 13:10:08 UTC (rev 13718) |
324 |
@@ -50,7 +50,7 @@ |
325 |
pass |
326 |
|
327 |
def cp_list(self, cp, use_cache=1): |
328 |
- return |
329 |
+ raise NotImplementedError(self) |
330 |
|
331 |
def _cpv_sort_ascending(self, cpv_list): |
332 |
""" |