From 60f8fa4451942e4a7ef6236bdda2ac3281f2ea12 Mon Sep 17 00:00:00 2001 From: Clinton Gormley Date: Wed, 5 Aug 2015 13:58:09 +0200 Subject: [PATCH] Added pure perl fallback for Digest::SHA for old windows boxes --- .../license-check/check_license_and_sha.pl | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/dev-tools/src/main/resources/license-check/check_license_and_sha.pl b/dev-tools/src/main/resources/license-check/check_license_and_sha.pl index 5af5b6b18ed..cc5f5b02773 100755 --- a/dev-tools/src/main/resources/license-check/check_license_and_sha.pl +++ b/dev-tools/src/main/resources/license-check/check_license_and_sha.pl @@ -8,11 +8,22 @@ use lib "$RealBin/lib"; use File::Spec(); use File::Temp(); use File::Find(); -use Digest::SHA qw(sha1); use File::Basename qw(basename); use Archive::Extract(); $Archive::Extract::PREFER_BIN = 1; +our $SHA_CLASS = 'Digest::SHA'; +if ( eval { require Digest::SHA } ) { + $SHA_CLASS = 'Digest::SHA'; +} +else { + + print STDERR "Digest::SHA not available. " + . "Falling back to Digest::SHA::PurePerl\n"; + require Digest::SHA::PurePerl; + $SHA_CLASS = 'Digest::SHA::PurePerl'; +} + my $mode = shift(@ARGV) || ""; die usage() unless $mode =~ /^--(check|update)$/; @@ -230,7 +241,7 @@ sub calculate_shas { #=================================== my %shas; while ( my $file = shift() ) { - my $digest = eval { Digest::SHA->new(1)->addfile($file) } + my $digest = eval { $SHA_CLASS->new(1)->addfile($file) } or die "Error calculating SHA1 for <$file>: $!\n"; $shas{ basename($file) . ".sha1" } = $digest->hexdigest; }