Gentoo Archives: gentoo-commits

From: "Fabian Groffen (grobian)" <grobian@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r15482 - in main/branches/prefix: bin pym/_emerge pym/portage pym/portage/dbapi pym/portage/package/ebuild pym/portage/util
Date: Sat, 27 Feb 2010 19:26:06
Message-Id: E1NlSIb-0000o9-Ek@stork.gentoo.org
1 Author: grobian
2 Date: 2010-02-27 19:26:00 +0000 (Sat, 27 Feb 2010)
3 New Revision: 15482
4
5 Added:
6 main/branches/prefix/pym/portage/dbapi/cpv_expand.py
7 main/branches/prefix/pym/portage/dbapi/dep_expand.py
8 main/branches/prefix/pym/portage/package/ebuild/digestcheck.py
9 main/branches/prefix/pym/portage/package/ebuild/digestgen.py
10 Removed:
11 main/branches/prefix/pym/portage/util/digestgen.py
12 Modified:
13 main/branches/prefix/bin/quickpkg
14 main/branches/prefix/bin/repoman
15 main/branches/prefix/pym/_emerge/Scheduler.py
16 main/branches/prefix/pym/_emerge/actions.py
17 main/branches/prefix/pym/_emerge/depgraph.py
18 main/branches/prefix/pym/_emerge/main.py
19 main/branches/prefix/pym/portage/__init__.py
20 main/branches/prefix/pym/portage/dbapi/__init__.py
21 main/branches/prefix/pym/portage/dbapi/bintree.py
22 main/branches/prefix/pym/portage/dbapi/porttree.py
23 main/branches/prefix/pym/portage/dbapi/vartree.py
24 main/branches/prefix/pym/portage/package/ebuild/doebuild.py
25 Log:
26 Merged from trunk -r15455:15460
27
28 | 15456 | Relocate portage.util.digestgen to |
29 | zmedico | portage.package.ebuild.digestgen. |
30
31 | 15457 | Fix broken digestgen import. |
32 | zmedico | |
33
34 | 15458 | Move portage.digestcheck to |
35 | zmedico | portage.package.ebuild.digestcheck. |
36
37 | 15459 | Fix typo in import. |
38 | zmedico | |
39
40 | 15460 | Move dep_expand and cpv_expand into portage.dbapi |
41 | zmedico | submodules. |
42
43
44 Modified: main/branches/prefix/bin/quickpkg
45 ===================================================================
46 --- main/branches/prefix/bin/quickpkg 2010-02-27 19:21:09 UTC (rev 15481)
47 +++ main/branches/prefix/bin/quickpkg 2010-02-27 19:26:00 UTC (rev 15482)
48 @@ -20,7 +20,8 @@
49 from portage import os
50
51 def quickpkg_main(options, args, eout):
52 - from portage import catsplit, dep_expand, flatten, isvalidatom, xpak
53 + from portage import catsplit, flatten, isvalidatom, xpak
54 + from portage.dbapi.dep_expand import dep_expand
55 from portage.dep import use_reduce, paren_reduce
56 from portage.util import ConfigProtect, ensure_dirs
57 from portage.exception import InvalidAtom, InvalidData, InvalidDependString
58
59 Modified: main/branches/prefix/bin/repoman
60 ===================================================================
61 --- main/branches/prefix/bin/repoman 2010-02-27 19:21:09 UTC (rev 15481)
62 +++ main/branches/prefix/bin/repoman 2010-02-27 19:26:00 UTC (rev 15482)
63 @@ -75,7 +75,7 @@
64 green, nocolor, red, turquoise, yellow
65 from portage.output import ConsoleStyleFile, StyleWriter
66 from portage.util import cmp_sort_key, writemsg_level
67 -from portage.util.digestgen import digestgen
68 +from portage.package.ebuild.digestgen import digestgen
69
70 if sys.hexversion >= 0x3000000:
71 basestring = str
72
73 Modified: main/branches/prefix/pym/_emerge/Scheduler.py
74 ===================================================================
75 --- main/branches/prefix/pym/_emerge/Scheduler.py 2010-02-27 19:21:09 UTC (rev 15481)
76 +++ main/branches/prefix/pym/_emerge/Scheduler.py 2010-02-27 19:26:00 UTC (rev 15482)
77 @@ -24,7 +24,8 @@
78 from portage.sets import SETPREFIX
79 from portage.sets.base import InternalPackageSet
80 from portage.util import writemsg, writemsg_level
81 -from portage.util.digestgen import digestgen
82 +from portage.package.ebuild.digestcheck import digestcheck
83 +from portage.package.ebuild.digestgen import digestgen
84
85 from _emerge.BinpkgPrefetcher import BinpkgPrefetcher
86 from _emerge.Blocker import Blocker
87 @@ -638,7 +639,7 @@
88 if ebuild_path is None:
89 raise AssertionError("ebuild not found for '%s'" % x.cpv)
90 quiet_config["O"] = os.path.dirname(ebuild_path)
91 - if not portage.digestcheck([], quiet_config, strict=True):
92 + if not digestcheck([], quiet_config, strict=True):
93 failures |= 1
94
95 if failures:
96
97 Modified: main/branches/prefix/pym/_emerge/actions.py
98 ===================================================================
99 --- main/branches/prefix/pym/_emerge/actions.py 2010-02-27 19:21:09 UTC (rev 15481)
100 +++ main/branches/prefix/pym/_emerge/actions.py 2010-02-27 19:26:00 UTC (rev 15482)
101 @@ -27,6 +27,7 @@
102 from portage import _unicode_decode
103 from portage.cache.cache_errors import CacheError
104 from portage.const import NEWS_LIB_PATH, EPREFIX
105 +from portage.dbapi.dep_expand import dep_expand
106 from portage.output import blue, bold, colorize, create_color_func, darkgreen, \
107 red, yellow
108 good = create_color_func("GOOD")
109 @@ -2260,7 +2261,7 @@
110
111 try:
112 valid_atoms.append(
113 - portage.dep_expand(x, mydb=vardb, settings=settings))
114 + dep_expand(x, mydb=vardb, settings=settings))
115 except portage.exception.AmbiguousPackageName as e:
116 msg = "The short ebuild name \"" + x + \
117 "\" is ambiguous. Please specify " + \
118
119 Modified: main/branches/prefix/pym/_emerge/depgraph.py
120 ===================================================================
121 --- main/branches/prefix/pym/_emerge/depgraph.py 2010-02-27 19:21:09 UTC (rev 15481)
122 +++ main/branches/prefix/pym/_emerge/depgraph.py 2010-02-27 19:26:00 UTC (rev 15482)
123 @@ -15,6 +15,7 @@
124 from portage import os
125 from portage import digraph
126 from portage.dbapi import dbapi
127 +from portage.dbapi.dep_expand import dep_expand
128 from portage.dep import Atom
129 from portage.output import bold, blue, colorize, create_color_func, darkblue, \
130 darkgreen, green, nc_len, red, teal, turquoise, yellow
131 @@ -4160,7 +4161,7 @@
132 else:
133 blocker_style = "PKG_BLOCKER"
134 addl = "%s %s " % (colorize(blocker_style, "B"), fetch)
135 - resolved = portage.dep_expand(
136 + resolved = dep_expand(
137 str(x.atom).lstrip("!"), mydb=vardb, settings=pkgsettings)
138 if "--columns" in self._frozen_config.myopts and "--quiet" in self._frozen_config.myopts:
139 addl += " " + colorize(blocker_style, str(resolved))
140
141 Modified: main/branches/prefix/pym/_emerge/main.py
142 ===================================================================
143 --- main/branches/prefix/pym/_emerge/main.py 2010-02-27 19:21:09 UTC (rev 15481)
144 +++ main/branches/prefix/pym/_emerge/main.py 2010-02-27 19:26:00 UTC (rev 15482)
145 @@ -33,6 +33,7 @@
146 import portage.exception
147 from portage.const import EPREFIX, BPREFIX, EPREFIX_LSTRIP
148 from portage.data import secpass
149 +from portage.dbapi.dep_expand import dep_expand
150 from portage.util import normalize_path as normpath
151 from portage.util import writemsg, writemsg_level, writemsg_stdout
152 from portage.sets import SETPREFIX
153 @@ -1501,7 +1502,7 @@
154 if is_valid_package_atom(x):
155 try:
156 valid_atoms.append(
157 - portage.dep_expand(x, mydb=vardb, settings=settings))
158 + dep_expand(x, mydb=vardb, settings=settings))
159 except portage.exception.AmbiguousPackageName as e:
160 msg = "The short ebuild name \"" + x + \
161 "\" is ambiguous. Please specify " + \
162
163 Modified: main/branches/prefix/pym/portage/__init__.py
164 ===================================================================
165 --- main/branches/prefix/pym/portage/__init__.py 2010-02-27 19:21:09 UTC (rev 15481)
166 +++ main/branches/prefix/pym/portage/__init__.py 2010-02-27 19:26:00 UTC (rev 15482)
167 @@ -82,6 +82,8 @@
168 'uid,userland,userpriv_groups,wheelgid',
169 'portage.dbapi',
170 'portage.dbapi.bintree:bindbapi,binarytree',
171 + 'portage.dbapi.cpv_expand:cpv_expand',
172 + 'portage.dbapi.dep_expand:dep_expand',
173 'portage.dbapi.porttree:close_portdbapi_caches,FetchlistDict,' + \
174 'portagetree,portdbapi',
175 'portage.dbapi.vartree:vardbapi,vartree,dblink',
176 @@ -104,6 +106,8 @@
177 'doebuild_environment,spawn,spawnebuild',
178 'portage.package.ebuild.config:autouse,best_from_dict,' + \
179 'check_config_instance,config',
180 + 'portage.package.ebuild.digestcheck:digestcheck',
181 + 'portage.package.ebuild.digestgen:digestgen',
182 'portage.package.ebuild.fetch:fetch',
183 'portage.package.ebuild.prepare_build_dirs:prepare_build_dirs',
184 'portage.process',
185 @@ -119,7 +123,6 @@
186 'pickle_read,pickle_write,stack_dictlist,stack_dicts,' + \
187 'stack_lists,unique_array,varexpand,writedict,writemsg,' + \
188 'writemsg_stdout,write_atomic',
189 - 'portage.util.digestgen:digestgen',
190 'portage.util.digraph:digraph',
191 'portage.util.env_update:env_update',
192 'portage.util.ExtractKernelVersion:ExtractKernelVersion',
193 @@ -560,146 +563,6 @@
194
195 return Manifest(pkgdir, mysettings["DISTDIR"]).getDigests()
196
197 -def digestcheck(myfiles, mysettings, strict=0, justmanifest=0):
198 - """Verifies checksums. Assumes all files have been downloaded.
199 - DEPRECATED: this is now only a compability wrapper for
200 - portage.manifest.Manifest()."""
201 - if mysettings.get("EBUILD_SKIP_MANIFEST") == "1":
202 - return 1
203 - pkgdir = mysettings["O"]
204 - manifest_path = os.path.join(pkgdir, "Manifest")
205 - if not os.path.exists(manifest_path):
206 - writemsg(_("!!! Manifest file not found: '%s'\n") % manifest_path,
207 - noiselevel=-1)
208 - if strict:
209 - return 0
210 - else:
211 - return 1
212 - mf = Manifest(pkgdir, mysettings["DISTDIR"])
213 - manifest_empty = True
214 - for d in mf.fhashdict.values():
215 - if d:
216 - manifest_empty = False
217 - break
218 - if manifest_empty:
219 - writemsg(_("!!! Manifest is empty: '%s'\n") % manifest_path,
220 - noiselevel=-1)
221 - if strict:
222 - return 0
223 - else:
224 - return 1
225 - eout = portage.output.EOutput()
226 - eout.quiet = mysettings.get("PORTAGE_QUIET", None) == "1"
227 - try:
228 - if strict and "PORTAGE_PARALLEL_FETCHONLY" not in mysettings:
229 - eout.ebegin(_("checking ebuild checksums ;-)"))
230 - mf.checkTypeHashes("EBUILD")
231 - eout.eend(0)
232 - eout.ebegin(_("checking auxfile checksums ;-)"))
233 - mf.checkTypeHashes("AUX")
234 - eout.eend(0)
235 - eout.ebegin(_("checking miscfile checksums ;-)"))
236 - mf.checkTypeHashes("MISC", ignoreMissingFiles=True)
237 - eout.eend(0)
238 - for f in myfiles:
239 - eout.ebegin(_("checking %s ;-)") % f)
240 - ftype = mf.findFile(f)
241 - if ftype is None:
242 - raise KeyError(f)
243 - mf.checkFileHashes(ftype, f)
244 - eout.eend(0)
245 - except KeyError as e:
246 - eout.eend(1)
247 - writemsg(_("\n!!! Missing digest for %s\n") % str(e), noiselevel=-1)
248 - return 0
249 - except portage.exception.FileNotFound as e:
250 - eout.eend(1)
251 - writemsg(_("\n!!! A file listed in the Manifest could not be found: %s\n") % str(e),
252 - noiselevel=-1)
253 - return 0
254 - except portage.exception.DigestException as e:
255 - eout.eend(1)
256 - writemsg(_("\n!!! Digest verification failed:\n"), noiselevel=-1)
257 - writemsg("!!! %s\n" % e.value[0], noiselevel=-1)
258 - writemsg(_("!!! Reason: %s\n") % e.value[1], noiselevel=-1)
259 - writemsg(_("!!! Got: %s\n") % e.value[2], noiselevel=-1)
260 - writemsg(_("!!! Expected: %s\n") % e.value[3], noiselevel=-1)
261 - return 0
262 - # Make sure that all of the ebuilds are actually listed in the Manifest.
263 - glep55 = 'parse-eapi-glep-55' in mysettings.features
264 - for f in os.listdir(pkgdir):
265 - pf = None
266 - if glep55:
267 - pf, eapi = _split_ebuild_name_glep55(f)
268 - elif f[-7:] == '.ebuild':
269 - pf = f[:-7]
270 - if pf is not None and not mf.hasFile("EBUILD", f):
271 - writemsg(_("!!! A file is not listed in the Manifest: '%s'\n") % \
272 - os.path.join(pkgdir, f), noiselevel=-1)
273 - if strict:
274 - return 0
275 - """ epatch will just grab all the patches out of a directory, so we have to
276 - make sure there aren't any foreign files that it might grab."""
277 - filesdir = os.path.join(pkgdir, "files")
278 -
279 - for parent, dirs, files in os.walk(filesdir):
280 - try:
281 - parent = _unicode_decode(parent,
282 - encoding=_encodings['fs'], errors='strict')
283 - except UnicodeDecodeError:
284 - parent = _unicode_decode(parent,
285 - encoding=_encodings['fs'], errors='replace')
286 - writemsg(_("!!! Path contains invalid "
287 - "character(s) for encoding '%s': '%s'") \
288 - % (_encodings['fs'], parent), noiselevel=-1)
289 - if strict:
290 - return 0
291 - continue
292 - for d in dirs:
293 - d_bytes = d
294 - try:
295 - d = _unicode_decode(d,
296 - encoding=_encodings['fs'], errors='strict')
297 - except UnicodeDecodeError:
298 - d = _unicode_decode(d,
299 - encoding=_encodings['fs'], errors='replace')
300 - writemsg(_("!!! Path contains invalid "
301 - "character(s) for encoding '%s': '%s'") \
302 - % (_encodings['fs'], os.path.join(parent, d)),
303 - noiselevel=-1)
304 - if strict:
305 - return 0
306 - dirs.remove(d_bytes)
307 - continue
308 - if d.startswith(".") or d == "CVS":
309 - dirs.remove(d_bytes)
310 - for f in files:
311 - try:
312 - f = _unicode_decode(f,
313 - encoding=_encodings['fs'], errors='strict')
314 - except UnicodeDecodeError:
315 - f = _unicode_decode(f,
316 - encoding=_encodings['fs'], errors='replace')
317 - if f.startswith("."):
318 - continue
319 - f = os.path.join(parent, f)[len(filesdir) + 1:]
320 - writemsg(_("!!! File name contains invalid "
321 - "character(s) for encoding '%s': '%s'") \
322 - % (_encodings['fs'], f), noiselevel=-1)
323 - if strict:
324 - return 0
325 - continue
326 - if f.startswith("."):
327 - continue
328 - f = os.path.join(parent, f)[len(filesdir) + 1:]
329 - file_type = mf.findFile(f)
330 - if file_type != "AUX" and not f.startswith("digest-"):
331 - writemsg(_("!!! A file is not listed in the Manifest: '%s'\n") % \
332 - os.path.join(filesdir, f), noiselevel=-1)
333 - if strict:
334 - return 0
335 - return 1
336 -
337 _testing_eapis = frozenset()
338 _deprecated_eapis = frozenset(["3_pre2", "3_pre1", "2_pre3", "2_pre2", "2_pre1"])
339
340 @@ -1533,42 +1396,6 @@
341
342 assert(False) # This point should not be reachable
343
344 -def dep_expand(mydep, mydb=None, use_cache=1, settings=None):
345 - '''
346 - @rtype: Atom
347 - '''
348 - if not len(mydep):
349 - return mydep
350 - if mydep[0]=="*":
351 - mydep=mydep[1:]
352 - orig_dep = mydep
353 - if isinstance(orig_dep, dep.Atom):
354 - mydep = orig_dep.cp
355 - else:
356 - mydep = orig_dep
357 - has_cat = '/' in orig_dep
358 - if not has_cat:
359 - alphanum = re.search(r'\w', orig_dep)
360 - if alphanum:
361 - mydep = orig_dep[:alphanum.start()] + "null/" + \
362 - orig_dep[alphanum.start():]
363 - try:
364 - mydep = dep.Atom(mydep)
365 - except exception.InvalidAtom:
366 - # Missing '=' prefix is allowed for backward compatibility.
367 - if not dep.isvalidatom("=" + mydep):
368 - raise
369 - mydep = dep.Atom('=' + mydep)
370 - orig_dep = '=' + orig_dep
371 - if not has_cat:
372 - null_cat, pn = catsplit(mydep.cp)
373 - mydep = pn
374 - else:
375 - mydep = mydep.cp
376 - expanded = cpv_expand(mydep, mydb=mydb,
377 - use_cache=use_cache, settings=settings)
378 - return portage.dep.Atom(orig_dep.replace(mydep, expanded, 1))
379 -
380 def dep_check(depstring, mydbapi, mysettings, use="yes", mode=None, myuse=None,
381 use_cache=1, use_binaries=0, myroot="/", trees=None):
382 """Takes a depend string and parses the condition."""
383 @@ -1702,92 +1529,6 @@
384 return None
385 return deplist
386
387 -def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None):
388 - """Given a string (packagename or virtual) expand it into a valid
389 - cat/package string. Virtuals use the mydb to determine which provided
390 - virtual is a valid choice and defaults to the first element when there
391 - are no installed/available candidates."""
392 - myslash=mycpv.split("/")
393 - mysplit = versions._pkgsplit(myslash[-1])
394 - if settings is None:
395 - settings = globals()["settings"]
396 - virts = settings.getvirtuals()
397 - virts_p = settings.get_virts_p()
398 - if len(myslash)>2:
399 - # this is illegal case.
400 - mysplit=[]
401 - mykey=mycpv
402 - elif len(myslash)==2:
403 - if mysplit:
404 - mykey=myslash[0]+"/"+mysplit[0]
405 - else:
406 - mykey=mycpv
407 - if mydb and virts and mykey in virts:
408 - writemsg("mydb.__class__: %s\n" % (mydb.__class__), 1)
409 - if hasattr(mydb, "cp_list"):
410 - if not mydb.cp_list(mykey, use_cache=use_cache):
411 - writemsg("virts[%s]: %s\n" % (str(mykey),virts[mykey]), 1)
412 - mykey_orig = mykey[:]
413 - for vkey in virts[mykey]:
414 - # The virtuals file can contain a versioned atom, so
415 - # it may be necessary to remove the operator and
416 - # version from the atom before it is passed into
417 - # dbapi.cp_list().
418 - if mydb.cp_list(vkey.cp):
419 - mykey = str(vkey)
420 - writemsg(_("virts chosen: %s\n") % (mykey), 1)
421 - break
422 - if mykey == mykey_orig:
423 - mykey = str(virts[mykey][0])
424 - writemsg(_("virts defaulted: %s\n") % (mykey), 1)
425 - #we only perform virtual expansion if we are passed a dbapi
426 - else:
427 - #specific cpv, no category, ie. "foo-1.0"
428 - if mysplit:
429 - myp=mysplit[0]
430 - else:
431 - # "foo" ?
432 - myp=mycpv
433 - mykey=None
434 - matches=[]
435 - if mydb and hasattr(mydb, "categories"):
436 - for x in mydb.categories:
437 - if mydb.cp_list(x+"/"+myp,use_cache=use_cache):
438 - matches.append(x+"/"+myp)
439 - if len(matches) > 1:
440 - virtual_name_collision = False
441 - if len(matches) == 2:
442 - for x in matches:
443 - if not x.startswith("virtual/"):
444 - # Assume that the non-virtual is desired. This helps
445 - # avoid the ValueError for invalid deps that come from
446 - # installed packages (during reverse blocker detection,
447 - # for example).
448 - mykey = x
449 - else:
450 - virtual_name_collision = True
451 - if not virtual_name_collision:
452 - # AmbiguousPackageName inherits from ValueError,
453 - # for backward compatibility with calling code
454 - # that already handles ValueError.
455 - raise portage.exception.AmbiguousPackageName(matches)
456 - elif matches:
457 - mykey=matches[0]
458 -
459 - if not mykey and not isinstance(mydb, list):
460 - if myp in virts_p:
461 - mykey=virts_p[myp][0]
462 - #again, we only perform virtual expansion if we have a dbapi (not a list)
463 - if not mykey:
464 - mykey="null/"+myp
465 - if mysplit:
466 - if mysplit[2]=="r0":
467 - return mykey+"-"+mysplit[1]
468 - else:
469 - return mykey+"-"+mysplit[1]+"-"+mysplit[2]
470 - else:
471 - return mykey
472 -
473 def getmaskingreason(mycpv, metadata=None, settings=None, portdb=None, return_location=False):
474 from portage.util import grablines
475 if settings is None:
476
477 Modified: main/branches/prefix/pym/portage/dbapi/__init__.py
478 ===================================================================
479 --- main/branches/prefix/pym/portage/dbapi/__init__.py 2010-02-27 19:21:09 UTC (rev 15481)
480 +++ main/branches/prefix/pym/portage/dbapi/__init__.py 2010-02-27 19:26:00 UTC (rev 15482)
481 @@ -8,6 +8,7 @@
482
483 import portage
484 portage.proxy.lazyimport.lazyimport(globals(),
485 + 'portage.dbapi.dep_expand:dep_expand',
486 'portage.dep:match_from_list',
487 'portage.locks:unlockfile',
488 'portage.output:colorize',
489 @@ -16,7 +17,7 @@
490 )
491
492 from portage import os
493 -from portage import auxdbkeys, dep_expand
494 +from portage import auxdbkeys
495 from portage.localization import _
496
497 class dbapi(object):
498
499 Modified: main/branches/prefix/pym/portage/dbapi/bintree.py
500 ===================================================================
501 --- main/branches/prefix/pym/portage/dbapi/bintree.py 2010-02-27 19:21:09 UTC (rev 15481)
502 +++ main/branches/prefix/pym/portage/dbapi/bintree.py 2010-02-27 19:26:00 UTC (rev 15482)
503 @@ -8,6 +8,7 @@
504
505 import portage
506 portage.proxy.lazyimport.lazyimport(globals(),
507 + 'portage.dbapi.dep_expand:dep_expand',
508 'portage.dep:dep_getkey,isjustname,match_from_list',
509 'portage.output:EOutput,colorize',
510 'portage.package.ebuild.doebuild:_vdb_use_conditional_atoms',
511 @@ -24,7 +25,7 @@
512 from portage.const import EAPI
513 from portage.localization import _
514
515 -from portage import dep_expand, _movefile
516 +from portage import _movefile
517 from portage import os
518 from portage import _encodings
519 from portage import _unicode_decode
520
521 Copied: main/branches/prefix/pym/portage/dbapi/cpv_expand.py (from rev 15460, main/trunk/pym/portage/dbapi/cpv_expand.py)
522 ===================================================================
523 --- main/branches/prefix/pym/portage/dbapi/cpv_expand.py (rev 0)
524 +++ main/branches/prefix/pym/portage/dbapi/cpv_expand.py 2010-02-27 19:26:00 UTC (rev 15482)
525 @@ -0,0 +1,96 @@
526 +# Copyright 2010 Gentoo Foundation
527 +# Distributed under the terms of the GNU General Public License v2
528 +# $Id$
529 +
530 +__all__ = ["cpv_expand"]
531 +
532 +from portage.exception import AmbiguousPackageName
533 +from portage.localization import _
534 +from portage.util import writemsg
535 +from portage.versions import _pkgsplit
536 +
537 +def cpv_expand(mycpv, mydb=None, use_cache=1, settings=None):
538 + """Given a string (packagename or virtual) expand it into a valid
539 + cat/package string. Virtuals use the mydb to determine which provided
540 + virtual is a valid choice and defaults to the first element when there
541 + are no installed/available candidates."""
542 + myslash=mycpv.split("/")
543 + mysplit = _pkgsplit(myslash[-1])
544 + if settings is None:
545 + settings = globals()["settings"]
546 + virts = settings.getvirtuals()
547 + virts_p = settings.get_virts_p()
548 + if len(myslash)>2:
549 + # this is illegal case.
550 + mysplit=[]
551 + mykey=mycpv
552 + elif len(myslash)==2:
553 + if mysplit:
554 + mykey=myslash[0]+"/"+mysplit[0]
555 + else:
556 + mykey=mycpv
557 + if mydb and virts and mykey in virts:
558 + writemsg("mydb.__class__: %s\n" % (mydb.__class__), 1)
559 + if hasattr(mydb, "cp_list"):
560 + if not mydb.cp_list(mykey, use_cache=use_cache):
561 + writemsg("virts[%s]: %s\n" % (str(mykey),virts[mykey]), 1)
562 + mykey_orig = mykey[:]
563 + for vkey in virts[mykey]:
564 + # The virtuals file can contain a versioned atom, so
565 + # it may be necessary to remove the operator and
566 + # version from the atom before it is passed into
567 + # dbapi.cp_list().
568 + if mydb.cp_list(vkey.cp):
569 + mykey = str(vkey)
570 + writemsg(_("virts chosen: %s\n") % (mykey), 1)
571 + break
572 + if mykey == mykey_orig:
573 + mykey = str(virts[mykey][0])
574 + writemsg(_("virts defaulted: %s\n") % (mykey), 1)
575 + #we only perform virtual expansion if we are passed a dbapi
576 + else:
577 + #specific cpv, no category, ie. "foo-1.0"
578 + if mysplit:
579 + myp=mysplit[0]
580 + else:
581 + # "foo" ?
582 + myp=mycpv
583 + mykey=None
584 + matches=[]
585 + if mydb and hasattr(mydb, "categories"):
586 + for x in mydb.categories:
587 + if mydb.cp_list(x+"/"+myp,use_cache=use_cache):
588 + matches.append(x+"/"+myp)
589 + if len(matches) > 1:
590 + virtual_name_collision = False
591 + if len(matches) == 2:
592 + for x in matches:
593 + if not x.startswith("virtual/"):
594 + # Assume that the non-virtual is desired. This helps
595 + # avoid the ValueError for invalid deps that come from
596 + # installed packages (during reverse blocker detection,
597 + # for example).
598 + mykey = x
599 + else:
600 + virtual_name_collision = True
601 + if not virtual_name_collision:
602 + # AmbiguousPackageName inherits from ValueError,
603 + # for backward compatibility with calling code
604 + # that already handles ValueError.
605 + raise AmbiguousPackageName(matches)
606 + elif matches:
607 + mykey=matches[0]
608 +
609 + if not mykey and not isinstance(mydb, list):
610 + if myp in virts_p:
611 + mykey=virts_p[myp][0]
612 + #again, we only perform virtual expansion if we have a dbapi (not a list)
613 + if not mykey:
614 + mykey="null/"+myp
615 + if mysplit:
616 + if mysplit[2]=="r0":
617 + return mykey+"-"+mysplit[1]
618 + else:
619 + return mykey+"-"+mysplit[1]+"-"+mysplit[2]
620 + else:
621 + return mykey
622
623 Copied: main/branches/prefix/pym/portage/dbapi/dep_expand.py (from rev 15460, main/trunk/pym/portage/dbapi/dep_expand.py)
624 ===================================================================
625 --- main/branches/prefix/pym/portage/dbapi/dep_expand.py (rev 0)
626 +++ main/branches/prefix/pym/portage/dbapi/dep_expand.py 2010-02-27 19:26:00 UTC (rev 15482)
627 @@ -0,0 +1,48 @@
628 +# Copyright 2010 Gentoo Foundation
629 +# Distributed under the terms of the GNU General Public License v2
630 +# $Id$
631 +
632 +__all__ = ["dep_expand"]
633 +
634 +import re
635 +
636 +from portage.dbapi.cpv_expand import cpv_expand
637 +from portage.dep import Atom, isvalidatom
638 +from portage.exception import InvalidAtom
639 +from portage.versions import catsplit
640 +
641 +def dep_expand(mydep, mydb=None, use_cache=1, settings=None):
642 + '''
643 + @rtype: Atom
644 + '''
645 + if not len(mydep):
646 + return mydep
647 + if mydep[0]=="*":
648 + mydep=mydep[1:]
649 + orig_dep = mydep
650 + if isinstance(orig_dep, Atom):
651 + mydep = orig_dep.cp
652 + else:
653 + mydep = orig_dep
654 + has_cat = '/' in orig_dep
655 + if not has_cat:
656 + alphanum = re.search(r'\w', orig_dep)
657 + if alphanum:
658 + mydep = orig_dep[:alphanum.start()] + "null/" + \
659 + orig_dep[alphanum.start():]
660 + try:
661 + mydep = Atom(mydep)
662 + except InvalidAtom:
663 + # Missing '=' prefix is allowed for backward compatibility.
664 + if not isvalidatom("=" + mydep):
665 + raise
666 + mydep = Atom('=' + mydep)
667 + orig_dep = '=' + orig_dep
668 + if not has_cat:
669 + null_cat, pn = catsplit(mydep.cp)
670 + mydep = pn
671 + else:
672 + mydep = mydep.cp
673 + expanded = cpv_expand(mydep, mydb=mydb,
674 + use_cache=use_cache, settings=settings)
675 + return Atom(orig_dep.replace(mydep, expanded, 1))
676
677 Modified: main/branches/prefix/pym/portage/dbapi/porttree.py
678 ===================================================================
679 --- main/branches/prefix/pym/portage/dbapi/porttree.py 2010-02-27 19:21:09 UTC (rev 15481)
680 +++ main/branches/prefix/pym/portage/dbapi/porttree.py 2010-02-27 19:26:00 UTC (rev 15482)
681 @@ -11,6 +11,7 @@
682 import portage
683 portage.proxy.lazyimport.lazyimport(globals(),
684 'portage.checksum',
685 + 'portage.dbapi.dep_expand:dep_expand',
686 'portage.dep:dep_getkey,flatten,match_from_list,paren_reduce,use_reduce',
687 'portage.env.loaders:KeyValuePairFileLoader',
688 'portage.package.ebuild.doebuild:doebuild',
689 @@ -30,7 +31,7 @@
690 from portage.manifest import Manifest
691
692 from portage import eclass_cache, auxdbkeys, \
693 - dep_expand, eapi_is_supported, dep_check, \
694 + eapi_is_supported, dep_check, \
695 _eapi_is_deprecated
696 from portage import os
697 from portage import _encodings
698
699 Modified: main/branches/prefix/pym/portage/dbapi/vartree.py
700 ===================================================================
701 --- main/branches/prefix/pym/portage/dbapi/vartree.py 2010-02-27 19:21:09 UTC (rev 15481)
702 +++ main/branches/prefix/pym/portage/dbapi/vartree.py 2010-02-27 19:26:00 UTC (rev 15482)
703 @@ -12,6 +12,7 @@
704 import portage
705 portage.proxy.lazyimport.lazyimport(globals(),
706 'portage.checksum:_perform_md5_merge@perform_md5',
707 + 'portage.dbapi.dep_expand:dep_expand',
708 'portage.dep:dep_getkey,isjustname,flatten,match_from_list,' + \
709 'use_reduce,paren_reduce,_slot_re',
710 'portage.elog:elog_process',
711 @@ -40,8 +41,7 @@
712 FileNotFound, PermissionDenied, UnsupportedAPIException
713 from portage.localization import _
714
715 -from portage import dep_expand, \
716 - abssymlink, movefile, _movefile, bsd_chflags
717 +from portage import abssymlink, movefile, _movefile, bsd_chflags
718
719 # This is a special version of the os module, wrapped for unicode support.
720 from portage import os
721
722 Copied: main/branches/prefix/pym/portage/package/ebuild/digestcheck.py (from rev 15460, main/trunk/pym/portage/package/ebuild/digestcheck.py)
723 ===================================================================
724 --- main/branches/prefix/pym/portage/package/ebuild/digestcheck.py (rev 0)
725 +++ main/branches/prefix/pym/portage/package/ebuild/digestcheck.py 2010-02-27 19:26:00 UTC (rev 15482)
726 @@ -0,0 +1,154 @@
727 +# Copyright 2010 Gentoo Foundation
728 +# Distributed under the terms of the GNU General Public License v2
729 +# $Id$
730 +
731 +__all__ = ['digestcheck']
732 +
733 +from portage import os, _encodings, _split_ebuild_name_glep55, _unicode_decode
734 +from portage.exception import DigestException, FileNotFound
735 +from portage.localization import _
736 +from portage.manifest import Manifest
737 +from portage.output import EOutput
738 +from portage.util import writemsg
739 +
740 +def digestcheck(myfiles, mysettings, strict=0, justmanifest=0):
741 + """
742 + Verifies checksums. Assumes all files have been downloaded.
743 + @rtype: int
744 + @returns: 1 on success and 0 on failure
745 + """
746 + if mysettings.get("EBUILD_SKIP_MANIFEST") == "1":
747 + return 1
748 + pkgdir = mysettings["O"]
749 + manifest_path = os.path.join(pkgdir, "Manifest")
750 + if not os.path.exists(manifest_path):
751 + writemsg(_("!!! Manifest file not found: '%s'\n") % manifest_path,
752 + noiselevel=-1)
753 + if strict:
754 + return 0
755 + else:
756 + return 1
757 + mf = Manifest(pkgdir, mysettings["DISTDIR"])
758 + manifest_empty = True
759 + for d in mf.fhashdict.values():
760 + if d:
761 + manifest_empty = False
762 + break
763 + if manifest_empty:
764 + writemsg(_("!!! Manifest is empty: '%s'\n") % manifest_path,
765 + noiselevel=-1)
766 + if strict:
767 + return 0
768 + else:
769 + return 1
770 + eout = EOutput()
771 + eout.quiet = mysettings.get("PORTAGE_QUIET", None) == "1"
772 + try:
773 + if strict and "PORTAGE_PARALLEL_FETCHONLY" not in mysettings:
774 + eout.ebegin(_("checking ebuild checksums ;-)"))
775 + mf.checkTypeHashes("EBUILD")
776 + eout.eend(0)
777 + eout.ebegin(_("checking auxfile checksums ;-)"))
778 + mf.checkTypeHashes("AUX")
779 + eout.eend(0)
780 + eout.ebegin(_("checking miscfile checksums ;-)"))
781 + mf.checkTypeHashes("MISC", ignoreMissingFiles=True)
782 + eout.eend(0)
783 + for f in myfiles:
784 + eout.ebegin(_("checking %s ;-)") % f)
785 + ftype = mf.findFile(f)
786 + if ftype is None:
787 + raise KeyError(f)
788 + mf.checkFileHashes(ftype, f)
789 + eout.eend(0)
790 + except KeyError as e:
791 + eout.eend(1)
792 + writemsg(_("\n!!! Missing digest for %s\n") % str(e), noiselevel=-1)
793 + return 0
794 + except FileNotFound as e:
795 + eout.eend(1)
796 + writemsg(_("\n!!! A file listed in the Manifest could not be found: %s\n") % str(e),
797 + noiselevel=-1)
798 + return 0
799 + except DigestException as e:
800 + eout.eend(1)
801 + writemsg(_("\n!!! Digest verification failed:\n"), noiselevel=-1)
802 + writemsg("!!! %s\n" % e.value[0], noiselevel=-1)
803 + writemsg(_("!!! Reason: %s\n") % e.value[1], noiselevel=-1)
804 + writemsg(_("!!! Got: %s\n") % e.value[2], noiselevel=-1)
805 + writemsg(_("!!! Expected: %s\n") % e.value[3], noiselevel=-1)
806 + return 0
807 + # Make sure that all of the ebuilds are actually listed in the Manifest.
808 + glep55 = 'parse-eapi-glep-55' in mysettings.features
809 + for f in os.listdir(pkgdir):
810 + pf = None
811 + if glep55:
812 + pf, eapi = _split_ebuild_name_glep55(f)
813 + elif f[-7:] == '.ebuild':
814 + pf = f[:-7]
815 + if pf is not None and not mf.hasFile("EBUILD", f):
816 + writemsg(_("!!! A file is not listed in the Manifest: '%s'\n") % \
817 + os.path.join(pkgdir, f), noiselevel=-1)
818 + if strict:
819 + return 0
820 + """ epatch will just grab all the patches out of a directory, so we have to
821 + make sure there aren't any foreign files that it might grab."""
822 + filesdir = os.path.join(pkgdir, "files")
823 +
824 + for parent, dirs, files in os.walk(filesdir):
825 + try:
826 + parent = _unicode_decode(parent,
827 + encoding=_encodings['fs'], errors='strict')
828 + except UnicodeDecodeError:
829 + parent = _unicode_decode(parent,
830 + encoding=_encodings['fs'], errors='replace')
831 + writemsg(_("!!! Path contains invalid "
832 + "character(s) for encoding '%s': '%s'") \
833 + % (_encodings['fs'], parent), noiselevel=-1)
834 + if strict:
835 + return 0
836 + continue
837 + for d in dirs:
838 + d_bytes = d
839 + try:
840 + d = _unicode_decode(d,
841 + encoding=_encodings['fs'], errors='strict')
842 + except UnicodeDecodeError:
843 + d = _unicode_decode(d,
844 + encoding=_encodings['fs'], errors='replace')
845 + writemsg(_("!!! Path contains invalid "
846 + "character(s) for encoding '%s': '%s'") \
847 + % (_encodings['fs'], os.path.join(parent, d)),
848 + noiselevel=-1)
849 + if strict:
850 + return 0
851 + dirs.remove(d_bytes)
852 + continue
853 + if d.startswith(".") or d == "CVS":
854 + dirs.remove(d_bytes)
855 + for f in files:
856 + try:
857 + f = _unicode_decode(f,
858 + encoding=_encodings['fs'], errors='strict')
859 + except UnicodeDecodeError:
860 + f = _unicode_decode(f,
861 + encoding=_encodings['fs'], errors='replace')
862 + if f.startswith("."):
863 + continue
864 + f = os.path.join(parent, f)[len(filesdir) + 1:]
865 + writemsg(_("!!! File name contains invalid "
866 + "character(s) for encoding '%s': '%s'") \
867 + % (_encodings['fs'], f), noiselevel=-1)
868 + if strict:
869 + return 0
870 + continue
871 + if f.startswith("."):
872 + continue
873 + f = os.path.join(parent, f)[len(filesdir) + 1:]
874 + file_type = mf.findFile(f)
875 + if file_type != "AUX" and not f.startswith("digest-"):
876 + writemsg(_("!!! A file is not listed in the Manifest: '%s'\n") % \
877 + os.path.join(filesdir, f), noiselevel=-1)
878 + if strict:
879 + return 0
880 + return 1
881
882 Copied: main/branches/prefix/pym/portage/package/ebuild/digestgen.py (from rev 15460, main/trunk/pym/portage/package/ebuild/digestgen.py)
883 ===================================================================
884 --- main/branches/prefix/pym/portage/package/ebuild/digestgen.py (rev 0)
885 +++ main/branches/prefix/pym/portage/package/ebuild/digestgen.py 2010-02-27 19:26:00 UTC (rev 15482)
886 @@ -0,0 +1,204 @@
887 +# Copyright 2010 Gentoo Foundation
888 +# Distributed under the terms of the GNU General Public License v2
889 +# $Id$
890 +
891 +__all__ = ['digestgen']
892 +
893 +import errno
894 +import warnings
895 +
896 +import portage
897 +portage.proxy.lazyimport.lazyimport(globals(),
898 + 'portage.package.ebuild.doebuild:doebuild_environment',
899 +)
900 +
901 +from portage import os
902 +from portage.const import MANIFEST2_REQUIRED_HASH
903 +from portage.dbapi.porttree import FetchlistDict
904 +from portage.exception import InvalidDependString, FileNotFound, \
905 + PermissionDenied, PortagePackageException
906 +from portage.localization import _
907 +from portage.manifest import Manifest
908 +from portage.output import colorize
909 +from portage.package.ebuild.config import config
910 +from portage.package.ebuild.fetch import fetch
911 +from portage.util import writemsg, writemsg_stdout
912 +from portage.versions import catsplit
913 +
914 +def digestgen(myarchives=None, mysettings=None,
915 + overwrite=None, manifestonly=None, myportdb=None):
916 + """
917 + Generates a digest file if missing. Fetches files if necessary.
918 + NOTE: myarchives and mysettings used to be positional arguments,
919 + so their order must be preserved for backward compatibility.
920 + @param mysettings: the ebuild config (mysettings["O"] must correspond
921 + to the ebuild's parent directory)
922 + @type mysettings: config
923 + @param myportdb: a portdbapi instance
924 + @type myportdb: portdbapi
925 + @rtype: int
926 + @returns: 1 on success and 0 on failure
927 + """
928 + if mysettings is None:
929 + raise TypeError("portage.digestgen(): missing" + \
930 + " required 'mysettings' parameter")
931 + if myportdb is None:
932 + warnings.warn("portage.digestgen() called without 'myportdb' parameter",
933 + DeprecationWarning, stacklevel=2)
934 + myportdb = portage.portdb
935 + if overwrite is not None:
936 + warnings.warn("portage.digestgen() called with " + \
937 + "deprecated 'overwrite' parameter",
938 + DeprecationWarning, stacklevel=2)
939 + if manifestonly is not None:
940 + warnings.warn("portage.digestgen() called with " + \
941 + "deprecated 'manifestonly' parameter",
942 + DeprecationWarning, stacklevel=2)
943 +
944 + try:
945 + portage._doebuild_manifest_exempt_depend += 1
946 + distfiles_map = {}
947 + fetchlist_dict = FetchlistDict(mysettings["O"], mysettings, myportdb)
948 + for cpv in fetchlist_dict:
949 + try:
950 + for myfile in fetchlist_dict[cpv]:
951 + distfiles_map.setdefault(myfile, []).append(cpv)
952 + except InvalidDependString as e:
953 + writemsg("!!! %s\n" % str(e), noiselevel=-1)
954 + del e
955 + return 0
956 + mytree = os.path.dirname(os.path.dirname(mysettings["O"]))
957 + manifest1_compat = False
958 + mf = Manifest(mysettings["O"], mysettings["DISTDIR"],
959 + fetchlist_dict=fetchlist_dict, manifest1_compat=manifest1_compat)
960 + # Don't require all hashes since that can trigger excessive
961 + # fetches when sufficient digests already exist. To ease transition
962 + # while Manifest 1 is being removed, only require hashes that will
963 + # exist before and after the transition.
964 + required_hash_types = set()
965 + required_hash_types.add("size")
966 + required_hash_types.add(MANIFEST2_REQUIRED_HASH)
967 + dist_hashes = mf.fhashdict.get("DIST", {})
968 +
969 + # To avoid accidental regeneration of digests with the incorrect
970 + # files (such as partially downloaded files), trigger the fetch
971 + # code if the file exists and it's size doesn't match the current
972 + # manifest entry. If there really is a legitimate reason for the
973 + # digest to change, `ebuild --force digest` can be used to avoid
974 + # triggering this code (or else the old digests can be manually
975 + # removed from the Manifest).
976 + missing_files = []
977 + for myfile in distfiles_map:
978 + myhashes = dist_hashes.get(myfile)
979 + if not myhashes:
980 + try:
981 + st = os.stat(os.path.join(mysettings["DISTDIR"], myfile))
982 + except OSError:
983 + st = None
984 + if st is None or st.st_size == 0:
985 + missing_files.append(myfile)
986 + continue
987 + size = myhashes.get("size")
988 +
989 + try:
990 + st = os.stat(os.path.join(mysettings["DISTDIR"], myfile))
991 + except OSError as e:
992 + if e.errno != errno.ENOENT:
993 + raise
994 + del e
995 + if size == 0:
996 + missing_files.append(myfile)
997 + continue
998 + if required_hash_types.difference(myhashes):
999 + missing_files.append(myfile)
1000 + continue
1001 + else:
1002 + if st.st_size == 0 or size is not None and size != st.st_size:
1003 + missing_files.append(myfile)
1004 + continue
1005 +
1006 + if missing_files:
1007 + mytree = os.path.realpath(os.path.dirname(
1008 + os.path.dirname(mysettings["O"])))
1009 + fetch_settings = config(clone=mysettings)
1010 + debug = mysettings.get("PORTAGE_DEBUG") == "1"
1011 + for myfile in missing_files:
1012 + uris = set()
1013 + for cpv in distfiles_map[myfile]:
1014 + myebuild = os.path.join(mysettings["O"],
1015 + catsplit(cpv)[1] + ".ebuild")
1016 + # for RESTRICT=fetch, mirror, etc...
1017 + doebuild_environment(myebuild, "fetch",
1018 + mysettings["ROOT"], fetch_settings,
1019 + debug, 1, myportdb)
1020 + uris.update(myportdb.getFetchMap(
1021 + cpv, mytree=mytree)[myfile])
1022 +
1023 + fetch_settings["A"] = myfile # for use by pkg_nofetch()
1024 +
1025 + try:
1026 + st = os.stat(os.path.join(
1027 + mysettings["DISTDIR"],myfile))
1028 + except OSError:
1029 + st = None
1030 +
1031 + if not fetch({myfile : uris}, fetch_settings):
1032 + writemsg(_("!!! Fetch failed for %s, can't update "
1033 + "Manifest\n") % myfile, noiselevel=-1)
1034 + if myfile in dist_hashes and \
1035 + st is not None and st.st_size > 0:
1036 + # stat result is obtained before calling fetch(),
1037 + # since fetch may rename the existing file if the
1038 + # digest does not match.
1039 + writemsg(_("!!! If you would like to "
1040 + "forcefully replace the existing "
1041 + "Manifest entry\n!!! for %s, use "
1042 + "the following command:\n") % myfile + \
1043 + "!!! " + colorize("INFORM",
1044 + "ebuild --force %s manifest" % \
1045 + os.path.basename(myebuild)) + "\n",
1046 + noiselevel=-1)
1047 + return 0
1048 + writemsg_stdout(_(">>> Creating Manifest for %s\n") % mysettings["O"])
1049 + try:
1050 + mf.create(assumeDistHashesSometimes=True,
1051 + assumeDistHashesAlways=(
1052 + "assume-digests" in mysettings.features))
1053 + except FileNotFound as e:
1054 + writemsg(_("!!! File %s doesn't exist, can't update "
1055 + "Manifest\n") % e, noiselevel=-1)
1056 + return 0
1057 + except PortagePackageException as e:
1058 + writemsg(("!!! %s\n") % (e,), noiselevel=-1)
1059 + return 0
1060 + try:
1061 + mf.write(sign=False)
1062 + except PermissionDenied as e:
1063 + writemsg(_("!!! Permission Denied: %s\n") % (e,), noiselevel=-1)
1064 + return 0
1065 + if "assume-digests" not in mysettings.features:
1066 + distlist = list(mf.fhashdict.get("DIST", {}))
1067 + distlist.sort()
1068 + auto_assumed = []
1069 + for filename in distlist:
1070 + if not os.path.exists(
1071 + os.path.join(mysettings["DISTDIR"], filename)):
1072 + auto_assumed.append(filename)
1073 + if auto_assumed:
1074 + mytree = os.path.realpath(
1075 + os.path.dirname(os.path.dirname(mysettings["O"])))
1076 + cp = os.path.sep.join(mysettings["O"].split(os.path.sep)[-2:])
1077 + pkgs = myportdb.cp_list(cp, mytree=mytree)
1078 + pkgs.sort()
1079 + writemsg_stdout(" digest.assumed" + colorize("WARN",
1080 + str(len(auto_assumed)).rjust(18)) + "\n")
1081 + for pkg_key in pkgs:
1082 + fetchlist = myportdb.getFetchMap(pkg_key, mytree=mytree)
1083 + pv = pkg_key.split("/")[1]
1084 + for filename in auto_assumed:
1085 + if filename in fetchlist:
1086 + writemsg_stdout(
1087 + " %s::%s\n" % (pv, filename))
1088 + return 1
1089 + finally:
1090 + portage._doebuild_manifest_exempt_depend -= 1
1091
1092 Modified: main/branches/prefix/pym/portage/package/ebuild/doebuild.py
1093 ===================================================================
1094 --- main/branches/prefix/pym/portage/package/ebuild/doebuild.py 2010-02-27 19:21:09 UTC (rev 15481)
1095 +++ main/branches/prefix/pym/portage/package/ebuild/doebuild.py 2010-02-27 19:26:00 UTC (rev 15482)
1096 @@ -21,11 +21,12 @@
1097 import portage
1098 portage.proxy.lazyimport.lazyimport(globals(),
1099 'portage.package.ebuild.config:check_config_instance',
1100 - 'portage.util.digestgen:digestgen',
1101 + 'portage.package.ebuild.digestcheck:digestcheck',
1102 + 'portage.package.ebuild.digestgen:digestgen',
1103 'portage.util.ExtractKernelVersion:ExtractKernelVersion'
1104 )
1105
1106 -from portage import auxdbkeys, bsd_chflags, dep_check, digestcheck, \
1107 +from portage import auxdbkeys, bsd_chflags, dep_check, \
1108 eapi_is_supported, merge, os, selinux, StringIO, \
1109 unmerge, _encodings, _parse_eapi_ebuild_head, _os_merge, \
1110 _shell_quote, _split_ebuild_name_glep55, _unicode_decode, _unicode_encode
1111
1112 Deleted: main/branches/prefix/pym/portage/util/digestgen.py
1113 ===================================================================
1114 --- main/branches/prefix/pym/portage/util/digestgen.py 2010-02-27 19:21:09 UTC (rev 15481)
1115 +++ main/branches/prefix/pym/portage/util/digestgen.py 2010-02-27 19:26:00 UTC (rev 15482)
1116 @@ -1,204 +0,0 @@
1117 -# Copyright 2010 Gentoo Foundation
1118 -# Distributed under the terms of the GNU General Public License v2
1119 -# $Id$
1120 -
1121 -__all__ = ['digestgen']
1122 -
1123 -import errno
1124 -import warnings
1125 -
1126 -import portage
1127 -portage.proxy.lazyimport.lazyimport(globals(),
1128 - 'portage.package.ebuild.doebuild:doebuild_environment',
1129 -)
1130 -
1131 -from portage import os
1132 -from portage.const import MANIFEST2_REQUIRED_HASH
1133 -from portage.dbapi.porttree import FetchlistDict
1134 -from portage.exception import InvalidDependString, FileNotFound, \
1135 - PermissionDenied, PortagePackageException
1136 -from portage.localization import _
1137 -from portage.manifest import Manifest
1138 -from portage.output import colorize
1139 -from portage.package.ebuild.config import config
1140 -from portage.package.ebuild.fetch import fetch
1141 -from portage.util import writemsg, writemsg_stdout
1142 -from portage.versions import catsplit
1143 -
1144 -def digestgen(myarchives=None, mysettings=None,
1145 - overwrite=None, manifestonly=None, myportdb=None):
1146 - """
1147 - Generates a digest file if missing. Fetches files if necessary.
1148 - NOTE: myarchives and mysettings used to be positional arguments,
1149 - so their order must be preserved for backward compatibility.
1150 - @param mysettings: the ebuild config (mysettings["O"] must correspond
1151 - to the ebuild's parent directory)
1152 - @type mysettings: config
1153 - @param myportdb: a portdbapi instance
1154 - @type myportdb: portdbapi
1155 - @rtype: int
1156 - @returns: 1 on success and 0 on failure
1157 - """
1158 - if mysettings is None:
1159 - raise TypeError("portage.digestgen(): missing" + \
1160 - " required 'mysettings' parameter")
1161 - if myportdb is None:
1162 - warnings.warn("portage.digestgen() called without 'myportdb' parameter",
1163 - DeprecationWarning, stacklevel=2)
1164 - myportdb = portage.portdb
1165 - if overwrite is not None:
1166 - warnings.warn("portage.digestgen() called with " + \
1167 - "deprecated 'overwrite' parameter",
1168 - DeprecationWarning, stacklevel=2)
1169 - if manifestonly is not None:
1170 - warnings.warn("portage.digestgen() called with " + \
1171 - "deprecated 'manifestonly' parameter",
1172 - DeprecationWarning, stacklevel=2)
1173 -
1174 - try:
1175 - portage._doebuild_manifest_exempt_depend += 1
1176 - distfiles_map = {}
1177 - fetchlist_dict = FetchlistDict(mysettings["O"], mysettings, myportdb)
1178 - for cpv in fetchlist_dict:
1179 - try:
1180 - for myfile in fetchlist_dict[cpv]:
1181 - distfiles_map.setdefault(myfile, []).append(cpv)
1182 - except InvalidDependString as e:
1183 - writemsg("!!! %s\n" % str(e), noiselevel=-1)
1184 - del e
1185 - return 0
1186 - mytree = os.path.dirname(os.path.dirname(mysettings["O"]))
1187 - manifest1_compat = False
1188 - mf = Manifest(mysettings["O"], mysettings["DISTDIR"],
1189 - fetchlist_dict=fetchlist_dict, manifest1_compat=manifest1_compat)
1190 - # Don't require all hashes since that can trigger excessive
1191 - # fetches when sufficient digests already exist. To ease transition
1192 - # while Manifest 1 is being removed, only require hashes that will
1193 - # exist before and after the transition.
1194 - required_hash_types = set()
1195 - required_hash_types.add("size")
1196 - required_hash_types.add(MANIFEST2_REQUIRED_HASH)
1197 - dist_hashes = mf.fhashdict.get("DIST", {})
1198 -
1199 - # To avoid accidental regeneration of digests with the incorrect
1200 - # files (such as partially downloaded files), trigger the fetch
1201 - # code if the file exists and it's size doesn't match the current
1202 - # manifest entry. If there really is a legitimate reason for the
1203 - # digest to change, `ebuild --force digest` can be used to avoid
1204 - # triggering this code (or else the old digests can be manually
1205 - # removed from the Manifest).
1206 - missing_files = []
1207 - for myfile in distfiles_map:
1208 - myhashes = dist_hashes.get(myfile)
1209 - if not myhashes:
1210 - try:
1211 - st = os.stat(os.path.join(mysettings["DISTDIR"], myfile))
1212 - except OSError:
1213 - st = None
1214 - if st is None or st.st_size == 0:
1215 - missing_files.append(myfile)
1216 - continue
1217 - size = myhashes.get("size")
1218 -
1219 - try:
1220 - st = os.stat(os.path.join(mysettings["DISTDIR"], myfile))
1221 - except OSError as e:
1222 - if e.errno != errno.ENOENT:
1223 - raise
1224 - del e
1225 - if size == 0:
1226 - missing_files.append(myfile)
1227 - continue
1228 - if required_hash_types.difference(myhashes):
1229 - missing_files.append(myfile)
1230 - continue
1231 - else:
1232 - if st.st_size == 0 or size is not None and size != st.st_size:
1233 - missing_files.append(myfile)
1234 - continue
1235 -
1236 - if missing_files:
1237 - mytree = os.path.realpath(os.path.dirname(
1238 - os.path.dirname(mysettings["O"])))
1239 - fetch_settings = config(clone=mysettings)
1240 - debug = mysettings.get("PORTAGE_DEBUG") == "1"
1241 - for myfile in missing_files:
1242 - uris = set()
1243 - for cpv in distfiles_map[myfile]:
1244 - myebuild = os.path.join(mysettings["O"],
1245 - catsplit(cpv)[1] + ".ebuild")
1246 - # for RESTRICT=fetch, mirror, etc...
1247 - doebuild_environment(myebuild, "fetch",
1248 - mysettings["ROOT"], fetch_settings,
1249 - debug, 1, myportdb)
1250 - uris.update(myportdb.getFetchMap(
1251 - cpv, mytree=mytree)[myfile])
1252 -
1253 - fetch_settings["A"] = myfile # for use by pkg_nofetch()
1254 -
1255 - try:
1256 - st = os.stat(os.path.join(
1257 - mysettings["DISTDIR"],myfile))
1258 - except OSError:
1259 - st = None
1260 -
1261 - if not fetch({myfile : uris}, fetch_settings):
1262 - writemsg(_("!!! Fetch failed for %s, can't update "
1263 - "Manifest\n") % myfile, noiselevel=-1)
1264 - if myfile in dist_hashes and \
1265 - st is not None and st.st_size > 0:
1266 - # stat result is obtained before calling fetch(),
1267 - # since fetch may rename the existing file if the
1268 - # digest does not match.
1269 - writemsg(_("!!! If you would like to "
1270 - "forcefully replace the existing "
1271 - "Manifest entry\n!!! for %s, use "
1272 - "the following command:\n") % myfile + \
1273 - "!!! " + colorize("INFORM",
1274 - "ebuild --force %s manifest" % \
1275 - os.path.basename(myebuild)) + "\n",
1276 - noiselevel=-1)
1277 - return 0
1278 - writemsg_stdout(_(">>> Creating Manifest for %s\n") % mysettings["O"])
1279 - try:
1280 - mf.create(assumeDistHashesSometimes=True,
1281 - assumeDistHashesAlways=(
1282 - "assume-digests" in mysettings.features))
1283 - except FileNotFound as e:
1284 - writemsg(_("!!! File %s doesn't exist, can't update "
1285 - "Manifest\n") % e, noiselevel=-1)
1286 - return 0
1287 - except PortagePackageException as e:
1288 - writemsg(("!!! %s\n") % (e,), noiselevel=-1)
1289 - return 0
1290 - try:
1291 - mf.write(sign=False)
1292 - except PermissionDenied as e:
1293 - writemsg(_("!!! Permission Denied: %s\n") % (e,), noiselevel=-1)
1294 - return 0
1295 - if "assume-digests" not in mysettings.features:
1296 - distlist = list(mf.fhashdict.get("DIST", {}))
1297 - distlist.sort()
1298 - auto_assumed = []
1299 - for filename in distlist:
1300 - if not os.path.exists(
1301 - os.path.join(mysettings["DISTDIR"], filename)):
1302 - auto_assumed.append(filename)
1303 - if auto_assumed:
1304 - mytree = os.path.realpath(
1305 - os.path.dirname(os.path.dirname(mysettings["O"])))
1306 - cp = os.path.sep.join(mysettings["O"].split(os.path.sep)[-2:])
1307 - pkgs = myportdb.cp_list(cp, mytree=mytree)
1308 - pkgs.sort()
1309 - writemsg_stdout(" digest.assumed" + colorize("WARN",
1310 - str(len(auto_assumed)).rjust(18)) + "\n")
1311 - for pkg_key in pkgs:
1312 - fetchlist = myportdb.getFetchMap(pkg_key, mytree=mytree)
1313 - pv = pkg_key.split("/")[1]
1314 - for filename in auto_assumed:
1315 - if filename in fetchlist:
1316 - writemsg_stdout(
1317 - " %s::%s\n" % (pv, filename))
1318 - return 1
1319 - finally:
1320 - portage._doebuild_manifest_exempt_depend -= 1