1 | ? base/src/pextlib1.0/sha1cmd.c |
---|
2 | ? base/src/pextlib1.0/sha1cmd.h |
---|
3 | cvs server: Diffing base |
---|
4 | cvs server: Diffing base/Mk |
---|
5 | cvs server: Diffing base/doc |
---|
6 | cvs server: Diffing base/doc/exampleport |
---|
7 | cvs server: Diffing base/src |
---|
8 | cvs server: Diffing base/src/cflib1.0 |
---|
9 | cvs server: Diffing base/src/darwinports1.0 |
---|
10 | cvs server: Diffing base/src/package1.0 |
---|
11 | cvs server: Diffing base/src/pextlib1.0 |
---|
12 | Index: base/src/pextlib1.0/Makefile |
---|
13 | =================================================================== |
---|
14 | RCS file: /Volumes/src/cvs/od/projects/darwinports/base/src/pextlib1.0/Makefile,v |
---|
15 | retrieving revision 1.37 |
---|
16 | diff -u -r1.37 Makefile |
---|
17 | --- base/src/pextlib1.0/Makefile 1 Jul 2004 17:21:12 -0000 1.37 |
---|
18 | +++ base/src/pextlib1.0/Makefile 15 Sep 2004 23:26:49 -0000 |
---|
19 | @@ -1,5 +1,6 @@ |
---|
20 | OBJS= Pextlib.o strsed.o fgetln.o md5cmd.o setmode.o xinstall.o \ |
---|
21 | - find.o strcasecmp.o vercomp.o filemap.o |
---|
22 | + find.o strcasecmp.o vercomp.o filemap.o \ |
---|
23 | + sha1cmd.o |
---|
24 | SHLIB_NAME= Pextlib${SHLIB_SUFFIX} |
---|
25 | INSTALLDIR= ${DESTDIR}${datadir}/darwinports/Tcl/pextlib1.0 |
---|
26 | |
---|
27 | Index: base/src/pextlib1.0/Pextlib.c |
---|
28 | =================================================================== |
---|
29 | RCS file: /Volumes/src/cvs/od/projects/darwinports/base/src/pextlib1.0/Pextlib.c,v |
---|
30 | retrieving revision 1.66 |
---|
31 | diff -u -r1.66 Pextlib.c |
---|
32 | --- base/src/pextlib1.0/Pextlib.c 4 Jul 2004 06:51:27 -0000 1.66 |
---|
33 | +++ base/src/pextlib1.0/Pextlib.c 15 Sep 2004 23:26:49 -0000 |
---|
34 | @@ -94,6 +94,7 @@ |
---|
35 | #include <tcl.h> |
---|
36 | |
---|
37 | #include "md5cmd.h" |
---|
38 | +#include "sha1cmd.h" |
---|
39 | #include "find.h" |
---|
40 | #include "filemap.h" |
---|
41 | #include "xinstall.h" |
---|
42 | @@ -716,6 +717,7 @@ |
---|
43 | Tcl_CreateObjCommand(interp, "find", FindCmd, NULL, NULL); |
---|
44 | Tcl_CreateObjCommand(interp, "filemap", FilemapCmd, NULL, NULL); |
---|
45 | Tcl_CreateObjCommand(interp, "rpm-vercomp", RPMVercompCmd, NULL, NULL); |
---|
46 | + Tcl_CreateObjCommand(interp, "sha1", SHA1Cmd, NULL, NULL); |
---|
47 | if(Tcl_PkgProvide(interp, "Pextlib", "1.0") != TCL_OK) |
---|
48 | return TCL_ERROR; |
---|
49 | return TCL_OK; |
---|
50 | cvs server: Diffing base/src/pextlib1.0/tests |
---|
51 | cvs server: Diffing base/src/port |
---|
52 | cvs server: Diffing base/src/port1.0 |
---|
53 | Index: base/src/port1.0/portchecksum.tcl |
---|
54 | =================================================================== |
---|
55 | RCS file: /Volumes/src/cvs/od/projects/darwinports/base/src/port1.0/portchecksum.tcl,v |
---|
56 | retrieving revision 1.33 |
---|
57 | diff -u -r1.33 portchecksum.tcl |
---|
58 | --- base/src/port1.0/portchecksum.tcl 5 May 2004 19:31:02 -0000 1.33 |
---|
59 | +++ base/src/port1.0/portchecksum.tcl 15 Sep 2004 23:26:49 -0000 |
---|
60 | @@ -45,15 +45,17 @@ |
---|
61 | |
---|
62 | set_ui_prefix |
---|
63 | |
---|
64 | -# dmd5 |
---|
65 | +# get_checksum |
---|
66 | # |
---|
67 | -# Returns the expected checksum for the given file. |
---|
68 | -# If no checksum is found, returns -1. |
---|
69 | +# Returns the expected md5/sha1/etc. checksum for the given file. |
---|
70 | +# If no md5/sha1/etc. checksum is found, returns -1. |
---|
71 | # |
---|
72 | -proc dmd5 {file} { |
---|
73 | - foreach {name type sum} [option checksums] { |
---|
74 | +proc get_checksum {file want_sum port_checksums} { |
---|
75 | + foreach {name type sum} $port_checksums { |
---|
76 | if {[string equal $name $file]} { |
---|
77 | - return $sum |
---|
78 | + if {[string equal $type $want_sum]} { |
---|
79 | + return $sum |
---|
80 | + } |
---|
81 | } |
---|
82 | } |
---|
83 | |
---|
84 | @@ -77,45 +79,120 @@ |
---|
85 | proc checksum_main {args} { |
---|
86 | global UI_PREFIX all_dist_files |
---|
87 | |
---|
88 | + # list of known checksum types as an |
---|
89 | + # array of string in portfile and function we'll call. |
---|
90 | + # The string and the function are currently the same, but no |
---|
91 | + # guarantees that it will remain so. |
---|
92 | + array set checksum_types { \ |
---|
93 | + "md5" md5 \ |
---|
94 | + "sha1" sha1 \ |
---|
95 | + } |
---|
96 | + |
---|
97 | # If no files have been downloaded, there is nothing to checksum. |
---|
98 | if {![info exists all_dist_files]} { |
---|
99 | return 0 |
---|
100 | } |
---|
101 | |
---|
102 | # Optimization for the two-argument case for checksums. |
---|
103 | - if {[llength [option checksums]] == 2 && [llength $all_dist_files] == 1} { |
---|
104 | - option checksums [linsert [option checksums] 0 $all_dist_files] |
---|
105 | + ## See if the checksum type from the Portfile matches a known |
---|
106 | + ## checksum type. If it does and we only have 1 distfile, |
---|
107 | + ## insert the distfilename ahead of the checksum type and result |
---|
108 | + ## from the Portfile. |
---|
109 | + ## If the type doesn't match a known type and we only have 1 distfile, |
---|
110 | + ## then its an unknown checksum type, so we barf on it. |
---|
111 | + ## ELACKSGRACE: if a Portfile only has 1 distfile *and* the two-arg |
---|
112 | + ## optimization is not used (i.e. checksum line is <distfile> <type> <sum>) |
---|
113 | + ## this code thinks that <distfile> is the <type> and barfs on it. |
---|
114 | + ## I'm not seeing a way around that right now, as the Portfile checksum |
---|
115 | + ## info comes to us as a list of items. |
---|
116 | + ## AND THERE WE GO: graphics/aalib has 1 distfile and doesn't use the |
---|
117 | + ## two-arg optimization, so it barfs. futzor. |
---|
118 | + ## okay, so now what we'll do is just ignore bogus checksum types. |
---|
119 | + ## We *should* detect bogus checksum types, I'm thinking that changes |
---|
120 | + ## need to happen in reading the Portfile and perform the substitution |
---|
121 | + ## for the two-arg optimization during the building of the checksums option. |
---|
122 | + ## |
---|
123 | + set port_checksums "" |
---|
124 | + foreach {type sum} [option checksums] { |
---|
125 | + ## see if $type is one of our known checksum types. If it is, |
---|
126 | + ## we assume we don't have our dist file name. Check that |
---|
127 | + ## we only expect 1 dist file as well... If we have only |
---|
128 | + ## one dist file and $type is a checksum_type, the add the |
---|
129 | + ## $all_dist_files to the start of the checksum list. |
---|
130 | + |
---|
131 | + if {[lsearch -exact [array names checksum_types] $type] != -1 && \ |
---|
132 | + [llength $all_dist_files] == 1} { |
---|
133 | + set port_checksums [linsert $port_checksums 0 $all_dist_files $type $sum] |
---|
134 | +## } else { |
---|
135 | +## if {[llength $all_dist_files] == 1} { |
---|
136 | +## return -code error "[format [msgcat::mc "Unknown checksum type '%s'"] $type]" |
---|
137 | +## } |
---|
138 | + } |
---|
139 | + } |
---|
140 | + ## if we didn't do the above filename insertions, we have an empty $port_checksums, |
---|
141 | + ## so copy over the [option checksums] and use $port_checksums from here out |
---|
142 | + if {[llength $port_checksums] == 0} { |
---|
143 | + set port_checksums [option checksums] |
---|
144 | } |
---|
145 | |
---|
146 | set fail no |
---|
147 | |
---|
148 | foreach distfile $all_dist_files { |
---|
149 | ui_info "$UI_PREFIX [format [msgcat::mc "Checksumming %s"] $distfile]" |
---|
150 | + set distfile_chksum_success 0 |
---|
151 | |
---|
152 | - # Calculate the distfile's checksum. |
---|
153 | - set checksum [md5 file [file join [option distpath] $distfile]] |
---|
154 | - |
---|
155 | - # Find the expected checksum. |
---|
156 | - set dchecksum [dmd5 $distfile] |
---|
157 | - |
---|
158 | - # Check for missing checksum or a mismatch. |
---|
159 | - if {$dchecksum == -1} { |
---|
160 | - ui_error "[format [msgcat::mc "No checksum set for %s"] $distfile]" |
---|
161 | - } elseif {![string equal $checksum $dchecksum]} { |
---|
162 | - ui_error "[format [msgcat::mc "Checksum mismatch for %s"] $distfile]" |
---|
163 | - } else { |
---|
164 | - continue |
---|
165 | + ## XYZZY: as I look at this again, I'm thinking maybe we're doing |
---|
166 | + ## it backwards - rather than calculate the checksum then go look for |
---|
167 | + ## it, we should find the checksums we do have, then calculate those |
---|
168 | + ## and compare, and note our successes. We can then show those |
---|
169 | + ## checksum types we know about that were not in the Portfile, and |
---|
170 | + ## make mention of it. |
---|
171 | + foreach chksum_type [array names checksum_types] { |
---|
172 | + # Find the expected checksum. |
---|
173 | + set dchecksum [get_checksum $distfile $chksum_type $port_checksums] |
---|
174 | + |
---|
175 | + # Check for missing checksum |
---|
176 | + if {$dchecksum == -1} { |
---|
177 | + ui_info "$UI_PREFIX [format [msgcat::mc "No %s checksum set for %s"] $chksum_type $distfile]" |
---|
178 | + ## and lets try the next one... |
---|
179 | + continue |
---|
180 | + } |
---|
181 | + ## sanity check - Do we actually have checksum routine? |
---|
182 | + if {[string length [info commands $checksum_types($chksum_type)]]} { |
---|
183 | + # Calculate the distfile's checksum. |
---|
184 | + set checksum [$checksum_types($chksum_type) file [file join [option distpath] $distfile]] |
---|
185 | + } else { |
---|
186 | + ## explode catch fire? Just throw a warning and continue? Hmmm. |
---|
187 | + ui_error "$UI_PREFIX [format [msgcat::mc "Can't find checksum routine '%s' for checksum type '%s'"] $checksum_types($chksum_type) $chksum_type]" |
---|
188 | + continue |
---|
189 | + } |
---|
190 | + |
---|
191 | + # Check for checksum mismatch. |
---|
192 | + if {![string equal $checksum $dchecksum]} { |
---|
193 | + ui_error "$UI_PREFIX [format [msgcat::mc "%s checksum mismatch for '%s':"] $chksum_type $distfile]" |
---|
194 | + ui_error "$UI_PREFIX [format [msgcat::mc "wanted '%s',"] $dchecksum]" |
---|
195 | + ui_error "$UI_PREFIX [format [msgcat::mc " got '%s'"] $checksum]" |
---|
196 | + # Raise the failure flag |
---|
197 | + set fail yes |
---|
198 | + } else { |
---|
199 | + set distfile_chksum_success [expr $distfile_chksum_success + 1] |
---|
200 | + } |
---|
201 | + |
---|
202 | + if {[tbool fail]} { |
---|
203 | + return -code error "[format [msgcat::mc "Unable to verify %s checksum"] $chksum_type]" |
---|
204 | + } |
---|
205 | + ## else just fall to the next checksum... |
---|
206 | + |
---|
207 | + if {$dchecksum != -1} { |
---|
208 | + # Post file checksum |
---|
209 | + ui_info "$UI_PREFIX [format [msgcat::mc "Correct %s checksum: %s %s %s"] $chksum_type ${distfile} $chksum_type ${checksum}]" |
---|
210 | + } |
---|
211 | } |
---|
212 | |
---|
213 | - # Post file checksum |
---|
214 | - ui_info "[format [msgcat::mc "Correct checksum: %s %s %s"] ${distfile} md5 ${checksum}]" |
---|
215 | - |
---|
216 | - # Raise the failure flag |
---|
217 | - set fail yes |
---|
218 | - } |
---|
219 | - |
---|
220 | - if {[tbool fail]} { |
---|
221 | - return -code error "[msgcat::mc "Unable to verify file checksums"]" |
---|
222 | + if {$distfile_chksum_success == 0} { |
---|
223 | + ## oh bother, no successful checksum for this dist file, bailage |
---|
224 | + return -code error "[format [msgcat::mc "No checksums set for %s"] $distfile]" |
---|
225 | + } |
---|
226 | } |
---|
227 | |
---|
228 | return 0 |
---|
229 | cvs server: Diffing base/src/port1.0/resources |
---|
230 | cvs server: Diffing base/src/port1.0/resources/fetch |
---|
231 | cvs server: Diffing base/src/port1.0/resources/group |
---|
232 | cvs server: Diffing base/src/port1.0/resources/package |
---|
233 | cvs server: Diffing base/src/portindex |
---|
234 | cvs server: Diffing base/src/portmgr |
---|
235 | cvs server: Diffing base/src/programs |
---|
236 | cvs server: Diffing base/src/programs/mtree |
---|
237 | cvs server: Diffing base/src/registry1.0 |
---|