Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r15460 - in main/trunk: bin pym/_emerge pym/portage pym/portage/dbapi
Date: Thu, 25 Feb 2010 20:42:09
Message-Id: E1NkkX6-0003u5-MO@stork.gentoo.org
1 Author: zmedico
2 Date: 2010-02-25 20:42:04 +0000 (Thu, 25 Feb 2010)
3 New Revision: 15460
4
5 Added:
6 main/trunk/pym/portage/dbapi/cpv_expand.py
7 main/trunk/pym/portage/dbapi/dep_expand.py
8 Modified:
9 main/trunk/bin/quickpkg
10 main/trunk/pym/_emerge/actions.py
11 main/trunk/pym/_emerge/depgraph.py
12 main/trunk/pym/_emerge/main.py
13 main/trunk/pym/portage/__init__.py
14 main/trunk/pym/portage/dbapi/__init__.py
15 main/trunk/pym/portage/dbapi/bintree.py
16 main/trunk/pym/portage/dbapi/porttree.py
17 main/trunk/pym/portage/dbapi/vartree.py
18 Log:
19 Move dep_expand and cpv_expand into portage.dbapi submodules.
20
21
22 Modified: main/trunk/bin/quickpkg
23 ===================================================================
24 --- main/trunk/bin/quickpkg 2010-02-25 20:40:13 UTC (rev 15459)
25 +++ main/trunk/bin/quickpkg 2010-02-25 20:42:04 UTC (rev 15460)
26 @@ -19,7 +19,8 @@
27 from portage import os
28
29 def quickpkg_main(options, args, eout):
30 - from portage import catsplit, dep_expand, flatten, isvalidatom, xpak
31 + from portage import catsplit, flatten, isvalidatom, xpak
32 + from portage.dbapi.dep_expand import dep_expand
33 from portage.dep import use_reduce, paren_reduce
34 from portage.util import ConfigProtect, ensure_dirs
35 from portage.exception import InvalidAtom, InvalidData, InvalidDependString
36
37 Modified: main/trunk/pym/_emerge/actions.py
38 ===================================================================
39 --- main/trunk/pym/_emerge/actions.py 2010-02-25 20:40:13 UTC (rev 15459)
40 +++ main/trunk/pym/_emerge/actions.py 2010-02-25 20:42:04 UTC (rev 15460)
41 @@ -27,6 +27,7 @@
42 from portage import _unicode_decode
43 from portage.cache.cache_errors import CacheError
44 from portage.const import NEWS_LIB_PATH
45 +from portage.dbapi.dep_expand import dep_expand
46 from portage.output import blue, bold, colorize, create_color_func, darkgreen, \
47 red, yellow
48 good = create_color_func("GOOD")
49 @@ -2212,7 +2213,7 @@
50
51 try:
52 valid_atoms.append(
53 - portage.dep_expand(x, mydb=vardb, settings=settings))
54 + dep_expand(x, mydb=vardb, settings=settings))
55 except portage.exception.AmbiguousPackageName as e:
56 msg = "The short ebuild name \"" + x + \
57 "\" is ambiguous. Please specify " + \
58
59 Modified: main/trunk/pym/_emerge/depgraph.py
60 ===================================================================
61 --- main/trunk/pym/_emerge/depgraph.py 2010-02-25 20:40:13 UTC (rev 15459)
62 +++ main/trunk/pym/_emerge/depgraph.py 2010-02-25 20:42:04 UTC (rev 15460)
63 @@ -15,6 +15,7 @@
64 from portage import os
65 from portage import digraph
66 from portage.dbapi import dbapi
67 +from portage.dbapi.dep_expand import dep_expand
68 from portage.dep import Atom
69 from portage.output import bold, blue, colorize, create_color_func, darkblue, \
70 darkgreen, green, nc_len, red, teal, turquoise, yellow
71 @@ -4160,7 +4161,7 @@
72 else:
73 blocker_style = "PKG_BLOCKER"
74 addl = "%s %s " % (colorize(blocker_style, "B"), fetch)
75 - resolved = portage.dep_expand(
76 + resolved = dep_expand(
77 str(x.atom).lstrip("!"), mydb=vardb, settings=pkgsettings)
78 if "--columns" in self._frozen_config.myopts and "--quiet" in self._frozen_config.myopts:
79 addl += " " + colorize(blocker_style, str(resolved))
80
81 Modified: main/trunk/pym/_emerge/main.py
82 ===================================================================
83 --- main/trunk/pym/_emerge/main.py 2010-02-25 20:40:13 UTC (rev 15459)
84 +++ main/trunk/pym/_emerge/main.py 2010-02-25 20:42:04 UTC (rev 15460)
85 @@ -32,6 +32,7 @@
86 import portage.locks
87 import portage.exception
88 from portage.data import secpass
89 +from portage.dbapi.dep_expand import dep_expand
90 from portage.util import normalize_path as normpath
91 from portage.util import writemsg, writemsg_level, writemsg_stdout
92 from portage.sets import SETPREFIX
93 @@ -1500,7 +1501,7 @@
94 if is_valid_package_atom(x):
95 try:
96 valid_atoms.append(
97 - portage.dep_expand(x, mydb=vardb, settings=settings))
98 + dep_expand(x, mydb=vardb, settings=settings))
99 except portage.exception.AmbiguousPackageName as e:
100 msg = "The short ebuild name \"" + x + \
101 "\" is ambiguous. Please specify " + \
102
103 Modified: main/trunk/pym/portage/__init__.py
104 ===================================================================
105 --- main/trunk/pym/portage/__init__.py 2010-02-25 20:40:13 UTC (rev 15459)
106 +++ main/trunk/pym/portage/__init__.py 2010-02-25 20:42:04 UTC (rev 15460)
107 @@ -82,6 +82,8 @@
108 'uid,userland,userpriv_groups,wheelgid',
109 'portage.dbapi',
110 'portage.dbapi.bintree:bindbapi,binarytree',
111 + 'portage.dbapi.cpv_expand:cpv_expand',
112 + 'portage.dbapi.dep_expand:dep_expand',
113 'portage.dbapi.porttree:close_portdbapi_caches,FetchlistDict,' + \
114 'portagetree,portdbapi',
115 'portage.dbapi.vartree:vardbapi,vartree,dblink',
116 @@ -1395,42 +1397,6 @@
117
118 assert(False) # This point should not be reachable
119
120 -def dep_expand(mydep, mydb=None, use_cache=1, settings=None):
121 - '''
122 - @rtype: Atom
123 - '''
124 - if not len(mydep):
125 - return mydep
126 - if mydep[0]=="*":
127 - mydep=mydep[1:]
128 - orig_dep = mydep
129 - if isinstance(orig_dep, dep.Atom):
130 - mydep = orig_dep.cp
131 - else:
132 - mydep = orig_dep
133 - has_cat = '/' in orig_dep
134 - if not has_cat:
135 - alphanum = re.search(r'\w', orig_dep)
136 - if alphanum:
137 - mydep = orig_dep[:alphanum.start()] + "null/" + \
138 - orig_dep[alphanum.start():]
139 - try:
140 - mydep = dep.Atom(mydep)
141 - except exception.InvalidAtom:
142 - # Missing '=' prefix is allowed for backward compatibility.
143 - if not dep.isvalidatom("=" + mydep):
144 - raise
145 - mydep = dep.Atom('=' + mydep)
146 - orig_dep = '=' + orig_dep
147 - if not has_cat:
148 - null_cat, pn = catsplit(mydep.cp)
149 - mydep = pn
150 - else:
151 - mydep = mydep.cp
152 - expanded = cpv_expand(mydep, mydb=mydb,
153 - use_cache=use_cache, settings=settings)
154 - return portage.dep.Atom(orig_dep.replace(mydep, expanded, 1))
155 -
156 def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
157 use_cache=1, use_binaries=0, myroot="/", trees=None):
158 """Takes a depend string and parses the condition."""
159 @@ -1564,92 +1530,6 @@
160 return None
161 return deplist
162
163 -def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None):
164 - """Given a string (packagename or virtual) expand it into a valid
165 - cat/package string. Virtuals use the mydb to determine which provided
166 - virtual is a valid choice and defaults to the first element when there
167 - are no installed/available candidates."""
168 - myslash=mycpv.split("/")
169 - mysplit = versions._pkgsplit(myslash[-1])
170 - if settings is None:
171 - settings = globals()["settings"]
172 - virts = settings.getvirtuals()
173 - virts_p = settings.get_virts_p()
174 - if len(myslash)>2:
175 - # this is illegal case.
176 - mysplit=[]
177 - mykey=mycpv
178 - elif len(myslash)==2:
179 - if mysplit:
180 - mykey=myslash[0]+"/"+mysplit[0]
181 - else:
182 - mykey=mycpv
183 - if mydb and virts and mykey in virts:
184 - writemsg("mydb.__class__: %s\n" % (mydb.__class__), 1)
185 - if hasattr(mydb, "cp_list"):
186 - if not mydb.cp_list(mykey, use_cache=use_cache):
187 - writemsg("virts[%s]: %s\n" % (str(mykey),virts[mykey]), 1)
188 - mykey_orig = mykey[:]
189 - for vkey in virts[mykey]:
190 - # The virtuals file can contain a versioned atom, so
191 - # it may be necessary to remove the operator and
192 - # version from the atom before it is passed into
193 - # dbapi.cp_list().
194 - if mydb.cp_list(vkey.cp):
195 - mykey = str(vkey)
196 - writemsg(_("virts chosen: %s\n") % (mykey), 1)
197 - break
198 - if mykey == mykey_orig:
199 - mykey = str(virts[mykey][0])
200 - writemsg(_("virts defaulted: %s\n") % (mykey), 1)
201 - #we only perform virtual expansion if we are passed a dbapi
202 - else:
203 - #specific cpv, no category, ie. "foo-1.0"
204 - if mysplit:
205 - myp=mysplit[0]
206 - else:
207 - # "foo" ?
208 - myp=mycpv
209 - mykey=None
210 - matches=[]
211 - if mydb and hasattr(mydb, "categories"):
212 - for x in mydb.categories:
213 - if mydb.cp_list(x+"/"+myp,use_cache=use_cache):
214 - matches.append(x+"/"+myp)
215 - if len(matches) > 1:
216 - virtual_name_collision = False
217 - if len(matches) == 2:
218 - for x in matches:
219 - if not x.startswith("virtual/"):
220 - # Assume that the non-virtual is desired. This helps
221 - # avoid the ValueError for invalid deps that come from
222 - # installed packages (during reverse blocker detection,
223 - # for example).
224 - mykey = x
225 - else:
226 - virtual_name_collision = True
227 - if not virtual_name_collision:
228 - # AmbiguousPackageName inherits from ValueError,
229 - # for backward compatibility with calling code
230 - # that already handles ValueError.
231 - raise portage.exception.AmbiguousPackageName(matches)
232 - elif matches:
233 - mykey=matches[0]
234 -
235 - if not mykey and not isinstance(mydb, list):
236 - if myp in virts_p:
237 - mykey=virts_p[myp][0]
238 - #again, we only perform virtual expansion if we have a dbapi (not a list)
239 - if not mykey:
240 - mykey="null/"+myp
241 - if mysplit:
242 - if mysplit[2]=="r0":
243 - return mykey+"-"+mysplit[1]
244 - else:
245 - return mykey+"-"+mysplit[1]+"-"+mysplit[2]
246 - else:
247 - return mykey
248 -
249 def getmaskingreason(mycpv, metadata=None, settings=None, portdb=None, return_location=False):
250 from portage.util import grablines
251 if settings is None:
252
253 Modified: main/trunk/pym/portage/dbapi/__init__.py
254 ===================================================================
255 --- main/trunk/pym/portage/dbapi/__init__.py 2010-02-25 20:40:13 UTC (rev 15459)
256 +++ main/trunk/pym/portage/dbapi/__init__.py 2010-02-25 20:42:04 UTC (rev 15460)
257 @@ -8,6 +8,7 @@
258
259 import portage
260 portage.proxy.lazyimport.lazyimport(globals(),
261 + 'portage.dbapi.dep_expand:dep_expand',
262 'portage.dep:match_from_list',
263 'portage.locks:unlockfile',
264 'portage.output:colorize',
265 @@ -16,7 +17,7 @@
266 )
267
268 from portage import os
269 -from portage import auxdbkeys, dep_expand
270 +from portage import auxdbkeys
271 from portage.localization import _
272
273 class dbapi(object):
274
275 Modified: main/trunk/pym/portage/dbapi/bintree.py
276 ===================================================================
277 --- main/trunk/pym/portage/dbapi/bintree.py 2010-02-25 20:40:13 UTC (rev 15459)
278 +++ main/trunk/pym/portage/dbapi/bintree.py 2010-02-25 20:42:04 UTC (rev 15460)
279 @@ -8,6 +8,7 @@
280
281 import portage
282 portage.proxy.lazyimport.lazyimport(globals(),
283 + 'portage.dbapi.dep_expand:dep_expand',
284 'portage.dep:dep_getkey,isjustname,match_from_list',
285 'portage.output:EOutput,colorize',
286 'portage.package.ebuild.doebuild:_vdb_use_conditional_atoms',
287 @@ -23,7 +24,7 @@
288 PermissionDenied, PortageException
289 from portage.localization import _
290
291 -from portage import dep_expand, _movefile
292 +from portage import _movefile
293 from portage import os
294 from portage import _encodings
295 from portage import _unicode_decode
296
297 Added: main/trunk/pym/portage/dbapi/cpv_expand.py
298 ===================================================================
299 --- main/trunk/pym/portage/dbapi/cpv_expand.py (rev 0)
300 +++ main/trunk/pym/portage/dbapi/cpv_expand.py 2010-02-25 20:42:04 UTC (rev 15460)
301 @@ -0,0 +1,96 @@
302 +# Copyright 2010 Gentoo Foundation
303 +# Distributed under the terms of the GNU General Public License v2
304 +# $Id$
305 +
306 +__all__ = ["cpv_expand"]
307 +
308 +from portage.exception import AmbiguousPackageName
309 +from portage.localization import _
310 +from portage.util import writemsg
311 +from portage.versions import _pkgsplit
312 +
313 +def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None):
314 + """Given a string (packagename or virtual) expand it into a valid
315 + cat/package string. Virtuals use the mydb to determine which provided
316 + virtual is a valid choice and defaults to the first element when there
317 + are no installed/available candidates."""
318 + myslash=mycpv.split("/")
319 + mysplit = _pkgsplit(myslash[-1])
320 + if settings is None:
321 + settings = globals()["settings"]
322 + virts = settings.getvirtuals()
323 + virts_p = settings.get_virts_p()
324 + if len(myslash)>2:
325 + # this is illegal case.
326 + mysplit=[]
327 + mykey=mycpv
328 + elif len(myslash)==2:
329 + if mysplit:
330 + mykey=myslash[0]+"/"+mysplit[0]
331 + else:
332 + mykey=mycpv
333 + if mydb and virts and mykey in virts:
334 + writemsg("mydb.__class__: %s\n" % (mydb.__class__), 1)
335 + if hasattr(mydb, "cp_list"):
336 + if not mydb.cp_list(mykey, use_cache=use_cache):
337 + writemsg("virts[%s]: %s\n" % (str(mykey),virts[mykey]), 1)
338 + mykey_orig = mykey[:]
339 + for vkey in virts[mykey]:
340 + # The virtuals file can contain a versioned atom, so
341 + # it may be necessary to remove the operator and
342 + # version from the atom before it is passed into
343 + # dbapi.cp_list().
344 + if mydb.cp_list(vkey.cp):
345 + mykey = str(vkey)
346 + writemsg(_("virts chosen: %s\n") % (mykey), 1)
347 + break
348 + if mykey == mykey_orig:
349 + mykey = str(virts[mykey][0])
350 + writemsg(_("virts defaulted: %s\n") % (mykey), 1)
351 + #we only perform virtual expansion if we are passed a dbapi
352 + else:
353 + #specific cpv, no category, ie. "foo-1.0"
354 + if mysplit:
355 + myp=mysplit[0]
356 + else:
357 + # "foo" ?
358 + myp=mycpv
359 + mykey=None
360 + matches=[]
361 + if mydb and hasattr(mydb, "categories"):
362 + for x in mydb.categories:
363 + if mydb.cp_list(x+"/"+myp,use_cache=use_cache):
364 + matches.append(x+"/"+myp)
365 + if len(matches) > 1:
366 + virtual_name_collision = False
367 + if len(matches) == 2:
368 + for x in matches:
369 + if not x.startswith("virtual/"):
370 + # Assume that the non-virtual is desired. This helps
371 + # avoid the ValueError for invalid deps that come from
372 + # installed packages (during reverse blocker detection,
373 + # for example).
374 + mykey = x
375 + else:
376 + virtual_name_collision = True
377 + if not virtual_name_collision:
378 + # AmbiguousPackageName inherits from ValueError,
379 + # for backward compatibility with calling code
380 + # that already handles ValueError.
381 + raise AmbiguousPackageName(matches)
382 + elif matches:
383 + mykey=matches[0]
384 +
385 + if not mykey and not isinstance(mydb, list):
386 + if myp in virts_p:
387 + mykey=virts_p[myp][0]
388 + #again, we only perform virtual expansion if we have a dbapi (not a list)
389 + if not mykey:
390 + mykey="null/"+myp
391 + if mysplit:
392 + if mysplit[2]=="r0":
393 + return mykey+"-"+mysplit[1]
394 + else:
395 + return mykey+"-"+mysplit[1]+"-"+mysplit[2]
396 + else:
397 + return mykey
398
399
400 Property changes on: main/trunk/pym/portage/dbapi/cpv_expand.py
401 ___________________________________________________________________
402 Added: svn:keywords
403 + Id
404
405 Added: main/trunk/pym/portage/dbapi/dep_expand.py
406 ===================================================================
407 --- main/trunk/pym/portage/dbapi/dep_expand.py (rev 0)
408 +++ main/trunk/pym/portage/dbapi/dep_expand.py 2010-02-25 20:42:04 UTC (rev 15460)
409 @@ -0,0 +1,48 @@
410 +# Copyright 2010 Gentoo Foundation
411 +# Distributed under the terms of the GNU General Public License v2
412 +# $Id$
413 +
414 +__all__ = ["dep_expand"]
415 +
416 +import re
417 +
418 +from portage.dbapi.cpv_expand import cpv_expand
419 +from portage.dep import Atom, isvalidatom
420 +from portage.exception import InvalidAtom
421 +from portage.versions import catsplit
422 +
423 +def dep_expand(mydep, mydb=None, use_cache=1, settings=None):
424 + '''
425 + @rtype: Atom
426 + '''
427 + if not len(mydep):
428 + return mydep
429 + if mydep[0]=="*":
430 + mydep=mydep[1:]
431 + orig_dep = mydep
432 + if isinstance(orig_dep, Atom):
433 + mydep = orig_dep.cp
434 + else:
435 + mydep = orig_dep
436 + has_cat = '/' in orig_dep
437 + if not has_cat:
438 + alphanum = re.search(r'\w', orig_dep)
439 + if alphanum:
440 + mydep = orig_dep[:alphanum.start()] + "null/" + \
441 + orig_dep[alphanum.start():]
442 + try:
443 + mydep = Atom(mydep)
444 + except InvalidAtom:
445 + # Missing '=' prefix is allowed for backward compatibility.
446 + if not isvalidatom("=" + mydep):
447 + raise
448 + mydep = Atom('=' + mydep)
449 + orig_dep = '=' + orig_dep
450 + if not has_cat:
451 + null_cat, pn = catsplit(mydep.cp)
452 + mydep = pn
453 + else:
454 + mydep = mydep.cp
455 + expanded = cpv_expand(mydep, mydb=mydb,
456 + use_cache=use_cache, settings=settings)
457 + return Atom(orig_dep.replace(mydep, expanded, 1))
458
459
460 Property changes on: main/trunk/pym/portage/dbapi/dep_expand.py
461 ___________________________________________________________________
462 Added: svn:keywords
463 + Id
464
465 Modified: main/trunk/pym/portage/dbapi/porttree.py
466 ===================================================================
467 --- main/trunk/pym/portage/dbapi/porttree.py 2010-02-25 20:40:13 UTC (rev 15459)
468 +++ main/trunk/pym/portage/dbapi/porttree.py 2010-02-25 20:42:04 UTC (rev 15460)
469 @@ -11,6 +11,7 @@
470 import portage
471 portage.proxy.lazyimport.lazyimport(globals(),
472 'portage.checksum',
473 + 'portage.dbapi.dep_expand:dep_expand',
474 'portage.dep:dep_getkey,flatten,match_from_list,paren_reduce,use_reduce',
475 'portage.env.loaders:KeyValuePairFileLoader',
476 'portage.package.ebuild.doebuild:doebuild',
477 @@ -30,7 +31,7 @@
478 from portage.manifest import Manifest
479
480 from portage import eclass_cache, auxdbkeys, \
481 - dep_expand, eapi_is_supported, dep_check, \
482 + eapi_is_supported, dep_check, \
483 _eapi_is_deprecated
484 from portage import os
485 from portage import _encodings
486
487 Modified: main/trunk/pym/portage/dbapi/vartree.py
488 ===================================================================
489 --- main/trunk/pym/portage/dbapi/vartree.py 2010-02-25 20:40:13 UTC (rev 15459)
490 +++ main/trunk/pym/portage/dbapi/vartree.py 2010-02-25 20:42:04 UTC (rev 15460)
491 @@ -11,6 +11,7 @@
492 import portage
493 portage.proxy.lazyimport.lazyimport(globals(),
494 'portage.checksum:_perform_md5_merge@perform_md5',
495 + 'portage.dbapi.dep_expand:dep_expand',
496 'portage.dep:dep_getkey,isjustname,flatten,match_from_list,' + \
497 'use_reduce,paren_reduce,_slot_re',
498 'portage.elog:elog_process',
499 @@ -39,8 +40,7 @@
500 FileNotFound, PermissionDenied, UnsupportedAPIException
501 from portage.localization import _
502
503 -from portage import dep_expand, \
504 - abssymlink, movefile, _movefile, bsd_chflags
505 +from portage import abssymlink, movefile, _movefile, bsd_chflags
506
507 # This is a special version of the os module, wrapped for unicode support.
508 from portage import os