Ticket #2198: base.add_sha1.diff
File base.add_sha1.diff, 7.0 KB (added by opendarwin.org@…, 20 years ago) |
---|
-
base/src/pextlib1.0/Makefile
cvs server: Diffing base cvs server: Diffing base/Mk cvs server: Diffing base/doc cvs server: Diffing base/doc/exampleport cvs server: Diffing base/src cvs server: Diffing base/src/cflib1.0 cvs server: Diffing base/src/darwinports1.0 cvs server: Diffing base/src/package1.0 cvs server: Diffing base/src/pextlib1.0 RCS file: /Volumes/src/cvs/od/projects/darwinports/base/src/pextlib1.0/Makefile,v retrieving revision 1.37 diff -u -r1.37 Makefile
1 1 OBJS= Pextlib.o strsed.o fgetln.o md5cmd.o setmode.o xinstall.o \ 2 find.o strcasecmp.o vercomp.o filemap.o 2 find.o strcasecmp.o vercomp.o filemap.o \ 3 sha1cmd.o 3 4 SHLIB_NAME= Pextlib${SHLIB_SUFFIX} 4 5 INSTALLDIR= ${DESTDIR}${datadir}/darwinports/Tcl/pextlib1.0 5 6 -
base/src/pextlib1.0/Pextlib.c
RCS file: /Volumes/src/cvs/od/projects/darwinports/base/src/pextlib1.0/Pextlib.c,v retrieving revision 1.66 diff -u -r1.66 Pextlib.c
94 94 #include <tcl.h> 95 95 96 96 #include "md5cmd.h" 97 #include "sha1cmd.h" 97 98 #include "find.h" 98 99 #include "filemap.h" 99 100 #include "xinstall.h" … … 716 717 Tcl_CreateObjCommand(interp, "find", FindCmd, NULL, NULL); 717 718 Tcl_CreateObjCommand(interp, "filemap", FilemapCmd, NULL, NULL); 718 719 Tcl_CreateObjCommand(interp, "rpm-vercomp", RPMVercompCmd, NULL, NULL); 720 Tcl_CreateObjCommand(interp, "sha1", SHA1Cmd, NULL, NULL); 719 721 if(Tcl_PkgProvide(interp, "Pextlib", "1.0") != TCL_OK) 720 722 return TCL_ERROR; 721 723 return TCL_OK; -
base/src/port1.0/portchecksum.tcl
cvs server: Diffing base/src/pextlib1.0/tests cvs server: Diffing base/src/port cvs server: Diffing base/src/port1.0 RCS file: /Volumes/src/cvs/od/projects/darwinports/base/src/port1.0/portchecksum.tcl,v retrieving revision 1.33 diff -u -r1.33 portchecksum.tcl
45 45 46 46 set_ui_prefix 47 47 48 # dmd548 # get_checksum 49 49 # 50 # Returns the expected checksum for the given file.51 # If no checksum is found, returns -1.50 # Returns the expected md5/sha1/etc. checksum for the given file. 51 # If no md5/sha1/etc. checksum is found, returns -1. 52 52 # 53 proc dmd5 {file} {54 foreach {name type sum} [option checksums]{53 proc get_checksum {file want_sum port_checksums} { 54 foreach {name type sum} $port_checksums { 55 55 if {[string equal $name $file]} { 56 return $sum 56 if {[string equal $type $want_sum]} { 57 return $sum 58 } 57 59 } 58 60 } 59 61 … … 77 79 proc checksum_main {args} { 78 80 global UI_PREFIX all_dist_files 79 81 82 # we'll count how many successful checksums we get... 83 ## set chksum_success 0 84 85 # list of known checksum types: 86 set checksum_types [list "md5" "sha1"] 87 80 88 # If no files have been downloaded, there is nothing to checksum. 81 89 if {![info exists all_dist_files]} { 82 90 return 0 83 91 } 84 92 85 93 # Optimization for the two-argument case for checksums. 86 if {[llength [option checksums]] == 2 && [llength $all_dist_files] == 1} { 87 option checksums [linsert [option checksums] 0 $all_dist_files] 94 set port_checksums "" 95 foreach {type sum} [option checksums] { 96 ## see if $type is one of our known checksum types. If it is, 97 ## we assume we don't have our dist file name. Check that 98 ## we only expect 1 dist file as well... If we have only 99 ## one dist file and $type is a checksum_type, the add the 100 ## $all_dist_files to the start of the checksum list. 101 if {[lsearch -exact $checksum_types $type] != -1 && \ 102 [llength $all_dist_files] == 1} { 103 set port_checksums [linsert $port_checksums 0 $all_dist_files $type $sum] 104 } 105 } 106 ## if we didn't do the above filename insertions, we have an empty $port_checksums, 107 ## so copy over the [option checksums] and use $port_checksums from here out 108 if {[llength $port_checksums] == 0} { 109 set port_checksums [option checksums] 88 110 } 89 111 90 112 set fail no 91 113 92 114 foreach distfile $all_dist_files { 93 115 ui_info "$UI_PREFIX [format [msgcat::mc "Checksumming %s"] $distfile]" 116 set distfile_chksum_success 0 94 117 95 # Calculate the distfile's checksum. 96 set checksum [md5 file [file join [option distpath] $distfile]] 97 98 # Find the expected checksum. 99 set dchecksum [dmd5 $distfile] 100 101 # Check for missing checksum or a mismatch. 102 if {$dchecksum == -1} { 103 ui_error "[format [msgcat::mc "No checksum set for %s"] $distfile]" 104 } elseif {![string equal $checksum $dchecksum]} { 105 ui_error "[format [msgcat::mc "Checksum mismatch for %s"] $distfile]" 106 } else { 107 continue 118 foreach chksum_type $checksum_types { 119 # Calculate the distfile's checksum. 120 set checksum [$chksum_type file [file join [option distpath] $distfile]] 121 122 # Find the expected checksum. 123 set dchecksum [get_checksum $distfile $chksum_type $port_checksums] 124 125 # Check for missing checksum or a mismatch. 126 if {$dchecksum == -1} { 127 ui_info "[format [msgcat::mc "No %s checksum set for %s"] $chksum_type $distfile]" 128 } elseif {![string equal $checksum $dchecksum]} { 129 ui_error "[format [msgcat::mc "%s checksum mismatch for '%s':"] $chksum_type $distfile]" 130 ui_error "[format [msgcat::mc "wanted '%s',"] $dchecksum]" 131 ui_error "[format [msgcat::mc " got '%s'"] $checksum]" 132 # Raise the failure flag 133 set fail yes 134 } else { 135 set distfile_chksum_success [expr $distfile_chksum_success + 1] 136 } 137 138 if {[tbool fail]} { 139 return -code error "[format [msgcat::mc "Unable to verify %s checksum"] $chksum_type]" 140 } 141 ## else just fall to the next checksum... 142 143 if {$dchecksum != -1} { 144 # Post file checksum 145 ui_info "[format [msgcat::mc "Correct %s checksum: %s %s %s"] $chksum_type ${distfile} $chksum_type ${checksum}]" 146 } 108 147 } 109 148 110 # Post file checksum 111 ui_info "[format [msgcat::mc "Correct checksum: %s %s %s"] ${distfile} md5 ${checksum}]" 112 113 # Raise the failure flag 114 set fail yes 149 if {$distfile_chksum_success == 0} { 150 ## oh bother, no successful checksum for this dist file, bailage 151 return -code error "[format [msgcat::mc "No checksums set for %s"] $distfile]" 152 } 115 153 } 154 ## set chksum_success [expr $chksum_success + $distfile_chksum_success] 116 155 117 if {[tbool fail]} {118 return -code error "[msgcat::mc "Unable to verify file checksums"]"119 }156 ## if {$chksum_success < 1 } { 157 ## return -code error "[msgcat::mc "Unable to verify file checksums"]" 158 ## } 120 159 121 160 return 0 122 161 }