1 |
Author: zmedico |
2 |
Date: 2008-08-05 08:28:13 +0000 (Tue, 05 Aug 2008) |
3 |
New Revision: 11332 |
4 |
|
5 |
Modified: |
6 |
main/trunk/pym/portage/__init__.py |
7 |
Log: |
8 |
Make doebuild() display manifest verification failures for each corrupt |
9 |
ebuild rather than just the first one. |
10 |
|
11 |
|
12 |
Modified: main/trunk/pym/portage/__init__.py |
13 |
=================================================================== |
14 |
--- main/trunk/pym/portage/__init__.py 2008-08-05 06:58:04 UTC (rev 11331) |
15 |
+++ main/trunk/pym/portage/__init__.py 2008-08-05 08:28:13 UTC (rev 11332) |
16 |
@@ -4979,7 +4979,8 @@ |
17 |
os.unlink(exit_status_file) |
18 |
|
19 |
_doebuild_manifest_exempt_depend = 0 |
20 |
-_doebuild_manifest_checked = None |
21 |
+_doebuild_manifest_cache = None |
22 |
+_doebuild_broken_ebuilds = set() |
23 |
_doebuild_broken_manifests = set() |
24 |
|
25 |
def doebuild(myebuild, mydo, myroot, mysettings, debug=0, listonly=0, |
26 |
@@ -5098,46 +5099,73 @@ |
27 |
mydo not in ("digest", "manifest", "help") and \ |
28 |
not _doebuild_manifest_exempt_depend: |
29 |
# Always verify the ebuild checksums before executing it. |
30 |
+ global _doebuild_manifest_cache, _doebuild_broken_ebuilds, \ |
31 |
+ _doebuild_broken_ebuilds |
32 |
+ |
33 |
+ if myebuild in _doebuild_broken_ebuilds: |
34 |
+ return 1 |
35 |
+ |
36 |
pkgdir = os.path.dirname(myebuild) |
37 |
manifest_path = os.path.join(pkgdir, "Manifest") |
38 |
- global _doebuild_manifest_checked, _doebuild_broken_manifests |
39 |
- if manifest_path in _doebuild_broken_manifests: |
40 |
- return 1 |
41 |
+ |
42 |
# Avoid checking the same Manifest several times in a row during a |
43 |
# regen with an empty cache. |
44 |
- if _doebuild_manifest_checked != manifest_path: |
45 |
+ if _doebuild_manifest_cache is None or \ |
46 |
+ _doebuild_manifest_cache.getFullname() != manifest_path: |
47 |
+ _doebuild_manifest_cache = None |
48 |
if not os.path.exists(manifest_path): |
49 |
- writemsg("!!! Manifest file not found: '%s'\n" % manifest_path, |
50 |
- noiselevel=-1) |
51 |
- _doebuild_broken_manifests.add(manifest_path) |
52 |
+ out = portage.output.EOutput() |
53 |
+ out.eerror("Manifest not found for '%s'" % (myebuild,)) |
54 |
+ _doebuild_broken_ebuilds.add(myebuild) |
55 |
return 1 |
56 |
mf = Manifest(pkgdir, mysettings["DISTDIR"]) |
57 |
- try: |
58 |
- mf.checkTypeHashes("EBUILD") |
59 |
- except portage.exception.FileNotFound, e: |
60 |
- writemsg("!!! A file listed in the Manifest " + \ |
61 |
- "could not be found: %s\n" % str(e), noiselevel=-1) |
62 |
- _doebuild_broken_manifests.add(manifest_path) |
63 |
- return 1 |
64 |
- except portage.exception.DigestException, e: |
65 |
- writemsg("!!! Digest verification failed:\n", noiselevel=-1) |
66 |
- writemsg("!!! %s\n" % e.value[0], noiselevel=-1) |
67 |
- writemsg("!!! Reason: %s\n" % e.value[1], noiselevel=-1) |
68 |
- writemsg("!!! Got: %s\n" % e.value[2], noiselevel=-1) |
69 |
- writemsg("!!! Expected: %s\n" % e.value[3], noiselevel=-1) |
70 |
- _doebuild_broken_manifests.add(manifest_path) |
71 |
- return 1 |
72 |
- # Make sure that all of the ebuilds are actually listed in the |
73 |
- # Manifest. |
74 |
+ |
75 |
+ else: |
76 |
+ mf = _doebuild_manifest_cache |
77 |
+ |
78 |
+ try: |
79 |
+ mf.checkFileHashes("EBUILD", os.path.basename(myebuild)) |
80 |
+ except KeyError: |
81 |
+ out = portage.output.EOutput() |
82 |
+ out.eerror("Missing digest for '%s'" % (myebuild,)) |
83 |
+ _doebuild_broken_ebuilds.add(myebuild) |
84 |
+ return 1 |
85 |
+ except portage.exception.FileNotFound: |
86 |
+ out = portage.output.EOutput() |
87 |
+ out.eerror("A file listed in the Manifest " + \ |
88 |
+ "could not be found: '%s'" % (myebuild,)) |
89 |
+ _doebuild_broken_ebuilds.add(myebuild) |
90 |
+ return 1 |
91 |
+ except portage.exception.DigestException, e: |
92 |
+ out = portage.output.EOutput() |
93 |
+ out.eerror("Digest verification failed:") |
94 |
+ out.eerror("%s" % e.value[0]) |
95 |
+ out.eerror("Reason: %s" % e.value[1]) |
96 |
+ out.eerror("Got: %s" % e.value[2]) |
97 |
+ out.eerror("Expected: %s" % e.value[3]) |
98 |
+ _doebuild_broken_ebuilds.add(myebuild) |
99 |
+ return 1 |
100 |
+ |
101 |
+ if mf.getFullname() in _doebuild_broken_manifests: |
102 |
+ return 1 |
103 |
+ |
104 |
+ if mf is not _doebuild_manifest_cache: |
105 |
+ |
106 |
+ # Make sure that all of the ebuilds are |
107 |
+ # actually listed in the Manifest. |
108 |
for f in os.listdir(pkgdir): |
109 |
if f.endswith(".ebuild") and not mf.hasFile("EBUILD", f): |
110 |
- writemsg("!!! A file is not listed in the " + \ |
111 |
- "Manifest: '%s'\n" % os.path.join(pkgdir, f), |
112 |
- noiselevel=-1) |
113 |
+ f = os.path.join(pkgdir, f) |
114 |
+ if f not in _doebuild_broken_ebuilds: |
115 |
+ out = portage.output.EOutput() |
116 |
+ out.eerror("A file is not listed in the " + \ |
117 |
+ "Manifest: '%s'" % (f,)) |
118 |
_doebuild_broken_manifests.add(manifest_path) |
119 |
return 1 |
120 |
- _doebuild_manifest_checked = manifest_path |
121 |
|
122 |
+ # Only cache it if the above stray files test succeeds. |
123 |
+ _doebuild_manifest_cache = mf |
124 |
+ |
125 |
def exit_status_check(retval): |
126 |
if retval != os.EX_OK: |
127 |
return retval |