1 |
Author: zmedico |
2 |
Date: 2010-02-25 20:11:11 +0000 (Thu, 25 Feb 2010) |
3 |
New Revision: 15458 |
4 |
|
5 |
Added: |
6 |
main/trunk/pym/portage/package/ebuild/digestcheck.py |
7 |
Modified: |
8 |
main/trunk/pym/_emerge/Scheduler.py |
9 |
main/trunk/pym/portage/__init__.py |
10 |
main/trunk/pym/portage/package/ebuild/doebuild.py |
11 |
Log: |
12 |
Move portage.digestcheck to portage.package.ebuild.digestcheck. |
13 |
|
14 |
|
15 |
Modified: main/trunk/pym/_emerge/Scheduler.py |
16 |
=================================================================== |
17 |
--- main/trunk/pym/_emerge/Scheduler.py 2010-02-25 19:28:06 UTC (rev 15457) |
18 |
+++ main/trunk/pym/_emerge/Scheduler.py 2010-02-25 20:11:11 UTC (rev 15458) |
19 |
@@ -24,6 +24,7 @@ |
20 |
from portage.sets import SETPREFIX |
21 |
from portage.sets.base import InternalPackageSet |
22 |
from portage.util import writemsg, writemsg_level |
23 |
+from portage.package.ebuild.digestcheck import digestcheck |
24 |
from portage.package.ebuild.digestgen import digestgen |
25 |
|
26 |
from _emerge.BinpkgPrefetcher import BinpkgPrefetcher |
27 |
@@ -638,7 +639,7 @@ |
28 |
if ebuild_path is None: |
29 |
raise AssertionError("ebuild not found for '%s'" % x.cpv) |
30 |
quiet_config["O"] = os.path.dirname(ebuild_path) |
31 |
- if not portage.digestcheck([], quiet_config, strict=True): |
32 |
+ if not digestcheck([], quiet_config, strict=True): |
33 |
failures |= 1 |
34 |
|
35 |
if failures: |
36 |
|
37 |
Modified: main/trunk/pym/portage/__init__.py |
38 |
=================================================================== |
39 |
--- main/trunk/pym/portage/__init__.py 2010-02-25 19:28:06 UTC (rev 15457) |
40 |
+++ main/trunk/pym/portage/__init__.py 2010-02-25 20:11:11 UTC (rev 15458) |
41 |
@@ -104,6 +104,8 @@ |
42 |
'doebuild_environment,spawn,spawnebuild', |
43 |
'portage.package.ebuild.config:autouse,best_from_dict,' + \ |
44 |
'check_config_instance,config', |
45 |
+ 'portage.package.ebuild.digestcheck:digestcheck', |
46 |
+ 'portage.package.ebuild.digestgen:digestgen', |
47 |
'portage.package.ebuild.fetch:fetch', |
48 |
'portage.package.ebuild.prepare_build_dirs:prepare_build_dirs', |
49 |
'portage.process', |
50 |
@@ -119,7 +121,6 @@ |
51 |
'pickle_read,pickle_write,stack_dictlist,stack_dicts,' + \ |
52 |
'stack_lists,unique_array,varexpand,writedict,writemsg,' + \ |
53 |
'writemsg_stdout,write_atomic', |
54 |
- 'portage.util.digestgen:digestgen', |
55 |
'portage.util.digraph:digraph', |
56 |
'portage.util.env_update:env_update', |
57 |
'portage.util.ExtractKernelVersion:ExtractKernelVersion', |
58 |
@@ -561,146 +562,6 @@ |
59 |
|
60 |
return Manifest(pkgdir, mysettings["DISTDIR"]).getDigests() |
61 |
|
62 |
-def digestcheck(myfiles, mysettings, strict=0, justmanifest=0): |
63 |
- """Verifies checksums. Assumes all files have been downloaded. |
64 |
- DEPRECATED: this is now only a compability wrapper for |
65 |
- portage.manifest.Manifest().""" |
66 |
- if mysettings.get("EBUILD_SKIP_MANIFEST") == "1": |
67 |
- return 1 |
68 |
- pkgdir = mysettings["O"] |
69 |
- manifest_path = os.path.join(pkgdir, "Manifest") |
70 |
- if not os.path.exists(manifest_path): |
71 |
- writemsg(_("!!! Manifest file not found: '%s'\n") % manifest_path, |
72 |
- noiselevel=-1) |
73 |
- if strict: |
74 |
- return 0 |
75 |
- else: |
76 |
- return 1 |
77 |
- mf = Manifest(pkgdir, mysettings["DISTDIR"]) |
78 |
- manifest_empty = True |
79 |
- for d in mf.fhashdict.values(): |
80 |
- if d: |
81 |
- manifest_empty = False |
82 |
- break |
83 |
- if manifest_empty: |
84 |
- writemsg(_("!!! Manifest is empty: '%s'\n") % manifest_path, |
85 |
- noiselevel=-1) |
86 |
- if strict: |
87 |
- return 0 |
88 |
- else: |
89 |
- return 1 |
90 |
- eout = portage.output.EOutput() |
91 |
- eout.quiet = mysettings.get("PORTAGE_QUIET", None) == "1" |
92 |
- try: |
93 |
- if strict and "PORTAGE_PARALLEL_FETCHONLY" not in mysettings: |
94 |
- eout.ebegin(_("checking ebuild checksums ;-)")) |
95 |
- mf.checkTypeHashes("EBUILD") |
96 |
- eout.eend(0) |
97 |
- eout.ebegin(_("checking auxfile checksums ;-)")) |
98 |
- mf.checkTypeHashes("AUX") |
99 |
- eout.eend(0) |
100 |
- eout.ebegin(_("checking miscfile checksums ;-)")) |
101 |
- mf.checkTypeHashes("MISC", ignoreMissingFiles=True) |
102 |
- eout.eend(0) |
103 |
- for f in myfiles: |
104 |
- eout.ebegin(_("checking %s ;-)") % f) |
105 |
- ftype = mf.findFile(f) |
106 |
- if ftype is None: |
107 |
- raise KeyError(f) |
108 |
- mf.checkFileHashes(ftype, f) |
109 |
- eout.eend(0) |
110 |
- except KeyError as e: |
111 |
- eout.eend(1) |
112 |
- writemsg(_("\n!!! Missing digest for %s\n") % str(e), noiselevel=-1) |
113 |
- return 0 |
114 |
- except portage.exception.FileNotFound as e: |
115 |
- eout.eend(1) |
116 |
- writemsg(_("\n!!! A file listed in the Manifest could not be found: %s\n") % str(e), |
117 |
- noiselevel=-1) |
118 |
- return 0 |
119 |
- except portage.exception.DigestException as e: |
120 |
- eout.eend(1) |
121 |
- writemsg(_("\n!!! Digest verification failed:\n"), noiselevel=-1) |
122 |
- writemsg("!!! %s\n" % e.value[0], noiselevel=-1) |
123 |
- writemsg(_("!!! Reason: %s\n") % e.value[1], noiselevel=-1) |
124 |
- writemsg(_("!!! Got: %s\n") % e.value[2], noiselevel=-1) |
125 |
- writemsg(_("!!! Expected: %s\n") % e.value[3], noiselevel=-1) |
126 |
- return 0 |
127 |
- # Make sure that all of the ebuilds are actually listed in the Manifest. |
128 |
- glep55 = 'parse-eapi-glep-55' in mysettings.features |
129 |
- for f in os.listdir(pkgdir): |
130 |
- pf = None |
131 |
- if glep55: |
132 |
- pf, eapi = _split_ebuild_name_glep55(f) |
133 |
- elif f[-7:] == '.ebuild': |
134 |
- pf = f[:-7] |
135 |
- if pf is not None and not mf.hasFile("EBUILD", f): |
136 |
- writemsg(_("!!! A file is not listed in the Manifest: '%s'\n") % \ |
137 |
- os.path.join(pkgdir, f), noiselevel=-1) |
138 |
- if strict: |
139 |
- return 0 |
140 |
- """ epatch will just grab all the patches out of a directory, so we have to |
141 |
- make sure there aren't any foreign files that it might grab.""" |
142 |
- filesdir = os.path.join(pkgdir, "files") |
143 |
- |
144 |
- for parent, dirs, files in os.walk(filesdir): |
145 |
- try: |
146 |
- parent = _unicode_decode(parent, |
147 |
- encoding=_encodings['fs'], errors='strict') |
148 |
- except UnicodeDecodeError: |
149 |
- parent = _unicode_decode(parent, |
150 |
- encoding=_encodings['fs'], errors='replace') |
151 |
- writemsg(_("!!! Path contains invalid " |
152 |
- "character(s) for encoding '%s': '%s'") \ |
153 |
- % (_encodings['fs'], parent), noiselevel=-1) |
154 |
- if strict: |
155 |
- return 0 |
156 |
- continue |
157 |
- for d in dirs: |
158 |
- d_bytes = d |
159 |
- try: |
160 |
- d = _unicode_decode(d, |
161 |
- encoding=_encodings['fs'], errors='strict') |
162 |
- except UnicodeDecodeError: |
163 |
- d = _unicode_decode(d, |
164 |
- encoding=_encodings['fs'], errors='replace') |
165 |
- writemsg(_("!!! Path contains invalid " |
166 |
- "character(s) for encoding '%s': '%s'") \ |
167 |
- % (_encodings['fs'], os.path.join(parent, d)), |
168 |
- noiselevel=-1) |
169 |
- if strict: |
170 |
- return 0 |
171 |
- dirs.remove(d_bytes) |
172 |
- continue |
173 |
- if d.startswith(".") or d == "CVS": |
174 |
- dirs.remove(d_bytes) |
175 |
- for f in files: |
176 |
- try: |
177 |
- f = _unicode_decode(f, |
178 |
- encoding=_encodings['fs'], errors='strict') |
179 |
- except UnicodeDecodeError: |
180 |
- f = _unicode_decode(f, |
181 |
- encoding=_encodings['fs'], errors='replace') |
182 |
- if f.startswith("."): |
183 |
- continue |
184 |
- f = os.path.join(parent, f)[len(filesdir) + 1:] |
185 |
- writemsg(_("!!! File name contains invalid " |
186 |
- "character(s) for encoding '%s': '%s'") \ |
187 |
- % (_encodings['fs'], f), noiselevel=-1) |
188 |
- if strict: |
189 |
- return 0 |
190 |
- continue |
191 |
- if f.startswith("."): |
192 |
- continue |
193 |
- f = os.path.join(parent, f)[len(filesdir) + 1:] |
194 |
- file_type = mf.findFile(f) |
195 |
- if file_type != "AUX" and not f.startswith("digest-"): |
196 |
- writemsg(_("!!! A file is not listed in the Manifest: '%s'\n") % \ |
197 |
- os.path.join(filesdir, f), noiselevel=-1) |
198 |
- if strict: |
199 |
- return 0 |
200 |
- return 1 |
201 |
- |
202 |
_testing_eapis = frozenset() |
203 |
_deprecated_eapis = frozenset(["3_pre2", "3_pre1", "2_pre3", "2_pre2", "2_pre1"]) |
204 |
|
205 |
|
206 |
Added: main/trunk/pym/portage/package/ebuild/digestcheck.py |
207 |
=================================================================== |
208 |
--- main/trunk/pym/portage/package/ebuild/digestcheck.py (rev 0) |
209 |
+++ main/trunk/pym/portage/package/ebuild/digestcheck.py 2010-02-25 20:11:11 UTC (rev 15458) |
210 |
@@ -0,0 +1,154 @@ |
211 |
+# Copyright 2010 Gentoo Foundation |
212 |
+# Distributed under the terms of the GNU General Public License v2 |
213 |
+# $Id$ |
214 |
+ |
215 |
+__all__ = ['digestcheck'] |
216 |
+ |
217 |
+from portage import os, _encodings, _split_ebuild_name_glep55, _unicode_decode |
218 |
+from portage.exception import DigestException, FileNotFound |
219 |
+from portage.localization import _ |
220 |
+from portage.manifest import Manifest |
221 |
+from portage.output import EOutput |
222 |
+from portagel.util import writemsg |
223 |
+ |
224 |
+def digestcheck(myfiles, mysettings, strict=0, justmanifest=0): |
225 |
+ """ |
226 |
+ Verifies checksums. Assumes all files have been downloaded. |
227 |
+ @rtype: int |
228 |
+ @returns: 1 on success and 0 on failure |
229 |
+ """ |
230 |
+ if mysettings.get("EBUILD_SKIP_MANIFEST") == "1": |
231 |
+ return 1 |
232 |
+ pkgdir = mysettings["O"] |
233 |
+ manifest_path = os.path.join(pkgdir, "Manifest") |
234 |
+ if not os.path.exists(manifest_path): |
235 |
+ writemsg(_("!!! Manifest file not found: '%s'\n") % manifest_path, |
236 |
+ noiselevel=-1) |
237 |
+ if strict: |
238 |
+ return 0 |
239 |
+ else: |
240 |
+ return 1 |
241 |
+ mf = Manifest(pkgdir, mysettings["DISTDIR"]) |
242 |
+ manifest_empty = True |
243 |
+ for d in mf.fhashdict.values(): |
244 |
+ if d: |
245 |
+ manifest_empty = False |
246 |
+ break |
247 |
+ if manifest_empty: |
248 |
+ writemsg(_("!!! Manifest is empty: '%s'\n") % manifest_path, |
249 |
+ noiselevel=-1) |
250 |
+ if strict: |
251 |
+ return 0 |
252 |
+ else: |
253 |
+ return 1 |
254 |
+ eout = EOutput() |
255 |
+ eout.quiet = mysettings.get("PORTAGE_QUIET", None) == "1" |
256 |
+ try: |
257 |
+ if strict and "PORTAGE_PARALLEL_FETCHONLY" not in mysettings: |
258 |
+ eout.ebegin(_("checking ebuild checksums ;-)")) |
259 |
+ mf.checkTypeHashes("EBUILD") |
260 |
+ eout.eend(0) |
261 |
+ eout.ebegin(_("checking auxfile checksums ;-)")) |
262 |
+ mf.checkTypeHashes("AUX") |
263 |
+ eout.eend(0) |
264 |
+ eout.ebegin(_("checking miscfile checksums ;-)")) |
265 |
+ mf.checkTypeHashes("MISC", ignoreMissingFiles=True) |
266 |
+ eout.eend(0) |
267 |
+ for f in myfiles: |
268 |
+ eout.ebegin(_("checking %s ;-)") % f) |
269 |
+ ftype = mf.findFile(f) |
270 |
+ if ftype is None: |
271 |
+ raise KeyError(f) |
272 |
+ mf.checkFileHashes(ftype, f) |
273 |
+ eout.eend(0) |
274 |
+ except KeyError as e: |
275 |
+ eout.eend(1) |
276 |
+ writemsg(_("\n!!! Missing digest for %s\n") % str(e), noiselevel=-1) |
277 |
+ return 0 |
278 |
+ except FileNotFound as e: |
279 |
+ eout.eend(1) |
280 |
+ writemsg(_("\n!!! A file listed in the Manifest could not be found: %s\n") % str(e), |
281 |
+ noiselevel=-1) |
282 |
+ return 0 |
283 |
+ except DigestException as e: |
284 |
+ eout.eend(1) |
285 |
+ writemsg(_("\n!!! Digest verification failed:\n"), noiselevel=-1) |
286 |
+ writemsg("!!! %s\n" % e.value[0], noiselevel=-1) |
287 |
+ writemsg(_("!!! Reason: %s\n") % e.value[1], noiselevel=-1) |
288 |
+ writemsg(_("!!! Got: %s\n") % e.value[2], noiselevel=-1) |
289 |
+ writemsg(_("!!! Expected: %s\n") % e.value[3], noiselevel=-1) |
290 |
+ return 0 |
291 |
+ # Make sure that all of the ebuilds are actually listed in the Manifest. |
292 |
+ glep55 = 'parse-eapi-glep-55' in mysettings.features |
293 |
+ for f in os.listdir(pkgdir): |
294 |
+ pf = None |
295 |
+ if glep55: |
296 |
+ pf, eapi = _split_ebuild_name_glep55(f) |
297 |
+ elif f[-7:] == '.ebuild': |
298 |
+ pf = f[:-7] |
299 |
+ if pf is not None and not mf.hasFile("EBUILD", f): |
300 |
+ writemsg(_("!!! A file is not listed in the Manifest: '%s'\n") % \ |
301 |
+ os.path.join(pkgdir, f), noiselevel=-1) |
302 |
+ if strict: |
303 |
+ return 0 |
304 |
+ """ epatch will just grab all the patches out of a directory, so we have to |
305 |
+ make sure there aren't any foreign files that it might grab.""" |
306 |
+ filesdir = os.path.join(pkgdir, "files") |
307 |
+ |
308 |
+ for parent, dirs, files in os.walk(filesdir): |
309 |
+ try: |
310 |
+ parent = _unicode_decode(parent, |
311 |
+ encoding=_encodings['fs'], errors='strict') |
312 |
+ except UnicodeDecodeError: |
313 |
+ parent = _unicode_decode(parent, |
314 |
+ encoding=_encodings['fs'], errors='replace') |
315 |
+ writemsg(_("!!! Path contains invalid " |
316 |
+ "character(s) for encoding '%s': '%s'") \ |
317 |
+ % (_encodings['fs'], parent), noiselevel=-1) |
318 |
+ if strict: |
319 |
+ return 0 |
320 |
+ continue |
321 |
+ for d in dirs: |
322 |
+ d_bytes = d |
323 |
+ try: |
324 |
+ d = _unicode_decode(d, |
325 |
+ encoding=_encodings['fs'], errors='strict') |
326 |
+ except UnicodeDecodeError: |
327 |
+ d = _unicode_decode(d, |
328 |
+ encoding=_encodings['fs'], errors='replace') |
329 |
+ writemsg(_("!!! Path contains invalid " |
330 |
+ "character(s) for encoding '%s': '%s'") \ |
331 |
+ % (_encodings['fs'], os.path.join(parent, d)), |
332 |
+ noiselevel=-1) |
333 |
+ if strict: |
334 |
+ return 0 |
335 |
+ dirs.remove(d_bytes) |
336 |
+ continue |
337 |
+ if d.startswith(".") or d == "CVS": |
338 |
+ dirs.remove(d_bytes) |
339 |
+ for f in files: |
340 |
+ try: |
341 |
+ f = _unicode_decode(f, |
342 |
+ encoding=_encodings['fs'], errors='strict') |
343 |
+ except UnicodeDecodeError: |
344 |
+ f = _unicode_decode(f, |
345 |
+ encoding=_encodings['fs'], errors='replace') |
346 |
+ if f.startswith("."): |
347 |
+ continue |
348 |
+ f = os.path.join(parent, f)[len(filesdir) + 1:] |
349 |
+ writemsg(_("!!! File name contains invalid " |
350 |
+ "character(s) for encoding '%s': '%s'") \ |
351 |
+ % (_encodings['fs'], f), noiselevel=-1) |
352 |
+ if strict: |
353 |
+ return 0 |
354 |
+ continue |
355 |
+ if f.startswith("."): |
356 |
+ continue |
357 |
+ f = os.path.join(parent, f)[len(filesdir) + 1:] |
358 |
+ file_type = mf.findFile(f) |
359 |
+ if file_type != "AUX" and not f.startswith("digest-"): |
360 |
+ writemsg(_("!!! A file is not listed in the Manifest: '%s'\n") % \ |
361 |
+ os.path.join(filesdir, f), noiselevel=-1) |
362 |
+ if strict: |
363 |
+ return 0 |
364 |
+ return 1 |
365 |
|
366 |
|
367 |
Property changes on: main/trunk/pym/portage/package/ebuild/digestcheck.py |
368 |
___________________________________________________________________ |
369 |
Added: svn:keywords |
370 |
+ Id |
371 |
|
372 |
Modified: main/trunk/pym/portage/package/ebuild/doebuild.py |
373 |
=================================================================== |
374 |
--- main/trunk/pym/portage/package/ebuild/doebuild.py 2010-02-25 19:28:06 UTC (rev 15457) |
375 |
+++ main/trunk/pym/portage/package/ebuild/doebuild.py 2010-02-25 20:11:11 UTC (rev 15458) |
376 |
@@ -21,11 +21,12 @@ |
377 |
import portage |
378 |
portage.proxy.lazyimport.lazyimport(globals(), |
379 |
'portage.package.ebuild.config:check_config_instance', |
380 |
+ 'portage.package.ebuild.digestcheck:digestcheck', |
381 |
'portage.package.ebuild.digestgen:digestgen', |
382 |
'portage.util.ExtractKernelVersion:ExtractKernelVersion' |
383 |
) |
384 |
|
385 |
-from portage import auxdbkeys, bsd_chflags, dep_check, digestcheck, \ |
386 |
+from portage import auxdbkeys, bsd_chflags, dep_check, \ |
387 |
eapi_is_supported, merge, os, selinux, StringIO, \ |
388 |
unmerge, _encodings, _parse_eapi_ebuild_head, _os_merge, \ |
389 |
_shell_quote, _split_ebuild_name_glep55, _unicode_decode, _unicode_encode |