summaryrefslogtreecommitdiff
path: root/Master
diff options
context:
space:
mode:
authorNorbert Preining <preining@logic.at>2016-04-12 06:11:21 +0000
committerNorbert Preining <preining@logic.at>2016-04-12 06:11:21 +0000
commit6a22f5f0018dc68b01d241a55c514a7f8755dd11 (patch)
treedd30f53ab68f7d798defecb946693aec6286a17b /Master
parent601410ed8ee3c502bc016ac493666002013d217d (diff)
make verify_* return values numeric with informal messages
git-svn-id: svn://tug.org/texlive/trunk@40449 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master')
-rwxr-xr-xMaster/texmf-dist/scripts/texlive/tlmgr.pl19
-rw-r--r--Master/tlpkg/TeXLive/TLPDB.pm2
-rw-r--r--Master/tlpkg/TeXLive/TLUtils.pm38
3 files changed, 35 insertions, 24 deletions
diff --git a/Master/texmf-dist/scripts/texlive/tlmgr.pl b/Master/texmf-dist/scripts/texlive/tlmgr.pl
index a0f7a2d27fa..ee9117222ab 100755
--- a/Master/texmf-dist/scripts/texlive/tlmgr.pl
+++ b/Master/texmf-dist/scripts/texlive/tlmgr.pl
@@ -5857,9 +5857,8 @@ sub setup_one_remotetlpdb {
ddebug("remote path of digest = $path\n");
my ($ret, $msg) = TeXLive::TLUtils::verify_checksum($loc_copy_of_remote_tlpdb, "$path.checksum");
- if (!$ret) {
- if (($msg eq "file not found") || ($msg eq "read error") || ($msg eq "digest not found")) {
- info(<<END_NO_INTERNET);
+ if ($ret < 0) {
+ info(<<END_NO_INTERNET);
No connection to the internet.
Unable to download the checksum of the remote TeX Live database,
but found a local copy so using that.
@@ -5871,15 +5870,11 @@ http://tug.org/texlive/doc/install-tl.html
END_NO_INTERNET
# above text duplicated in install-tl
-
- $remotetlpdb = TeXLive::TLPDB->new(root => $location,
- tlpdbfile => $loc_copy_of_remote_tlpdb);
- $local_copy_tlpdb_used = 1;
- } elsif ($msg eq "checksum error") {
- # no problem, reload it!
- } else {
- tlwarn("Unknown return message from verify_checksum: $msg\n");
- }
+ $remotetlpdb = TeXLive::TLPDB->new(root => $location,
+ tlpdbfile => $loc_copy_of_remote_tlpdb);
+ $local_copy_tlpdb_used = 1;
+ } elsif ($ret > 0) {
+ # no problem, checksum is wrong, we need to get new tlpdb
} else {
debug("checksum of local copy identical with remote hash\n");
$remotetlpdb = TeXLive::TLPDB->new(root => $location,
diff --git a/Master/tlpkg/TeXLive/TLPDB.pm b/Master/tlpkg/TeXLive/TLPDB.pm
index edbabc1c46c..658eafdb316 100644
--- a/Master/tlpkg/TeXLive/TLPDB.pm
+++ b/Master/tlpkg/TeXLive/TLPDB.pm
@@ -363,7 +363,7 @@ sub from_file {
#
# before we open and proceed, verify the downloaded file
my ($r, $m) = TeXLive::TLUtils::verify_download($tlpdbfile, $path);
- if (!$r) {
+ if ($r != 0) {
tldie("$0: verification of $tlpdbfile from $path failed ($r): $m\n");
}
open($retfh, "<$tlpdbfile") || die "$0: open($tlpdbfile) failed: $!";
diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm
index dcc3309f333..115b98cb6dd 100644
--- a/Master/tlpkg/TeXLive/TLUtils.pm
+++ b/Master/tlpkg/TeXLive/TLUtils.pm
@@ -3676,9 +3676,10 @@ sub slurp_file {
=item C<< verify_checksum($file, $checksum_url) >>
-Verifies that C<$file> has cecksum C<$checksum_url>.
+Verifies that C<$file> has checksum C<$checksum_url>.
-Returns 1 on success, and a pair of 0 and a warning otherwise.
+Returns 0 on success, -1 on connection error, 1 on checksum error.
+In case of errors returns an informal message as second argument.
=cut
@@ -3687,10 +3688,13 @@ sub verify_checksum {
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
+ if (!$checksum_file) {
+ return(-1, "download did not succeed: $checksum_url");
+ }
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");
+ return(1, "incomplete read from $checksum_file");
} else {
close($cs_fh);
ddebug("found remote digest: $remote_digest\n");
@@ -3698,23 +3702,23 @@ sub verify_checksum {
$local_digest = tlchecksum($file);
ddebug("local_digest = $local_digest\n");
if ($local_digest ne $remote_digest) {
- return(0, "checksum error");
+ return(1, "digest disagree");
}
# we are still here, so checksum also succeeded
debug("checksum of local copy identical with remote hash\n");
- return(1);
+ return(0);
}
=pod
-=item C<< verify_download($file, $url) >>
+=item C<< download_to_temp_or_file($url) >>
-Verifies a download of C<$url> into C<$file> by checking C<$url.checksum>
-and if gpg is available, verifying that with C<$url.checksum.asc>.
+If C<$url> tries to download the file into a temporary file.
+In both cases returns the local file.
-Returns 1 on success, and a pair of 0 and a warning otherwise.
+Returns the local file name if succeeded, otherwise undef.
=cut
@@ -3739,6 +3743,18 @@ sub download_to_temp_or_file {
return;
}
+=pod
+
+=item C<< verify_download($file, $url) >>
+
+Verifies a download of C<$url> into C<$file> by checking C<$url.checksum>
+and if gpg is available, verifying that with C<$url.checksum.asc>.
+
+Returns 0 on success, -1 on connection error, 1 on checksum error.
+In case of errors returns an informal message as second argument.
+
+=cut
+
sub verify_download {
my ($file, $url) = @_;
# download checksum file
@@ -3748,7 +3764,7 @@ sub verify_download {
my $checksum_file = download_to_temp_or_file($checksum_url);
if (!$checksum_file) {
# we do not accept if not even a checksum file is present, error out
- return(0, "checksum file not found");
+ return(-1, "download did not succeed: $checksum_url");
}
# if we have $::gpg set, we try to verify cryptographic signatures
@@ -3758,7 +3774,7 @@ sub verify_download {
if (TeXLive::TLUtils::gpg_verify_signature($checksum_file, $signature_file)) {
info("cryptographic signature of $checksum_url verified\n");
} else {
- return(0, <<GPGERROR);
+ return(1, <<GPGERROR);
cryptograpic verification of
$checksum_url
against