summaryrefslogtreecommitdiff
path: root/systems/texlive/tlnet/tlpkg/tlperl/lib/Archive
diff options
context:
space:
mode:
authorNorbert Preining <norbert@preining.info>2021-04-02 03:20:54 +0000
committerNorbert Preining <norbert@preining.info>2021-04-02 03:20:54 +0000
commit3f173002d4a4a84e7d1fa5a74755fdd00d08a9c2 (patch)
tree5ed380344702de1f9ab53b68b6c3bcd6b8458087 /systems/texlive/tlnet/tlpkg/tlperl/lib/Archive
parentf78ba658b3ecd56053fe0837a4404d0c6c16a707 (diff)
CTAN sync 202104020320
Diffstat (limited to 'systems/texlive/tlnet/tlpkg/tlperl/lib/Archive')
-rw-r--r--systems/texlive/tlnet/tlpkg/tlperl/lib/Archive/Tar.pm72
-rw-r--r--systems/texlive/tlnet/tlpkg/tlperl/lib/Archive/Tar/Constant.pm13
-rw-r--r--systems/texlive/tlnet/tlpkg/tlperl/lib/Archive/Tar/File.pm2
3 files changed, 68 insertions, 19 deletions
diff --git a/systems/texlive/tlnet/tlpkg/tlperl/lib/Archive/Tar.pm b/systems/texlive/tlnet/tlpkg/tlperl/lib/Archive/Tar.pm
index 093579a6c2..af6786ee51 100644
--- a/systems/texlive/tlnet/tlpkg/tlperl/lib/Archive/Tar.pm
+++ b/systems/texlive/tlnet/tlpkg/tlperl/lib/Archive/Tar.pm
@@ -27,11 +27,11 @@ use vars qw[$DEBUG $error $VERSION $WARN $FOLLOW_SYMLINK $CHOWN $CHMOD
];
@ISA = qw[Exporter];
-@EXPORT = qw[ COMPRESS_GZIP COMPRESS_BZIP ];
+@EXPORT = qw[ COMPRESS_GZIP COMPRESS_BZIP COMPRESS_XZ ];
$DEBUG = 0;
$WARN = 1;
$FOLLOW_SYMLINK = 0;
-$VERSION = "2.32";
+$VERSION = "2.36";
$CHOWN = 1;
$CHMOD = 1;
$SAME_PERMISSIONS = $> == 0 ? 1 : 0;
@@ -76,6 +76,7 @@ Archive::Tar - module for manipulations of tar archives
$tar->write('files.tar'); # plain tar
$tar->write('files.tgz', COMPRESS_GZIP); # gzip compressed
$tar->write('files.tbz', COMPRESS_BZIP); # bzip2 compressed
+ $tar->write('files.txz', COMPRESS_XZ); # xz compressed
=head1 DESCRIPTION
@@ -147,12 +148,13 @@ backwards compatibility. Archive::Tar now looks at the file
magic to determine what class should be used to open the file
and will transparently Do The Right Thing.
-Archive::Tar will warn if you try to pass a bzip2 compressed file and the
-IO::Zlib / IO::Uncompress::Bunzip2 modules are not available and simply return.
+Archive::Tar will warn if you try to pass a bzip2 / xz compressed file and the
+IO::Uncompress::Bunzip2 / IO::Uncompress::UnXz are not available and simply return.
Note that you can currently B<not> pass a C<gzip> compressed
filehandle, which is not opened with C<IO::Zlib>, a C<bzip2> compressed
-filehandle, which is not opened with C<IO::Uncompress::Bunzip2>, nor a string
+filehandle, which is not opened with C<IO::Uncompress::Bunzip2>, a C<xz> compressed
+filehandle, which is not opened with C<IO::Uncompress::UnXz>, nor a string
containing the full archive information (either compressed or
uncompressed). These are worth while features, but not currently
implemented. See the C<TODO> section.
@@ -246,16 +248,40 @@ sub _get_handle {
return;
};
- ### read the first 4 bites of the file to figure out which class to
+ ### read the first 6 bytes of the file to figure out which class to
### use to open the file.
- sysread( $tmp, $magic, 4 );
+ sysread( $tmp, $magic, 6 );
close $tmp;
}
+ ### is it xz?
+ ### if you asked specifically for xz compression, or if we're in
+ ### read mode and the magic numbers add up, use xz
+ if( XZ and (
+ ($compress eq COMPRESS_XZ) or
+ ( MODE_READ->($mode) and $magic =~ XZ_MAGIC_NUM )
+ )
+ ) {
+ if( MODE_READ->($mode) ) {
+ $fh = IO::Uncompress::UnXz->new( $file ) or do {
+ $self->_error( qq[Could not read '$file': ] .
+ $IO::Uncompress::UnXz::UnXzError
+ );
+ return;
+ };
+ } else {
+ $fh = IO::Compress::Xz->new( $file ) or do {
+ $self->_error( qq[Could not write to '$file': ] .
+ $IO::Compress::Xz::XzError
+ );
+ return;
+ };
+ }
+
### is it bzip?
### if you asked specifically for bzip compression, or if we're in
### read mode and the magic numbers add up, use bzip
- if( BZIP and (
+ } elsif( BZIP and (
($compress eq COMPRESS_BZIP) or
( MODE_READ->($mode) and $magic =~ BZIP_MAGIC_NUM )
)
@@ -1246,8 +1272,8 @@ Write the in-memory archive to disk. The first argument can either
be the name of a file or a reference to an already open filehandle (a
GLOB reference).
-The second argument is used to indicate compression. You can either
-compress using C<gzip> or C<bzip2>. If you pass a digit, it's assumed
+The second argument is used to indicate compression. You can
+compress using C<gzip>, C<bzip2> or C<xz>. If you pass a digit, it's assumed
to be the C<gzip> compression level (between 1 and 9), but the use of
constants is preferred:
@@ -1257,10 +1283,13 @@ constants is preferred:
# write a bzip compressed file
$tar->write( 'out.tbz', COMPRESS_BZIP );
+ # write a xz compressed file
+ $tar->write( 'out.txz', COMPRESS_XZ );
+
Note that when you pass in a filehandle, the compression argument
is ignored, as all files are printed verbatim to your filehandle.
If you wish to enable compression with filehandles, use an
-C<IO::Zlib> or C<IO::Compress::Bzip2> filehandle instead.
+C<IO::Zlib>, C<IO::Compress::Bzip2> or C<IO::Compress::Xz> filehandle instead.
The third argument is an optional prefix. All files will be tucked
away in the directory you specify as prefix. So if you have files
@@ -1696,8 +1725,8 @@ Creates a tar file from the list of files provided. The first
argument can either be the name of the tar file to create or a
reference to an open file handle (e.g. a GLOB reference).
-The second argument is used to indicate compression. You can either
-compress using C<gzip> or C<bzip2>. If you pass a digit, it's assumed
+The second argument is used to indicate compression. You can
+compress using C<gzip>, C<bzip2> or C<xz>. If you pass a digit, it's assumed
to be the C<gzip> compression level (between 1 and 9), but the use of
constants is preferred:
@@ -1707,10 +1736,13 @@ constants is preferred:
# write a bzip compressed file
Archive::Tar->create_archive( 'out.tbz', COMPRESS_BZIP, @filelist );
+ # write a xz compressed file
+ Archive::Tar->create_archive( 'out.txz', COMPRESS_XZ, @filelist );
+
Note that when you pass in a filehandle, the compression argument
is ignored, as all files are printed verbatim to your filehandle.
If you wish to enable compression with filehandles, use an
-C<IO::Zlib> or C<IO::Compress::Bzip2> filehandle instead.
+C<IO::Zlib>, C<IO::Compress::Bzip2> or C<IO::Compress::Xz> filehandle instead.
The remaining arguments list the files to be included in the tar file.
These files must all exist. Any files which don't exist or can't be
@@ -1915,11 +1947,19 @@ Returns true if C<Archive::Tar> can extract C<bzip2> compressed archives
sub has_bzip2_support { return BZIP }
+=head2 $bool = Archive::Tar->has_xz_support
+
+Returns true if C<Archive::Tar> can extract C<xz> compressed archives
+
+=cut
+
+sub has_xz_support { return XZ }
+
=head2 Archive::Tar->can_handle_compressed_files
A simple checking routine, which will return true if C<Archive::Tar>
-is able to uncompress compressed archives on the fly with C<IO::Zlib>
-and C<IO::Compress::Bzip2> or false if not both are installed.
+is able to uncompress compressed archives on the fly with C<IO::Zlib>,
+C<IO::Compress::Bzip2> and C<IO::Compress::Xz> or false if not both are installed.
You can use this as a shortcut to determine whether C<Archive::Tar>
will do what you think before passing compressed archives to its
diff --git a/systems/texlive/tlnet/tlpkg/tlperl/lib/Archive/Tar/Constant.pm b/systems/texlive/tlnet/tlpkg/tlperl/lib/Archive/Tar/Constant.pm
index a48968d9e0..398c4799a5 100644
--- a/systems/texlive/tlnet/tlpkg/tlperl/lib/Archive/Tar/Constant.pm
+++ b/systems/texlive/tlnet/tlpkg/tlperl/lib/Archive/Tar/Constant.pm
@@ -3,7 +3,7 @@ package Archive::Tar::Constant;
BEGIN {
require Exporter;
- $VERSION = '2.32';
+ $VERSION = '2.36';
@ISA = qw[Exporter];
require Time::Local if $^O eq "MacOS";
@@ -32,6 +32,7 @@ use constant BLOCK => 512;
use constant COMPRESS_GZIP => 9;
use constant COMPRESS_BZIP => 'bzip2';
+use constant COMPRESS_XZ => 'xz';
use constant BLOCK_SIZE => sub { my $n = int($_[0]/BLOCK); $n++ if $_[0] % BLOCK; $n * BLOCK };
use constant TAR_PAD => sub { my $x = shift || return; return "\0" x (BLOCK - ($x % BLOCK) ) };
@@ -58,7 +59,7 @@ use constant PACK => 'a100 a8 a8 a8 a12 a12 A8 a1 a100 a6 a2 a32 a32 a
use constant NAME_LENGTH => 100;
use constant PREFIX_LENGTH => 155;
-use constant TIME_OFFSET => ($^O eq "MacOS") ? Time::Local::timelocal(0,0,0,1,0,70) : 0;
+use constant TIME_OFFSET => ($^O eq "MacOS") ? Time::Local::timelocal(0,0,0,1,0,1970) : 0;
use constant MAGIC => "ustar";
use constant TAR_VERSION => "00";
use constant LONGLINK_NAME => '././@LongLink';
@@ -77,8 +78,16 @@ use constant BZIP => do { !$ENV{'PERL5_AT_NO_BZIP'} and
$ENV{'PERL5_AT_NO_BZIP'} || $@ ? 0 : 1
};
+ ### allow XZ to be turned off using ENV: DEBUG only
+use constant XZ => do { !$ENV{'PERL5_AT_NO_XZ'} and
+ eval { require IO::Compress::Xz;
+ require IO::Uncompress::UnXz; };
+ $ENV{'PERL5_AT_NO_XZ'} || $@ ? 0 : 1
+ };
+
use constant GZIP_MAGIC_NUM => qr/^(?:\037\213|\037\235)/;
use constant BZIP_MAGIC_NUM => qr/^BZh\d/;
+use constant XZ_MAGIC_NUM => qr/^\xFD\x37\x7A\x58\x5A\x00/;
use constant CAN_CHOWN => sub { ($> == 0 and $^O ne "MacOS" and $^O ne "MSWin32") };
use constant CAN_READLINK => ($^O ne 'MSWin32' and $^O !~ /RISC(?:[ _])?OS/i and $^O ne 'VMS');
diff --git a/systems/texlive/tlnet/tlpkg/tlperl/lib/Archive/Tar/File.pm b/systems/texlive/tlnet/tlpkg/tlperl/lib/Archive/Tar/File.pm
index 3efa3159d9..0887a923bd 100644
--- a/systems/texlive/tlnet/tlpkg/tlperl/lib/Archive/Tar/File.pm
+++ b/systems/texlive/tlnet/tlpkg/tlperl/lib/Archive/Tar/File.pm
@@ -13,7 +13,7 @@ use Archive::Tar::Constant;
use vars qw[@ISA $VERSION];
#@ISA = qw[Archive::Tar];
-$VERSION = '2.32';
+$VERSION = '2.36';
### set value to 1 to oct() it during the unpack ###