summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Master/tlpkg/TeXLive/TLCrypto.pm41
1 files changed, 32 insertions, 9 deletions
diff --git a/Master/tlpkg/TeXLive/TLCrypto.pm b/Master/tlpkg/TeXLive/TLCrypto.pm
index 8cd1ded425c..ac095bce5b5 100644
--- a/Master/tlpkg/TeXLive/TLCrypto.pm
+++ b/Master/tlpkg/TeXLive/TLCrypto.pm
@@ -75,18 +75,36 @@ sub setup_checksum_method {
eval {
require Digest::SHA;
Digest::SHA->import('sha512_hex');
+ debug("Using checksum method digest::sha\n");
$::checksum_method = "digest::sha";
};
- if ($@) {
- # ok, Digest::SHA is not available, try to find either the openssl
- # or sha512sum programs
- if (TeXLive::TLUtils::which("openssl")) {
- $::checksum_method = "openssl";
- } elsif (TeXLive::TLUtils::which("sha512sum")) {
- $::checksum_method = "sha512sum";
- } else {
- debug("Cannot find usable checksum method!\n");
+ if ($@ && ($^O !~ /^MSWin/i)) {
+ # for unix like environments we test other programs (openssl, sha512sum,
+ # shasum), too
+ my $ret;
+
+ # first for openssl dgst -sha512
+ # old MacOS openssl does not support -sha512!
+ $ret = system("openssl dgst -sha512 >/dev/null 2>&1 </dev/null" );
+ if ($ret == 0) {
+ debug("Using checksum method openssl\n");
+ return($::checksum_method = "openssl");
+ }
+
+ # next for sha512sum, but this is not available on old MacOS
+ if (TeXLive::TLUtils::which("sha512sum")) {
+ debug("Using checksum method sha512sum\n");
+ return($::checksum_method = "sha512sum");
+ }
+
+ # shasum for old Macs
+ $ret = system("shasum -a 512 >/dev/null 2>&1 </dev/null" );
+ if ($ret == 0) {
+ debug("Using checksum method shasum\n");
+ return($::checksum_method = "shasum");
}
+
+ debug("Cannot find usable checksum method!\n");
}
return($::checksum_method);
}
@@ -113,6 +131,9 @@ sub tlchecksum {
} elsif ($::checksum_method eq "sha512sum") {
($out, $ret) = TeXLive::TLUtils::run_cmd("sha512sum $file");
chomp($out);
+ } elsif ($::checksum_method eq "shasum") {
+ ($out, $ret) = TeXLive::TLUtils::run_cmd("shasum -a 512 $file");
+ chomp($out);
} elsif ($::checksum_method eq "digest::sha") {
open(FILE, $file) || die "open($file) failed: $!";
binmode(FILE);
@@ -132,6 +153,8 @@ sub tlchecksum {
(undef,$cs) = split(/= /,$out);
} elsif ($::checksum_method eq "sha512sum") {
($cs,undef) = split(' ',$out);
+ } elsif ($::checksum_method eq "shasum") {
+ ($cs,undef) = split(' ',$out);
} elsif ($::checksum_method eq "digest::sha") {
$cs = $out;
}