1 |
Author: zmedico |
2 |
Date: 2010-02-25 21:38:30 +0000 (Thu, 25 Feb 2010) |
3 |
New Revision: 15463 |
4 |
|
5 |
Added: |
6 |
main/trunk/pym/portage/package/ebuild/getmaskingreason.py |
7 |
main/trunk/pym/portage/package/ebuild/getmaskingstatus.py |
8 |
Modified: |
9 |
main/trunk/pym/portage/__init__.py |
10 |
Log: |
11 |
Split getmaskingstatus and getmaskingreason info portage.package.ebuild |
12 |
submodules. |
13 |
|
14 |
|
15 |
Modified: main/trunk/pym/portage/__init__.py |
16 |
=================================================================== |
17 |
--- main/trunk/pym/portage/__init__.py 2010-02-25 21:15:35 UTC (rev 15462) |
18 |
+++ main/trunk/pym/portage/__init__.py 2010-02-25 21:38:30 UTC (rev 15463) |
19 |
@@ -110,6 +110,8 @@ |
20 |
'portage.package.ebuild.digestcheck:digestcheck', |
21 |
'portage.package.ebuild.digestgen:digestgen', |
22 |
'portage.package.ebuild.fetch:fetch', |
23 |
+ 'portage.package.ebuild.getmaskingreason:getmaskingreason', |
24 |
+ 'portage.package.ebuild.getmaskingstatus:getmaskingstatus', |
25 |
'portage.package.ebuild.prepare_build_dirs:prepare_build_dirs', |
26 |
'portage.process', |
27 |
'portage.process:atexit_register,run_exitfuncs', |
28 |
@@ -913,217 +915,6 @@ |
29 |
newsplit.append(x) |
30 |
return newsplit |
31 |
|
32 |
-def getmaskingreason(mycpv, metadata=None, settings=None, portdb=None, return_location=False): |
33 |
- from portage.util import grablines |
34 |
- if settings is None: |
35 |
- settings = globals()["settings"] |
36 |
- if portdb is None: |
37 |
- portdb = globals()["portdb"] |
38 |
- mysplit = catpkgsplit(mycpv) |
39 |
- if not mysplit: |
40 |
- raise ValueError(_("invalid CPV: %s") % mycpv) |
41 |
- if metadata is None: |
42 |
- db_keys = list(portdb._aux_cache_keys) |
43 |
- try: |
44 |
- metadata = dict(zip(db_keys, portdb.aux_get(mycpv, db_keys))) |
45 |
- except KeyError: |
46 |
- if not portdb.cpv_exists(mycpv): |
47 |
- raise |
48 |
- if metadata is None: |
49 |
- # Can't access SLOT due to corruption. |
50 |
- cpv_slot_list = [mycpv] |
51 |
- else: |
52 |
- cpv_slot_list = ["%s:%s" % (mycpv, metadata["SLOT"])] |
53 |
- mycp=mysplit[0]+"/"+mysplit[1] |
54 |
- |
55 |
- # XXX- This is a temporary duplicate of code from the config constructor. |
56 |
- locations = [os.path.join(settings["PORTDIR"], "profiles")] |
57 |
- locations.extend(settings.profiles) |
58 |
- for ov in settings["PORTDIR_OVERLAY"].split(): |
59 |
- profdir = os.path.join(normalize_path(ov), "profiles") |
60 |
- if os.path.isdir(profdir): |
61 |
- locations.append(profdir) |
62 |
- locations.append(os.path.join(settings["PORTAGE_CONFIGROOT"], |
63 |
- USER_CONFIG_PATH)) |
64 |
- locations.reverse() |
65 |
- pmasklists = [(x, grablines(os.path.join(x, "package.mask"), recursive=1)) for x in locations] |
66 |
- |
67 |
- if mycp in settings.pmaskdict: |
68 |
- for x in settings.pmaskdict[mycp]: |
69 |
- if match_from_list(x, cpv_slot_list): |
70 |
- for pmask in pmasklists: |
71 |
- comment = "" |
72 |
- comment_valid = -1 |
73 |
- pmask_filename = os.path.join(pmask[0], "package.mask") |
74 |
- for i in range(len(pmask[1])): |
75 |
- l = pmask[1][i].strip() |
76 |
- if l == "": |
77 |
- comment = "" |
78 |
- comment_valid = -1 |
79 |
- elif l[0] == "#": |
80 |
- comment += (l+"\n") |
81 |
- comment_valid = i + 1 |
82 |
- elif l == x: |
83 |
- if comment_valid != i: |
84 |
- comment = "" |
85 |
- if return_location: |
86 |
- return (comment, pmask_filename) |
87 |
- else: |
88 |
- return comment |
89 |
- elif comment_valid != -1: |
90 |
- # Apparently this comment applies to muliple masks, so |
91 |
- # it remains valid until a blank line is encountered. |
92 |
- comment_valid += 1 |
93 |
- if return_location: |
94 |
- return (None, None) |
95 |
- else: |
96 |
- return None |
97 |
- |
98 |
-def getmaskingstatus(mycpv, settings=None, portdb=None): |
99 |
- if settings is None: |
100 |
- settings = config(clone=globals()["settings"]) |
101 |
- if portdb is None: |
102 |
- portdb = globals()["portdb"] |
103 |
- |
104 |
- metadata = None |
105 |
- installed = False |
106 |
- if not isinstance(mycpv, basestring): |
107 |
- # emerge passed in a Package instance |
108 |
- pkg = mycpv |
109 |
- mycpv = pkg.cpv |
110 |
- metadata = pkg.metadata |
111 |
- installed = pkg.installed |
112 |
- |
113 |
- mysplit = catpkgsplit(mycpv) |
114 |
- if not mysplit: |
115 |
- raise ValueError(_("invalid CPV: %s") % mycpv) |
116 |
- if metadata is None: |
117 |
- db_keys = list(portdb._aux_cache_keys) |
118 |
- try: |
119 |
- metadata = dict(zip(db_keys, portdb.aux_get(mycpv, db_keys))) |
120 |
- except KeyError: |
121 |
- if not portdb.cpv_exists(mycpv): |
122 |
- raise |
123 |
- return ["corruption"] |
124 |
- if "?" in metadata["LICENSE"]: |
125 |
- settings.setcpv(mycpv, mydb=metadata) |
126 |
- metadata["USE"] = settings["PORTAGE_USE"] |
127 |
- else: |
128 |
- metadata["USE"] = "" |
129 |
- mycp=mysplit[0]+"/"+mysplit[1] |
130 |
- |
131 |
- rValue = [] |
132 |
- |
133 |
- # profile checking |
134 |
- if settings._getProfileMaskAtom(mycpv, metadata): |
135 |
- rValue.append("profile") |
136 |
- |
137 |
- # package.mask checking |
138 |
- if settings._getMaskAtom(mycpv, metadata): |
139 |
- rValue.append("package.mask") |
140 |
- |
141 |
- # keywords checking |
142 |
- eapi = metadata["EAPI"] |
143 |
- mygroups = settings._getKeywords(mycpv, metadata) |
144 |
- licenses = metadata["LICENSE"] |
145 |
- properties = metadata["PROPERTIES"] |
146 |
- slot = metadata["SLOT"] |
147 |
- if eapi.startswith("-"): |
148 |
- eapi = eapi[1:] |
149 |
- if not eapi_is_supported(eapi): |
150 |
- return ["EAPI %s" % eapi] |
151 |
- elif _eapi_is_deprecated(eapi) and not installed: |
152 |
- return ["EAPI %s" % eapi] |
153 |
- egroups = settings.configdict["backupenv"].get( |
154 |
- "ACCEPT_KEYWORDS", "").split() |
155 |
- pgroups = settings["ACCEPT_KEYWORDS"].split() |
156 |
- myarch = settings["ARCH"] |
157 |
- if pgroups and myarch not in pgroups: |
158 |
- """For operating systems other than Linux, ARCH is not necessarily a |
159 |
- valid keyword.""" |
160 |
- myarch = pgroups[0].lstrip("~") |
161 |
- |
162 |
- cp = cpv_getkey(mycpv) |
163 |
- pkgdict = settings.pkeywordsdict.get(cp) |
164 |
- matches = False |
165 |
- if pkgdict: |
166 |
- cpv_slot_list = ["%s:%s" % (mycpv, metadata["SLOT"])] |
167 |
- for atom, pkgkeywords in pkgdict.items(): |
168 |
- if match_from_list(atom, cpv_slot_list): |
169 |
- matches = True |
170 |
- pgroups.extend(pkgkeywords) |
171 |
- if matches or egroups: |
172 |
- pgroups.extend(egroups) |
173 |
- inc_pgroups = set() |
174 |
- for x in pgroups: |
175 |
- if x.startswith("-"): |
176 |
- if x == "-*": |
177 |
- inc_pgroups.clear() |
178 |
- else: |
179 |
- inc_pgroups.discard(x[1:]) |
180 |
- else: |
181 |
- inc_pgroups.add(x) |
182 |
- pgroups = inc_pgroups |
183 |
- del inc_pgroups |
184 |
- |
185 |
- kmask = "missing" |
186 |
- |
187 |
- if '**' in pgroups: |
188 |
- kmask = None |
189 |
- else: |
190 |
- for keyword in pgroups: |
191 |
- if keyword in mygroups: |
192 |
- kmask = None |
193 |
- break |
194 |
- |
195 |
- if kmask: |
196 |
- fallback = None |
197 |
- for gp in mygroups: |
198 |
- if gp=="*": |
199 |
- kmask=None |
200 |
- break |
201 |
- elif gp=="-"+myarch and myarch in pgroups: |
202 |
- kmask="-"+myarch |
203 |
- break |
204 |
- elif gp=="~"+myarch and myarch in pgroups: |
205 |
- kmask="~"+myarch |
206 |
- break |
207 |
- |
208 |
- try: |
209 |
- missing_licenses = settings._getMissingLicenses(mycpv, metadata) |
210 |
- if missing_licenses: |
211 |
- allowed_tokens = set(["||", "(", ")"]) |
212 |
- allowed_tokens.update(missing_licenses) |
213 |
- license_split = licenses.split() |
214 |
- license_split = [x for x in license_split \ |
215 |
- if x in allowed_tokens] |
216 |
- msg = license_split[:] |
217 |
- msg.append("license(s)") |
218 |
- rValue.append(" ".join(msg)) |
219 |
- except portage.exception.InvalidDependString as e: |
220 |
- rValue.append("LICENSE: "+str(e)) |
221 |
- |
222 |
- try: |
223 |
- missing_properties = settings._getMissingProperties(mycpv, metadata) |
224 |
- if missing_properties: |
225 |
- allowed_tokens = set(["||", "(", ")"]) |
226 |
- allowed_tokens.update(missing_properties) |
227 |
- properties_split = properties.split() |
228 |
- properties_split = [x for x in properties_split \ |
229 |
- if x in allowed_tokens] |
230 |
- msg = properties_split[:] |
231 |
- msg.append("properties") |
232 |
- rValue.append(" ".join(msg)) |
233 |
- except portage.exception.InvalidDependString as e: |
234 |
- rValue.append("PROPERTIES: "+str(e)) |
235 |
- |
236 |
- # Only show KEYWORDS masks for installed packages |
237 |
- # if they're not masked for any other reason. |
238 |
- if kmask and (not installed or not rValue): |
239 |
- rValue.append(kmask+" keyword") |
240 |
- |
241 |
- return rValue |
242 |
- |
243 |
auxdbkeys = ( |
244 |
'DEPEND', 'RDEPEND', 'SLOT', 'SRC_URI', |
245 |
'RESTRICT', 'HOMEPAGE', 'LICENSE', 'DESCRIPTION', |
246 |
|
247 |
Added: main/trunk/pym/portage/package/ebuild/getmaskingreason.py |
248 |
=================================================================== |
249 |
--- main/trunk/pym/portage/package/ebuild/getmaskingreason.py (rev 0) |
250 |
+++ main/trunk/pym/portage/package/ebuild/getmaskingreason.py 2010-02-25 21:38:30 UTC (rev 15463) |
251 |
@@ -0,0 +1,78 @@ |
252 |
+# Copyright 2010 Gentoo Foundation |
253 |
+# Distributed under the terms of the GNU General Public License v2 |
254 |
+# $Id$ |
255 |
+ |
256 |
+__all__ = ['getmaskingreason'] |
257 |
+ |
258 |
+import portage |
259 |
+from portage import os |
260 |
+from portage.const import USER_CONFIG_PATH |
261 |
+from portage.dep import match_from_list |
262 |
+from portage.localization import _ |
263 |
+from portage.util import grablines, normalize_path |
264 |
+from portage.versions import catpkgsplit |
265 |
+ |
266 |
+def getmaskingreason(mycpv, metadata=None, settings=None, portdb=None, return_location=False): |
267 |
+ if settings is None: |
268 |
+ settings = portage.settings |
269 |
+ if portdb is None: |
270 |
+ portdb = portage.portdb |
271 |
+ mysplit = catpkgsplit(mycpv) |
272 |
+ if not mysplit: |
273 |
+ raise ValueError(_("invalid CPV: %s") % mycpv) |
274 |
+ if metadata is None: |
275 |
+ db_keys = list(portdb._aux_cache_keys) |
276 |
+ try: |
277 |
+ metadata = dict(zip(db_keys, portdb.aux_get(mycpv, db_keys))) |
278 |
+ except KeyError: |
279 |
+ if not portdb.cpv_exists(mycpv): |
280 |
+ raise |
281 |
+ if metadata is None: |
282 |
+ # Can't access SLOT due to corruption. |
283 |
+ cpv_slot_list = [mycpv] |
284 |
+ else: |
285 |
+ cpv_slot_list = ["%s:%s" % (mycpv, metadata["SLOT"])] |
286 |
+ mycp=mysplit[0]+"/"+mysplit[1] |
287 |
+ |
288 |
+ # XXX- This is a temporary duplicate of code from the config constructor. |
289 |
+ locations = [os.path.join(settings["PORTDIR"], "profiles")] |
290 |
+ locations.extend(settings.profiles) |
291 |
+ for ov in settings["PORTDIR_OVERLAY"].split(): |
292 |
+ profdir = os.path.join(normalize_path(ov), "profiles") |
293 |
+ if os.path.isdir(profdir): |
294 |
+ locations.append(profdir) |
295 |
+ locations.append(os.path.join(settings["PORTAGE_CONFIGROOT"], |
296 |
+ USER_CONFIG_PATH)) |
297 |
+ locations.reverse() |
298 |
+ pmasklists = [(x, grablines(os.path.join(x, "package.mask"), recursive=1)) for x in locations] |
299 |
+ |
300 |
+ if mycp in settings.pmaskdict: |
301 |
+ for x in settings.pmaskdict[mycp]: |
302 |
+ if match_from_list(x, cpv_slot_list): |
303 |
+ for pmask in pmasklists: |
304 |
+ comment = "" |
305 |
+ comment_valid = -1 |
306 |
+ pmask_filename = os.path.join(pmask[0], "package.mask") |
307 |
+ for i in range(len(pmask[1])): |
308 |
+ l = pmask[1][i].strip() |
309 |
+ if l == "": |
310 |
+ comment = "" |
311 |
+ comment_valid = -1 |
312 |
+ elif l[0] == "#": |
313 |
+ comment += (l+"\n") |
314 |
+ comment_valid = i + 1 |
315 |
+ elif l == x: |
316 |
+ if comment_valid != i: |
317 |
+ comment = "" |
318 |
+ if return_location: |
319 |
+ return (comment, pmask_filename) |
320 |
+ else: |
321 |
+ return comment |
322 |
+ elif comment_valid != -1: |
323 |
+ # Apparently this comment applies to muliple masks, so |
324 |
+ # it remains valid until a blank line is encountered. |
325 |
+ comment_valid += 1 |
326 |
+ if return_location: |
327 |
+ return (None, None) |
328 |
+ else: |
329 |
+ return None |
330 |
|
331 |
|
332 |
Property changes on: main/trunk/pym/portage/package/ebuild/getmaskingreason.py |
333 |
___________________________________________________________________ |
334 |
Added: svn:keywords |
335 |
+ Id |
336 |
|
337 |
Added: main/trunk/pym/portage/package/ebuild/getmaskingstatus.py |
338 |
=================================================================== |
339 |
--- main/trunk/pym/portage/package/ebuild/getmaskingstatus.py (rev 0) |
340 |
+++ main/trunk/pym/portage/package/ebuild/getmaskingstatus.py 2010-02-25 21:38:30 UTC (rev 15463) |
341 |
@@ -0,0 +1,154 @@ |
342 |
+# Copyright 2010 Gentoo Foundation |
343 |
+# Distributed under the terms of the GNU General Public License v2 |
344 |
+# $Id$ |
345 |
+ |
346 |
+__all__ = ['getmaskingstatus'] |
347 |
+ |
348 |
+import portage |
349 |
+from portage import eapi_is_supported, _eapi_is_deprecated |
350 |
+from portage.dep import match_from_list |
351 |
+from portage.localization import _ |
352 |
+from portage.package.ebuild.config import config |
353 |
+from portage.versions import catpkgsplit, cpv_getkey |
354 |
+ |
355 |
+def getmaskingstatus(mycpv, settings=None, portdb=None): |
356 |
+ if settings is None: |
357 |
+ settings = config(clone=portage.settings) |
358 |
+ if portdb is None: |
359 |
+ portdb = portage.portdb |
360 |
+ |
361 |
+ metadata = None |
362 |
+ installed = False |
363 |
+ if not isinstance(mycpv, basestring): |
364 |
+ # emerge passed in a Package instance |
365 |
+ pkg = mycpv |
366 |
+ mycpv = pkg.cpv |
367 |
+ metadata = pkg.metadata |
368 |
+ installed = pkg.installed |
369 |
+ |
370 |
+ mysplit = catpkgsplit(mycpv) |
371 |
+ if not mysplit: |
372 |
+ raise ValueError(_("invalid CPV: %s") % mycpv) |
373 |
+ if metadata is None: |
374 |
+ db_keys = list(portdb._aux_cache_keys) |
375 |
+ try: |
376 |
+ metadata = dict(zip(db_keys, portdb.aux_get(mycpv, db_keys))) |
377 |
+ except KeyError: |
378 |
+ if not portdb.cpv_exists(mycpv): |
379 |
+ raise |
380 |
+ return ["corruption"] |
381 |
+ if "?" in metadata["LICENSE"]: |
382 |
+ settings.setcpv(mycpv, mydb=metadata) |
383 |
+ metadata["USE"] = settings["PORTAGE_USE"] |
384 |
+ else: |
385 |
+ metadata["USE"] = "" |
386 |
+ |
387 |
+ rValue = [] |
388 |
+ |
389 |
+ # profile checking |
390 |
+ if settings._getProfileMaskAtom(mycpv, metadata): |
391 |
+ rValue.append("profile") |
392 |
+ |
393 |
+ # package.mask checking |
394 |
+ if settings._getMaskAtom(mycpv, metadata): |
395 |
+ rValue.append("package.mask") |
396 |
+ |
397 |
+ # keywords checking |
398 |
+ eapi = metadata["EAPI"] |
399 |
+ mygroups = settings._getKeywords(mycpv, metadata) |
400 |
+ licenses = metadata["LICENSE"] |
401 |
+ properties = metadata["PROPERTIES"] |
402 |
+ if eapi.startswith("-"): |
403 |
+ eapi = eapi[1:] |
404 |
+ if not eapi_is_supported(eapi): |
405 |
+ return ["EAPI %s" % eapi] |
406 |
+ elif _eapi_is_deprecated(eapi) and not installed: |
407 |
+ return ["EAPI %s" % eapi] |
408 |
+ egroups = settings.configdict["backupenv"].get( |
409 |
+ "ACCEPT_KEYWORDS", "").split() |
410 |
+ pgroups = settings["ACCEPT_KEYWORDS"].split() |
411 |
+ myarch = settings["ARCH"] |
412 |
+ if pgroups and myarch not in pgroups: |
413 |
+ """For operating systems other than Linux, ARCH is not necessarily a |
414 |
+ valid keyword.""" |
415 |
+ myarch = pgroups[0].lstrip("~") |
416 |
+ |
417 |
+ cp = cpv_getkey(mycpv) |
418 |
+ pkgdict = settings.pkeywordsdict.get(cp) |
419 |
+ matches = False |
420 |
+ if pkgdict: |
421 |
+ cpv_slot_list = ["%s:%s" % (mycpv, metadata["SLOT"])] |
422 |
+ for atom, pkgkeywords in pkgdict.items(): |
423 |
+ if match_from_list(atom, cpv_slot_list): |
424 |
+ matches = True |
425 |
+ pgroups.extend(pkgkeywords) |
426 |
+ if matches or egroups: |
427 |
+ pgroups.extend(egroups) |
428 |
+ inc_pgroups = set() |
429 |
+ for x in pgroups: |
430 |
+ if x.startswith("-"): |
431 |
+ if x == "-*": |
432 |
+ inc_pgroups.clear() |
433 |
+ else: |
434 |
+ inc_pgroups.discard(x[1:]) |
435 |
+ else: |
436 |
+ inc_pgroups.add(x) |
437 |
+ pgroups = inc_pgroups |
438 |
+ del inc_pgroups |
439 |
+ |
440 |
+ kmask = "missing" |
441 |
+ |
442 |
+ if '**' in pgroups: |
443 |
+ kmask = None |
444 |
+ else: |
445 |
+ for keyword in pgroups: |
446 |
+ if keyword in mygroups: |
447 |
+ kmask = None |
448 |
+ break |
449 |
+ |
450 |
+ if kmask: |
451 |
+ for gp in mygroups: |
452 |
+ if gp=="*": |
453 |
+ kmask=None |
454 |
+ break |
455 |
+ elif gp=="-"+myarch and myarch in pgroups: |
456 |
+ kmask="-"+myarch |
457 |
+ break |
458 |
+ elif gp=="~"+myarch and myarch in pgroups: |
459 |
+ kmask="~"+myarch |
460 |
+ break |
461 |
+ |
462 |
+ try: |
463 |
+ missing_licenses = settings._getMissingLicenses(mycpv, metadata) |
464 |
+ if missing_licenses: |
465 |
+ allowed_tokens = set(["||", "(", ")"]) |
466 |
+ allowed_tokens.update(missing_licenses) |
467 |
+ license_split = licenses.split() |
468 |
+ license_split = [x for x in license_split \ |
469 |
+ if x in allowed_tokens] |
470 |
+ msg = license_split[:] |
471 |
+ msg.append("license(s)") |
472 |
+ rValue.append(" ".join(msg)) |
473 |
+ except portage.exception.InvalidDependString as e: |
474 |
+ rValue.append("LICENSE: "+str(e)) |
475 |
+ |
476 |
+ try: |
477 |
+ missing_properties = settings._getMissingProperties(mycpv, metadata) |
478 |
+ if missing_properties: |
479 |
+ allowed_tokens = set(["||", "(", ")"]) |
480 |
+ allowed_tokens.update(missing_properties) |
481 |
+ properties_split = properties.split() |
482 |
+ properties_split = [x for x in properties_split \ |
483 |
+ if x in allowed_tokens] |
484 |
+ msg = properties_split[:] |
485 |
+ msg.append("properties") |
486 |
+ rValue.append(" ".join(msg)) |
487 |
+ except portage.exception.InvalidDependString as e: |
488 |
+ rValue.append("PROPERTIES: "+str(e)) |
489 |
+ |
490 |
+ # Only show KEYWORDS masks for installed packages |
491 |
+ # if they're not masked for any other reason. |
492 |
+ if kmask and (not installed or not rValue): |
493 |
+ rValue.append(kmask+" keyword") |
494 |
+ |
495 |
+ return rValue |
496 |
|
497 |
|
498 |
Property changes on: main/trunk/pym/portage/package/ebuild/getmaskingstatus.py |
499 |
___________________________________________________________________ |
500 |
Added: svn:keywords |
501 |
+ Id |