diff options
author | Norbert Preining <preining@logic.at> | 2016-04-12 06:10:52 +0000 |
---|---|---|
committer | Norbert Preining <preining@logic.at> | 2016-04-12 06:10:52 +0000 |
commit | c9367258a3cd0e44e0d82bb91dd0c33e25443cda (patch) | |
tree | 485dff105ded626e7a75a24ac54042568f68de2e /Master/tlpkg | |
parent | ab3d7a43c88e88e3c6d26b2cd6cce44cafec6144 (diff) |
reintroduce verify_checksum, single out code, adapt tlmgr
tlmgr uses verify_checksum to verify the downloaded tlpdb copy
with the remote checksum to reduce loading time. Reintroduce
verify_checksum, single out the code from verify_download,
and adjust tlmgr to new calling convention that second
argument is already the url for the checksum
git-svn-id: svn://tug.org/texlive/trunk@40446 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/tlpkg')
-rw-r--r-- | Master/tlpkg/TeXLive/TLUtils.pm | 56 |
1 files changed, 38 insertions, 18 deletions
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm index 23abd1f9f3d..715517f57f7 100644 --- a/Master/tlpkg/TeXLive/TLUtils.pm +++ b/Master/tlpkg/TeXLive/TLUtils.pm @@ -101,6 +101,7 @@ C<TeXLive::TLUtils> -- utilities used in TeX Live infrastructure TeXLive::TLUtils::tlmd5($path); TeXLive::TLUtils::tlchecksum($path); TeXLive::TLUtils::setup_gpg(); + TeXLive::TLUtils::verify_checksum($file, $url); TeXLive::TLUtils::verify_download($file, $url); TeXLive::TLUtils::compare_tlpobjs($tlpA, $tlpB); TeXLive::TLUtils::compare_tlpdbs($tlpdbA, $tlpdbB); @@ -178,6 +179,7 @@ BEGIN { &tlmd5 &tlchecksum &setup_gpg + &verify_checksum &verify_download &wsystem &xsystem @@ -3672,6 +3674,41 @@ sub slurp_file { =pod +=item C<< verify_checksum($file, $checksum_url) >> + +Verifies that C<$file> has cecksum C<$checksum_url>. + +Returns 1 on success, and a pair of 0 and a warning otherwise. + +=cut + +sub verify_checksum { + my ($file, $checksum_url) = @_; + my $checksum_file = download_to_temp_or_file($checksum_url); + # next step is verification of tlpdb checksum with checksum file + # existenc of checksum_file was checked above + open $cs_fh, "<$checksum_file" or die("cannot read file: $!"); + if (read ($cs_fh, $remote_digest, $ChecksumLength) != $ChecksumLength) { + close($cs_fh); + return(0, "read error from $checksum_file"); + } else { + close($cs_fh); + ddebug("found remote digest: $remote_digest\n"); + } + $local_digest = tlchecksum($file); + ddebug("local_digest = $local_digest\n"); + if ($local_digest ne $remote_digest) { + return(0, "checksum error"); + } + + # we are still here, so checksum also succeeded + debug("checksum of local copy identical with remote hash\n"); + + return(1); +} + +=pod + =item C<< verify_download($file, $url) >> Verifies a download of C<$url> into C<$file> by checking C<$url.checksum> @@ -3741,24 +3778,7 @@ GPGERROR # next step is verification of tlpdb checksum with checksum file # existenc of checksum_file was checked above - open $cs_fh, "<$checksum_file" or die("cannot read file: $!"); - if (read ($cs_fh, $remote_digest, $ChecksumLength) != $ChecksumLength) { - close($cs_fh); - return(0, "read error from $checksum_file"); - } else { - close($cs_fh); - ddebug("found remote digest: $remote_digest\n"); - } - $local_digest = tlchecksum($file); - ddebug("local_digest = $local_digest\n"); - if ($local_digest ne $remote_digest) { - return(0, "checksum error"); - } - - # we are still here, so checksum also succeeded - debug("checksum of local copy identical with remote hash\n"); - - return(1); + return verify_checksum($file, $checksum_file); } sub gpg_verify_signature { |