Index: Setup/verify.eagle ================================================================== --- Setup/verify.eagle +++ Setup/verify.eagle @@ -20,11 +20,11 @@ # NOTE: Indicate to the caller, if any, that we have failed. # exit 1 } -proc getSha1Hashes { varName } { +proc getFileHashes { varName } { variable fossil upvar 1 $varName hashes set data [exec -success Success -nocarriagereturns -- \ @@ -39,11 +39,11 @@ if {[llength $fields] >= 3} then { set fileName [string map [list \\s " "] [lindex $fields 1]] set hash [lindex $fields 2] - if {[regexp -- {[0-9a-f]{40}} $hash]} then { + if {[regexp -- {[0-9a-f]{40,64}} $hash]} then { set hashes($fileName) $hash; incr result } } } } @@ -58,10 +58,23 @@ -trimall -- $fossil sha1sum [appendArgs \" $fileName \"]] 0 39] if {[regexp -- {[0-9a-f]{40}} $hash]} then { return $hash } + + return "" +} + +proc getSha3Sum { fileName } { + variable fossil + + set hash [string range [exec -success Success -nocarriagereturns \ + -trimall -- $fossil sha3sum [appendArgs \" $fileName \"]] 0 63] + + if {[regexp -- {[0-9a-f]{64}} $hash]} then { + return $hash + } return "" } set argc [llength $argv] @@ -164,11 +177,11 @@ if {$withHashes} then { if {![file exists $fossil]} then { usage [appendArgs "tool \"" $fossil "\" is missing"] } - if {[getSha1Hashes hashes] == 0} then { + if {[getFileHashes hashes] == 0} then { usage "no repository hashes are available" } } set hashPrefix [expr {$failHashes ? "ERROR" : "WARNING"}] @@ -307,19 +320,19 @@ set exitCode 1 } # - # NOTE: Skip checking SHA1 hashes if it was not requested on the + # NOTE: Skip checking hashes if that was not requested on the # command line. # if {!$withHashes} then { continue } # - # HACK: For now, only verify SHA1 hashes for those files actually + # HACK: For now, only verify hashes for those files actually # present in the repository. # if {![string match -nocase -- *Source* $archiveFileName] && \ ![info exists hashes($manifestFileName)]} then { continue @@ -347,11 +360,15 @@ try { if {[info exists hashes($manifestFileName)]} then { if {[catch { eval [string map $extractCommandMap $extractCommand] } result] == 0} then { - set hash [getSha1Sum $extractFileName] + if {[string length $hashes($manifestFileName)] == 64} then { + set hash [getSha3Sum $extractFileName] + } else { + set hash [getSha1Sum $extractFileName] + } if {[string length $hash] > 0} then { if {$hash ne $hashes($manifestFileName)} then { puts stdout [appendArgs \ $hashPrefix ": Archive \"" $archiveFileName \