From af61d4d340b46609b9d88deb0d64cbdefcf4882f Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Fri, 18 May 2018 23:46:06 +0000 Subject: work on supporting lz4 and possibly other codices git-svn-id: svn://tug.org/texlive/trunk@47754 c570f23f-e606-0410-a88d-b1316a301751 --- Master/tlpkg/TeXLive/TLConfig.pm | 8 +++++ Master/tlpkg/TeXLive/TLPDB.pm | 17 +++++----- Master/tlpkg/TeXLive/TLUtils.pm | 68 +++++++++++++++++++++++----------------- 3 files changed, 57 insertions(+), 36 deletions(-) diff --git a/Master/tlpkg/TeXLive/TLConfig.pm b/Master/tlpkg/TeXLive/TLConfig.pm index 39c547bc998..71e50e946e7 100644 --- a/Master/tlpkg/TeXLive/TLConfig.pm +++ b/Master/tlpkg/TeXLive/TLConfig.pm @@ -24,6 +24,10 @@ BEGIN { $DefaultCategory $DefaultContainerFormat $DefaultContainerExtension + $AcceptedCompressors + $AcceptedCompressorsRegexp + %CompressorProgram + %CompressorArgs $InfraLocation $DatabaseName $PackageBackupDir @@ -106,6 +110,10 @@ if ($^O =~ /^MSWin/i) { # 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 diff --git a/Master/tlpkg/TeXLive/TLPDB.pm b/Master/tlpkg/TeXLive/TLPDB.pm index 0fa8c073445..34e3414b32d 100644 --- a/Master/tlpkg/TeXLive/TLPDB.pm +++ b/Master/tlpkg/TeXLive/TLPDB.pm @@ -1891,10 +1891,13 @@ sub not_virtual_install_package { 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 @@ sub not_virtual_install_package { # - 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 @@ sub _install_data { } # 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"; diff --git a/Master/tlpkg/TeXLive/TLUtils.pm b/Master/tlpkg/TeXLive/TLUtils.pm index b8af0fe476f..476ebf5b5ef 100644 --- a/Master/tlpkg/TeXLive/TLUtils.pm +++ b/Master/tlpkg/TeXLive/TLUtils.pm @@ -2133,51 +2133,60 @@ sub unpack { 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 @@ sub unpack { # 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 @@ sub setup_programs { 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. } -- cgit v1.2.3