Skip to content

Commit

Permalink
Item1338: add SHA1 checksum
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.foswiki.org/trunk@3223 0b4bb1d4-4e5a-0410-9cc4-b2b747904278
  • Loading branch information
WillNorris authored and WillNorris committed Mar 20, 2009
1 parent 1398e40 commit 8584d1d
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion BuildContrib/lib/Foswiki/Contrib/Build.pm
Expand Up @@ -1187,9 +1187,10 @@ sub target_archive {
foreach my $f qw(.tgz _installer .zip) {
push( @fs, "$target$f" ) if ( -e "$target$f" );
}

eval "require Digest::MD5";
if ($@) {
print STDERR "WARNING: Digest::MD5 not installed; cannot checksum\n";
print STDERR "WARNING: Digest::MD5 not installed; cannot generate MD5 checksum\n";
}
else {
open( CS, '>', "$target.md5" ) || die $!;
Expand All @@ -1204,6 +1205,25 @@ sub target_archive {
close(CS);
print "MD5 checksums in $this->{basedir}/$target.md5\n";
}

eval "require Digest::SHA";
if ($@) {
print STDERR "WARNING: Digest::SHA not installed; cannot generate SHA1 checksum\n";
}
else {
open( CS, '>', "$target.sha1" ) || die $!;
foreach my $file (@fs) {
open( F, '<', $file );
local $/;
my $data = <F>;
close(F);
my $cs = Digest::SHA::sha1_hex($data);
print CS "$cs $file\n";
}
close(CS);
print "SHA1 checksums in $this->{basedir}/$target.sha1\n";
}

$this->popd();
$this->popd();

Expand Down

0 comments on commit 8584d1d

Please sign in to comment.