Ticket #2451: patch-portchecksum.tcl

File patch-portchecksum.tcl, 2.3 KB (added by jberry@…, 20 years ago)

patch to base/src/port1.0/portchecksum.tcl

Line 
1Index: src/port1.0/portchecksum.tcl
2===================================================================
3RCS file: /Volumes/src/cvs/od/proj/darwinports/base/src/port1.0/portchecksum.tcl,v
4retrieving revision 1.37
5diff -u -r1.37 portchecksum.tcl
6--- src/port1.0/portchecksum.tcl        5 Dec 2004 09:18:12 -0000       1.37
7+++ src/port1.0/portchecksum.tcl        5 Dec 2004 17:46:45 -0000
8@@ -88,7 +88,7 @@
9 
10                incr i 2
11        }
12-
13+       
14        # If no checksums were found, the checksums option is probably invalid.
15        if {$start >= $i} {
16                return -1
17@@ -97,22 +97,22 @@
18        return [lrange $checksums $start $i]
19 }
20 
21-# check_md5
22+# calc_md5
23 #
24-# Check the md5 checksum for the given file.
25-# Return 0 if the checksum is incorrect, 1 otherwise.
26+# Calculate the md5 checksum for the given file.
27+# Return the checksum.
28 #
29-proc check_md5 {file sum} {
30-       return [string equal $sum [md5 file $file]]
31+proc calc_md5 {file} {
32+       return [md5 file $file]
33 }
34 
35-# check_sha1
36+# calc_sha1
37 #
38-# Check the sha1 checksum for the given file.
39-# Return 0 if the checksum is incorrect, 1 otherwise.
40+# Calculate the sha1 checksum for the given file.
41+# Return the checksum.
42 #
43-proc check_sha1 {file sum} {
44-       return [string equal $sum [sha1 file $file]]
45+proc calc_sha1 {file} {
46+       return [sha1 file $file]
47 }
48 
49 # checksum_start
50@@ -164,7 +164,7 @@
51 
52                # obtain the checksums for this file from the portfile (i.e. from $checksums)
53                set portfile_checksums [fchecksums $checksums $distfile]
54-
55+               
56                # check that there is at least one checksum for the distfile.
57                if {$portfile_checksums == -1} {
58                        ui_error "[format [msgcat::mc "No checksum set for %s"] $distfile]"
59@@ -173,17 +173,15 @@
60                } else {
61                        # iterate on this list to check the actual values.
62                        foreach {type sum} $portfile_checksums {
63-                               if {[check_$type $fullpath $sum]} {
64+                               set calculated_sum [calc_$type $fullpath]
65+                               if {[string equal $sum $calculated_sum]} {
66                                        ui_debug "[format [msgcat::mc "Correct (%s) checksum for %s"] $type $distfile]"
67                                } else {
68                                        ui_error "[format [msgcat::mc "Checksum (%s) mismatch for %s"] $type $distfile]"
69-                                       ui_info "[format [msgcat::mc "Correct checksum: %s %s %s"] $distfile $type $sum]"
70+                                       ui_info "[format [msgcat::mc "Correct checksum is: %s %s %s"] $distfile $type $calculated_sum]"
71                                       
72                                        # Raise the failure flag
73                                        set fail yes
74-                                       
75-                                       # Exit.
76-                                       break
77                                }
78                        }
79                }