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
Index: base/src/pextlib1.0/Makefile
===================================================================
RCS file: /Volumes/src/cvs/od/projects/darwinports/base/src/pextlib1.0/Makefile,v
retrieving revision 1.37
diff -u -r1.37 Makefile
--- base/src/pextlib1.0/Makefile	1 Jul 2004 17:21:12 -0000	1.37
+++ base/src/pextlib1.0/Makefile	8 Sep 2004 07:19:44 -0000
@@ -1,5 +1,6 @@
 OBJS=		Pextlib.o strsed.o fgetln.o md5cmd.o setmode.o xinstall.o \
-		find.o strcasecmp.o vercomp.o filemap.o
+		find.o strcasecmp.o vercomp.o filemap.o \
+		sha1cmd.o
 SHLIB_NAME=	Pextlib${SHLIB_SUFFIX}
 INSTALLDIR= ${DESTDIR}${datadir}/darwinports/Tcl/pextlib1.0
 
Index: 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
--- base/src/pextlib1.0/Pextlib.c	4 Jul 2004 06:51:27 -0000	1.66
+++ base/src/pextlib1.0/Pextlib.c	8 Sep 2004 07:19:44 -0000
@@ -94,6 +94,7 @@
 #include <tcl.h>
 
 #include "md5cmd.h"
+#include "sha1cmd.h"
 #include "find.h"
 #include "filemap.h"
 #include "xinstall.h"
@@ -716,6 +717,7 @@
 	Tcl_CreateObjCommand(interp, "find", FindCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "filemap", FilemapCmd, NULL, NULL);
 	Tcl_CreateObjCommand(interp, "rpm-vercomp", RPMVercompCmd, NULL, NULL);
+	Tcl_CreateObjCommand(interp, "sha1", SHA1Cmd, NULL, NULL);
 	if(Tcl_PkgProvide(interp, "Pextlib", "1.0") != TCL_OK)
 		return TCL_ERROR;
 	return TCL_OK;
cvs server: Diffing base/src/pextlib1.0/tests
cvs server: Diffing base/src/port
cvs server: Diffing base/src/port1.0
Index: base/src/port1.0/portchecksum.tcl
===================================================================
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
--- base/src/port1.0/portchecksum.tcl	5 May 2004 19:31:02 -0000	1.33
+++ base/src/port1.0/portchecksum.tcl	8 Sep 2004 07:19:45 -0000
@@ -45,15 +45,17 @@
 
 set_ui_prefix
 
-# dmd5
+# get_checksum
 #
-# Returns the expected checksum for the given file.
-# If no checksum is found, returns -1.
+# Returns the expected md5/sha1/etc. checksum for the given file.
+# If no md5/sha1/etc. checksum is found, returns -1.
 #
-proc dmd5 {file} {
-	foreach {name type sum} [option checksums] {
+proc get_checksum {file want_sum port_checksums} {
+	foreach {name type sum} $port_checksums {
 		if {[string equal $name $file]} {
-			return $sum
+			if {[string equal $type $want_sum]} {
+				return $sum
+			}
 		}
 	}
 
@@ -77,46 +79,83 @@
 proc checksum_main {args} {
 	global UI_PREFIX all_dist_files
 
+	# we'll count how many successful checksums we get...
+##	set chksum_success 0
+
+	# list of known checksum types:
+	set checksum_types [list "md5" "sha1"]
+
 	# If no files have been downloaded, there is nothing to checksum.
 	if {![info exists all_dist_files]} {
 		return 0
 	}
 
 	# Optimization for the two-argument case for checksums.
-	if {[llength [option checksums]] == 2 && [llength $all_dist_files] == 1} {
-		option checksums [linsert [option checksums] 0 $all_dist_files]
+	set port_checksums ""
+	foreach {type sum} [option checksums] {
+		## see if $type is one of our known checksum types.  If it is, 
+		## we assume we don't have our dist file name.  Check that
+		## we only expect 1 dist file as well...  If we have only
+		## one dist file and $type is a checksum_type, the add the
+		## $all_dist_files to the start of the checksum list.
+		if {[lsearch -exact $checksum_types $type] != -1 && \
+			[llength $all_dist_files] == 1} {
+			set port_checksums [linsert $port_checksums 0 $all_dist_files $type $sum]
+		}
+	}
+	## if we didn't do the above filename insertions, we have an empty $port_checksums,
+	## so copy over the [option checksums] and use $port_checksums from here out
+	if {[llength $port_checksums] == 0} {
+		set port_checksums [option checksums]
 	}
 
 	set fail no
 
 	foreach distfile $all_dist_files {
 		ui_info "$UI_PREFIX [format [msgcat::mc "Checksumming %s"] $distfile]"
+		set distfile_chksum_success 0
 
-		# Calculate the distfile's checksum.
-		set checksum [md5 file [file join [option distpath] $distfile]]
-
-		# Find the expected checksum.
-		set dchecksum [dmd5 $distfile]
-
-		# Check for missing checksum or a mismatch.
-		if {$dchecksum == -1} {
-			ui_error "[format [msgcat::mc "No checksum set for %s"] $distfile]"
-		} elseif {![string equal $checksum $dchecksum]} {
-			ui_error "[format [msgcat::mc "Checksum mismatch for %s"] $distfile]"
-		} else {
-			continue
+		foreach chksum_type $checksum_types {
+			# Calculate the distfile's checksum.
+			set checksum [$chksum_type file [file join [option distpath] $distfile]]
+	
+			# Find the expected checksum.
+			set dchecksum [get_checksum $distfile $chksum_type $port_checksums]
+	
+			# Check for missing checksum or a mismatch.
+			if {$dchecksum == -1} {
+				ui_info "[format [msgcat::mc "No %s checksum set for %s"] $chksum_type $distfile]"
+			} elseif {![string equal $checksum $dchecksum]} {
+				ui_error "[format [msgcat::mc "%s checksum mismatch for '%s':"] $chksum_type $distfile]"
+				ui_error "[format [msgcat::mc "wanted '%s',"] $dchecksum]"
+				ui_error "[format [msgcat::mc "   got '%s'"] $checksum]"
+				# Raise the failure flag
+				set fail yes
+			} else {
+				set distfile_chksum_success [expr $distfile_chksum_success + 1]
+			}
+	
+			if {[tbool fail]} {
+				return -code error "[format [msgcat::mc "Unable to verify %s checksum"] $chksum_type]"
+			}
+			## else just fall to the next checksum...
+	
+			if {$dchecksum != -1} {
+				# Post file checksum
+				ui_info "[format [msgcat::mc "Correct %s checksum: %s %s %s"] $chksum_type ${distfile} $chksum_type ${checksum}]"
+			}
 		}
 
-		# Post file checksum
-		ui_info "[format [msgcat::mc "Correct checksum: %s %s %s"] ${distfile} md5 ${checksum}]"
-
-		# Raise the failure flag
-		set fail yes
+		if {$distfile_chksum_success == 0} {
+			## oh bother, no successful checksum for this dist file, bailage
+			return -code error "[format [msgcat::mc "No checksums set for %s"] $distfile]"
+		}
 	}
+##	set chksum_success [expr $chksum_success + $distfile_chksum_success]
 
-	if {[tbool fail]} {
-		return -code error "[msgcat::mc "Unable to verify file checksums"]"
-	}
+##	if {$chksum_success < 1 } {
+##		return -code error "[msgcat::mc "Unable to verify file checksums"]"
+##	}
 
 	return 0
 }
cvs server: Diffing base/src/port1.0/resources
cvs server: Diffing base/src/port1.0/resources/fetch
cvs server: Diffing base/src/port1.0/resources/group
cvs server: Diffing base/src/port1.0/resources/package
cvs server: Diffing base/src/portindex
cvs server: Diffing base/src/portmgr
cvs server: Diffing base/src/programs
cvs server: Diffing base/src/programs/mtree
cvs server: Diffing base/src/registry1.0
