summaryrefslogtreecommitdiff
path: root/Master/tlpkg/TeXLive
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2016-04-29 05:06:28 +0000
committerNorbert Preining <preining@logic.at>2016-04-29 05:06:28 +0000
commitde0a8413669db9c073974326e54efb36af99489f (patch)
tree30272de6038041540a667951029727a0430a68ff /Master/tlpkg/TeXLive
parent3ddd55c0ee5026c902bf1370a40d5b91b1d28e5b (diff)
TLCrypto: use only openssl if sha512 support, add shasum
git-svn-id: svn://tug.org/texlive/trunk@40811 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg/TeXLive')
-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;
}