texlive[47754] Master/tlpkg/TeXLive: work on supporting lz4 and

commits+preining at tug.org commits+preining at tug.org
Sat May 19 01:46:06 CEST 2018


Revision: 47754
          http://tug.org/svn/texlive?view=revision&revision=47754
Author:   preining
Date:     2018-05-19 01:46:06 +0200 (Sat, 19 May 2018)
Log Message:
-----------
work on supporting lz4 and possibly other codices

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

Modified: trunk/Master/tlpkg/TeXLive/TLConfig.pm
===================================================================
--- trunk/Master/tlpkg/TeXLive/TLConfig.pm	2018-05-18 23:45:57 UTC (rev 47753)
+++ trunk/Master/tlpkg/TeXLive/TLConfig.pm	2018-05-18 23:46:06 UTC (rev 47754)
@@ -24,6 +24,10 @@
     $DefaultCategory
     $DefaultContainerFormat
     $DefaultContainerExtension
+    $AcceptedCompressors
+    $AcceptedCompressorsRegexp
+    %CompressorProgram
+    %CompressorArgs
     $InfraLocation
     $DatabaseName
     $PackageBackupDir 
@@ -106,6 +110,10 @@
 # the way we package things on the web
 our $DefaultContainerFormat = "xz";
 our $DefaultContainerExtension = "tar.$DefaultContainerFormat";
+our @AcceptedCompressors = qw/xz lz4/;
+our $AcceptedCompressorsRegexp = "(xz|lz4)";
+our %CompressorProgram = ( 'xz' => 'xzdec', 'lz4' => 'lz4' );
+our %CompressorArgs    = ( 'xz' => '',      'lz4' => '-dcf');
 
 # archive (not user) settings.
 # these can be overridden by putting them into 00texlive.config.tlpsrc

Modified: trunk/Master/tlpkg/TeXLive/TLPDB.pm
===================================================================
--- trunk/Master/tlpkg/TeXLive/TLPDB.pm	2018-05-18 23:45:57 UTC (rev 47753)
+++ trunk/Master/tlpkg/TeXLive/TLPDB.pm	2018-05-18 23:46:06 UTC (rev 47754)
@@ -1891,10 +1891,13 @@
     if ($media eq 'local_uncompressed') {
       $container = \@installfiles;
     } elsif ($media eq 'local_compressed') {
-      if (-r "$root/$Archive/$pkg.tar.xz") {
-        $container = "$root/$Archive/$pkg.tar.xz";
-      } else {
-        tlwarn("TLPDB: cannot find package $pkg.tar.xz) in $root/$Archive\n");
+      for my $ext (@AcceptedCompressors) {
+        if (-r "$root/$Archive/$pkg.tar.$ext") {
+          $container = "$root/$Archive/$pkg.tar.$ext";
+        }
+      }
+      if (!$container) {
+        tlwarn("TLPDB: cannot find package $pkg.tar.$AcceptedCompressorsRegexp in $root/$Archive\n");
         next;
       }
     } elsif (&media eq 'NET') {
@@ -1918,13 +1921,13 @@
       # - there are actually src/doc files present
       if ($container_src_split && $opt_src && $tlpobj->srcfiles) {
         my $srccontainer = $container;
-        $srccontainer =~ s/(\.tar\.xz|\.zip)$/.source$1/;
+        $srccontainer =~ s/\.tar\.$AcceptedCompressorRegexp$/.source$1/;
         $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/;
+        $doccontainer =~ s/\.tar\.$AcceptedCompressorRegexp$/.doc$1/;
         $self->_install_data ($doccontainer, $reloc, \@installfiles, $totlpdb, $tlpobj->doccontainersize, $tlpobj->doccontainerchecksum)
           || return(0);
       }
@@ -2052,7 +2055,7 @@
     }
     # we always assume that copy will work
     return(1);
-  } elsif ($what =~ m,\.tar\.xz$,) {
+  } elsif ($what =~ m,\.tar\.$AcceptedCompressorsRegexp$,) {
     if ($reloc) {
       if (!$totlpdb->setting("usertree")) {
         $target .= "/$TeXLive::TLConfig::RelocTree";

Modified: trunk/Master/tlpkg/TeXLive/TLUtils.pm
===================================================================
--- trunk/Master/tlpkg/TeXLive/TLUtils.pm	2018-05-18 23:45:57 UTC (rev 47753)
+++ trunk/Master/tlpkg/TeXLive/TLUtils.pm	2018-05-18 23:46:06 UTC (rev 47754)
@@ -2133,51 +2133,60 @@
     return (0, "nothing to unpack");
   }
 
+  my $type;
+  for my $ext (@AcceptedCompressors) {
+    if ($what =~  m/\.tar\.$ext$/) {
+      $type = $ext;
+    }
+  }
+  if (!$type) {
+    return(0, "don't know how to unpack");
+  }
+
   # we assume that $::progs has been set up!
-  my $wget = $::progs{'wget'};
-  my $xzdec = TeXLive::TLUtils::quotify_path_with_spaces($::progs{'xzdec'});
-  if (!defined($wget) || !defined($xzdec)) {
+  # wget is again checked by download file
+  # my $wget = $::progs{'wget'};
+  # only check the necessary compressor program
+  my $decompressor = TeXLive::TLUtils::quotify_path_with_spaces($::progs{$CompressorProgram{$type}});
+  my $decompressorArgs = $::progs{$DecompressorArgs{$type}};
+  if (!defined($decompressor)) {
     return (0, "programs not set up properly");
   }
 
-  my $type;
-  if ($what !~ m/\.tar\.xz$/) {
-    return(0, "don't know how to unpack");
-  }
 
   my $fn = basename($what);
   my $pkg = $fn;
-  $pkg =~ s/\.tar\.xz$//;
+  $pkg =~ s/\.tar\.$AcceptedCompressorsRegexp$//;
   my $tarfile;
-  my $remove_xzfile = $remove;
-  my $xzfile = "$tempdir/$fn";
-  $tarfile  = "$tempdir/$fn"; $tarfile =~ s/\.xz$//;
-  my $xzfile_quote;
+  my $remove_containerfile = $remove;
+  my $containerfile = "$tempdir/$fn";
+  $tarfile  = "$tempdir/$fn"; $tarfile =~ s/$AcceptedCompressorsRegexp$//;
+  my $containerfile_quote;
   my $tarfile_quote;
   my $target_quote;
   if (win32()) {
-    $xzfile =~ s!/!\\!g;
+    $containerfile =~ s!/!\\!g;
     $tarfile =~ s!/!\\!g;
     $target =~ s!/!\\!g;
   }
-  $xzfile_quote = "\"$xzfile\"";
+  $containerfile_quote = "\"$containerfile\"";
   $tarfile_quote = "\"$tarfile\"";
   $target_quote = "\"$target\"";
   if ($what =~ m,^(https?|ftp)://,) {
     # we are installing from the NET
     # check for the presence of $what in $tempdir
-    if (-r $xzfile) {
-      check_file($xzfile, $checksum, $size);
+    if (-r $containerfile) {
+      check_file($containerfile, $checksum, $size);
     }
     # if the file is now not present, we can use it
-    if (! -r $xzfile) {
+    if (! -r $containerfile) {
       # try download the file and put it into temp
-      if (!download_file($what, $xzfile)) {
+      if (!download_file($what, $containerfile)) {
         return(0, "downloading did not succeed");
       }
       # remove false downloads
-      check_file($xzfile, $checksum, $size);
-      if ( ! -r $xzfile ) {
+      check_file($containerfile, $checksum, $size);
+      if ( ! -r $containerfile ) {
         return(0, "downloading did not succeed");
       }
     }
@@ -2186,20 +2195,20 @@
     # copy it to temp
     TeXLive::TLUtils::copy($what, $tempdir);
 
-    check_file($xzfile, $checksum, $size);
-    if (! -r $xzfile) {
+    check_file($containerfile, $checksum, $size);
+    if (! -r $containerfile) {
       return (0, "consistency checks failed");
     }
     # we can remove it afterwards
-    $remove_xzfile = 1;
+    $remove_containerfile = 1;
   }
-  debug("un-xzing $xzfile to $tarfile\n");
-  system("$xzdec < $xzfile_quote > $tarfile_quote");
+  debug("decompressing $containerfile to $tarfile\n");
+  system("$decompressor $decompressorArgs < $containerfile_quote > $tarfile_quote");
   if (! -f $tarfile) {
-    unlink($tarfile, $xzfile);
-    return(0, "Unpacking $xzfile failed");
+    unlink($tarfile, $containerfile);
+    return(0, "Decompressing $containerfile failed");
   }
-  unlink($xzfile) if $remove_xzfile;
+  unlink($containerfile) if $remove_containerfile;
   if (untar($tarfile, $target, 1)) {
     return (1, "$pkg");
   } else {
@@ -2348,7 +2357,8 @@
     my $s = 0;
     $s += setup_unix_one('wget', "$bindir/wget/wget.$platform", "--version");
     $s += setup_unix_one('xzdec',"$bindir/xz/xzdec.$platform","--help");
-    $s += setup_unix_one('xz', "$bindir/xz/xz.$platform", "notest");
+    $s += setup_unix_one('xz',   "$bindir/xz/xz.$platform", "notest");
+    $s += setup_unix_one('lz4',  "$bindir/lz4/lz4.$platform", "--version");
     $ok = ($s == 3);  # failure return unless all are present.
   }
 



More information about the tex-live-commits mailing list