texlive[46421] Master/tlpkg/TeXLive: better debugging and stronger

commits+preining at tug.org commits+preining at tug.org
Wed Jan 24 04:55:36 CET 2018


Revision: 46421
          http://tug.org/svn/texlive?view=revision&revision=46421
Author:   preining
Date:     2018-01-24 04:55:35 +0100 (Wed, 24 Jan 2018)
Log Message:
-----------
better debugging and stronger integrity checks

Modified Paths:
--------------
    trunk/Master/tlpkg/TeXLive/TLCrypto.pm
    trunk/Master/tlpkg/TeXLive/TLPDB.pm
    trunk/Master/tlpkg/TeXLive/TLUtils.pm

Modified: trunk/Master/tlpkg/TeXLive/TLCrypto.pm
===================================================================
--- trunk/Master/tlpkg/TeXLive/TLCrypto.pm	2018-01-24 01:18:01 UTC (rev 46420)
+++ trunk/Master/tlpkg/TeXLive/TLCrypto.pm	2018-01-24 03:55:35 UTC (rev 46421)
@@ -180,7 +180,7 @@
     } elsif ($::checksum_method eq "digest::sha") {
       $cs = $out;
     }
-    ddebug("tlchecksum: cs ===$cs===\n");
+    debug("tlchecksum($file): ===$cs===\n");
     if (length($cs) != 128) {
       tlwarn("unexpected output from $::checksum_method: $out\n");
       return "";
@@ -247,23 +247,29 @@
   # next step is verification of tlpdb checksum with checksum file
   # existenc of checksum_file was checked above
   if (!$checksum_file) {
+    debug("verify_checksum: download did not succeed for $checksum_url\n");
     return($VS_CONNECTION_ERROR, "download did not succeed: $checksum_url");
   }
   # check the signature
   my ($ret, $msg) = verify_signature($checksum_file, $checksum_url);
-  return ($ret, $msg) if ($ret != 0);
 
+  if ($ret != 0) {
+    debug("verify_checksum: returning $ret and $msg\n");
+    return ($ret, $msg)
+  }
+
   # verify local data
   open $cs_fh, "<$checksum_file" or die("cannot read file: $!");
   if (read ($cs_fh, $remote_digest, $ChecksumLength) != $ChecksumLength) {
     close($cs_fh);
+    debug("verify_checksum: incomplete read from\n  $checksum_file\nfor\n  $file\nand\n  $checksum_url\n");
     return($VS_CHECKSUM_ERROR, "incomplete read from $checksum_file");
   } else {
     close($cs_fh);
-    ddebug("found remote digest: $remote_digest\n");
+    debug("verify_checksum: found remote digest\n  $remote_digest\nfrom\n  $checksum_file\nfor\n  $file\nand\n  $checksum_url\n");
   }
   $local_digest = tlchecksum($file);
-  ddebug("local_digest = $local_digest\n");
+  debug("verify_checksum: local_digest = $local_digest\n");
   if ($local_digest ne $remote_digest) {
     return($VS_CHECKSUM_ERROR, "digest disagree");
   }

Modified: trunk/Master/tlpkg/TeXLive/TLPDB.pm
===================================================================
--- trunk/Master/tlpkg/TeXLive/TLPDB.pm	2018-01-24 01:18:01 UTC (rev 46420)
+++ trunk/Master/tlpkg/TeXLive/TLPDB.pm	2018-01-24 03:55:35 UTC (rev 46421)
@@ -1896,7 +1896,7 @@
     } elsif (&media eq 'NET') {
       $container = "$root/$Archive/$pkg.$TeXLive::TLConfig::DefaultContainerExtension";
     }
-    $self->_install_data ($container, $reloc, \@installfiles, $totlpdb, $tlpobj->containersize, $tlpobj->containermd5)
+    $self->_install_data ($container, $reloc, \@installfiles, $totlpdb, $tlpobj->containersize, $tlpobj->containerchecksum)
       || return(0);
     # if we are installing from local_compressed or NET we have to fetch the respective
     # source and doc packages $pkg.source and $pkg.doc and install them, too
@@ -1915,13 +1915,13 @@
       if ($container_src_split && $opt_src && $tlpobj->srcfiles) {
         my $srccontainer = $container;
         $srccontainer =~ s/(\.tar\.xz|\.zip)$/.source$1/;
-        $self->_install_data ($srccontainer, $reloc, \@installfiles, $totlpdb, $tlpobj->srccontainersize, $tlpobj->srccontainermd5)
+        $self->_install_data ($srccontainer, $reloc, \@installfiles, $totlpdb, $tlpobj->srccontainersize, $tlpobj->srccontainerchecksum)
           || return(0);
       }
       if ($container_doc_split && $real_opt_doc && $tlpobj->docfiles) {
         my $doccontainer = $container;
         $doccontainer =~ s/(\.tar\.xz|\.zip)$/.doc$1/;
-        $self->_install_data ($doccontainer, $reloc, \@installfiles, $totlpdb, $tlpobj->doccontainersize, $tlpobj->doccontainermd5)
+        $self->_install_data ($doccontainer, $reloc, \@installfiles, $totlpdb, $tlpobj->doccontainersize, $tlpobj->doccontainerchecksum)
           || return(0);
       }
       #
@@ -2054,6 +2054,7 @@
         $target .= "/$TeXLive::TLConfig::RelocTree";
       }
     }
+    debug("tlpdb:_install_data: what=$what, target=$target, size=$whatsize, checksum=$whatcheck, tmpdir=$tempdir\n");
     my ($ret, $pkg) = TeXLive::TLUtils::unpack($what, $target, 'size' => $whatsize, 'checksum' => $whatcheck, 'tmpdir' => $tempdir);
     if (!$ret) {
       tlwarn("TLPDB::_install_package: $pkg\n");

Modified: trunk/Master/tlpkg/TeXLive/TLUtils.pm
===================================================================
--- trunk/Master/tlpkg/TeXLive/TLUtils.pm	2018-01-24 01:18:01 UTC (rev 46420)
+++ trunk/Master/tlpkg/TeXLive/TLUtils.pm	2018-01-24 03:55:35 UTC (rev 46421)
@@ -2064,6 +2064,11 @@
 
 sub check_file {
   my ($xzfile, $checksum, $checksize) = @_;
+  debug("check_file $xzfile, $checksum, $checksize\n");
+  if (!$checksum && !$checksize) {
+    tlwarn("TLUtils::check_file: neither checksum nor checksize available for $xzfile, cannot check integrity!\n");
+    return;
+  }
   # only run checksum tests if we can actually compute the checksum
   if ($checksum && $::checksum_method) {
     my $tlchecksum = TeXLive::TLCrypto::tlchecksum($xzfile);
@@ -2072,6 +2077,10 @@
       tlwarn("TLUtils::check_file:   TL=$tlchecksum, arg=$checksum\n");
       unlink($xzfile);
       return;
+    } else {
+      debug("TLUtils::check_file: checksums for $xzfile agree\n");
+      # if we have checked the checksum, we don't need to check the size, too
+      return;
     }
   }
   if ($checksize) {



More information about the tex-live-commits mailing list