Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Archive-Tar sync from CPAN with modification #21691

Merged
merged 2 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions MANIFEST
Original file line number Diff line number Diff line change
Expand Up @@ -230,9 +230,8 @@ cpan/Archive-Tar/t/03_file.t Archive::Tar tests
cpan/Archive-Tar/t/04_resolved_issues.t Archive::Tar tests
cpan/Archive-Tar/t/05_iter.t Archive::Tar tests
cpan/Archive-Tar/t/06_error.t Archive::Tar tests
cpan/Archive-Tar/t/08_ptargrep.t
cpan/Archive-Tar/t/09_roundtrip.t
cpan/Archive-Tar/t/90_symlink.t Archive::Tar tests
cpan/Archive-Tar/t/08_ptargrep.t Test file related to Archive::Tar
cpan/Archive-Tar/t/09_roundtrip.t Test file related to Archive::Tar
cpan/Archive-Tar/t/99_pod.t Archive::Tar tests
cpan/Archive-Tar/t/src/header/signed.tar Archive::Tar tests
cpan/Archive-Tar/t/src/linktest/linktest_missing_dir.tar Archive::Tar tests
Expand All @@ -241,6 +240,7 @@ cpan/Archive-Tar/t/src/long/b Archive::Tar tests
cpan/Archive-Tar/t/src/long/bar.tar Archive::Tar tests
cpan/Archive-Tar/t/src/long/foo.tbz Archive::Tar tests
cpan/Archive-Tar/t/src/long/foo.tgz Archive::Tar tests
cpan/Archive-Tar/t/src/long/prefix-directory-concat.tar Archive-Tar
cpan/Archive-Tar/t/src/short/b Archive::Tar tests
cpan/Archive-Tar/t/src/short/bar.tar Archive::Tar tests
cpan/Archive-Tar/t/src/short/foo.tbz Archive::Tar tests
Expand Down
4 changes: 3 additions & 1 deletion Porting/Maintainers.pl
Original file line number Diff line number Diff line change
Expand Up @@ -129,12 +129,14 @@ package Maintainers;
our %Modules = (

'Archive::Tar' => {
'DISTRIBUTION' => 'BINGOS/Archive-Tar-2.40.tar.gz',
'DISTRIBUTION' => 'BINGOS/Archive-Tar-3.02_001.tar.gz',
'SYNCINFO' => 'jkeenan on Tue Dec 5 07:32:24 2023',
'FILES' => q[cpan/Archive-Tar],
'BUGS' => '[email protected]',
'EXCLUDED' => [
qw(t/07_ptardiff.t),
qr{t/src/(long|short)/foo.txz},
qw(t/90_symlink.t),
],
},

Expand Down
81 changes: 47 additions & 34 deletions cpan/Archive-Tar/lib/Archive/Tar.pm
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
### the gnu tar specification:
### http://www.gnu.org/software/tar/manual/tar.html
### https://www.gnu.org/software/tar/manual/tar.html
###
### and the pax format spec, which tar derives from:
### http://www.opengroup.org/onlinepubs/007904975/utilities/pax.html
### https://www.opengroup.org/onlinepubs/007904975/utilities/pax.html

package Archive::Tar;
require 5.005_03;
Expand All @@ -24,21 +24,23 @@ use strict;
use vars qw[$DEBUG $error $VERSION $WARN $FOLLOW_SYMLINK $CHOWN $CHMOD
$DO_NOT_USE_PREFIX $HAS_PERLIO $HAS_IO_STRING $SAME_PERMISSIONS
$INSECURE_EXTRACT_MODE $ZERO_PAD_NUMBERS @ISA @EXPORT $RESOLVE_SYMLINK
$EXTRACT_BLOCK_SIZE
];

@ISA = qw[Exporter];
@EXPORT = qw[ COMPRESS_GZIP COMPRESS_BZIP COMPRESS_XZ ];
$DEBUG = 0;
$WARN = 1;
$FOLLOW_SYMLINK = 0;
$VERSION = "2.40";
$VERSION = "3.02_001";
$CHOWN = 1;
$CHMOD = 1;
$SAME_PERMISSIONS = $> == 0 ? 1 : 0;
$DO_NOT_USE_PREFIX = 0;
$INSECURE_EXTRACT_MODE = 0;
$ZERO_PAD_NUMBERS = 0;
$RESOLVE_SYMLINK = $ENV{'PERL5_AT_RESOLVE_SYMLINK'} || 'speed';
$EXTRACT_BLOCK_SIZE = 1024 * 1024 * 1024;

BEGIN {
use Config;
Expand Down Expand Up @@ -423,7 +425,7 @@ sub _read_tar {
}

### ignore labels:
### http://www.gnu.org/software/tar/manual/html_chapter/Media.html#SEC159
### https://www.gnu.org/software/tar/manual/html_chapter/Media.html#SEC159
next if $entry->is_label;

if( length $entry->type and ($entry->is_file || $entry->is_longlink) ) {
Expand Down Expand Up @@ -894,10 +896,18 @@ sub _extract_file {

if( $entry->size ) {
binmode $fh;
syswrite $fh, $entry->data or (
$self->_error( qq[Could not write data to '$full'] ),
return
);
my $offset = 0;
my $content = $entry->get_content_by_ref();
while ($offset < $entry->size) {
my $written
= syswrite $fh, $$content, $EXTRACT_BLOCK_SIZE, $offset;
if (defined $written) {
$offset += $written;
} else {
$self->_error( qq[Could not write data to '$full': $!] );
return;
}
}
}

close $fh or (
Expand Down Expand Up @@ -2143,25 +2153,39 @@ numbers. Added for compatibility with C<busybox> implementations.

=head2 Tuning the way RESOLVE_SYMLINK will works

You can tune the behaviour by setting the $Archive::Tar::RESOLVE_SYMLINK variable,
or $ENV{PERL5_AT_RESOLVE_SYMLINK} before loading the module Archive::Tar.
You can tune the behaviour by setting the $Archive::Tar::RESOLVE_SYMLINK variable,
or $ENV{PERL5_AT_RESOLVE_SYMLINK} before loading the module Archive::Tar.

Values can be one of the following:

=over 4

=item none

Values can be one of the following:
Disable this mechanism and failed as it was in previous version (<1.88)

none
Disable this mechanism and failed as it was in previous version (<1.88)
=item speed (default)

speed (default)
If you prefer speed
this will read again the whole archive using read() so all entries
will be available
If you prefer speed
this will read again the whole archive using read() so all entries
will be available

memory
If you prefer memory
=item memory

Limitation
If you prefer memory

It won't work for terminal, pipe or sockets or every non seekable source.
=back

Limitation: It won't work for terminal, pipe or sockets or every non seekable
source.

=head2 $Archive::Tar::EXTRACT_BLOCK_SIZE

This variable holds an integer with the block size that should be used when
writing files during extraction. It defaults to 1 GiB. Please note that this
cannot be arbitrarily large since some operating systems limit the number of
bytes that can be written in one call to C<write(2)>, so if this is too large,
extraction may fail with an error.

=cut

Expand Down Expand Up @@ -2396,22 +2420,11 @@ to an uploaded file, which might be a compressed archive.

=item The GNU tar specification

C<http://www.gnu.org/software/tar/manual/tar.html>
L<https://www.gnu.org/software/tar/manual/tar.html>

=item The PAX format specification

The specification which tar derives from; C< http://www.opengroup.org/onlinepubs/007904975/utilities/pax.html>

=item A comparison of GNU and POSIX tar standards; C<http://www.delorie.com/gnu/docs/tar/tar_114.html>

=item GNU tar intends to switch to POSIX compatibility

GNU Tar authors have expressed their intention to become completely
POSIX-compatible; C<http://www.gnu.org/software/tar/manual/html_node/Formats.html>

=item A Comparison between various tar implementations

Lists known issues and incompatibilities; C<http://gd.tuwien.ac.at/utils/archivers/star/README.otherbugs>
The specification which tar derives from; L<https://pubs.opengroup.org/onlinepubs/007904975/utilities/pax.html>

=back

Expand Down
2 changes: 1 addition & 1 deletion cpan/Archive-Tar/lib/Archive/Tar/Constant.pm
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use vars qw[$VERSION @ISA @EXPORT];
BEGIN {
require Exporter;

$VERSION = '2.40';
$VERSION = '3.02_001';
@ISA = qw[Exporter];

require Time::Local if $^O eq "MacOS";
Expand Down
10 changes: 6 additions & 4 deletions cpan/Archive-Tar/lib/Archive/Tar/File.pm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ use Archive::Tar::Constant;

use vars qw[@ISA $VERSION];
#@ISA = qw[Archive::Tar];
$VERSION = '2.40';
$VERSION = '3.02_001';

### set value to 1 to oct() it during the unpack ###

Expand Down Expand Up @@ -71,7 +71,7 @@ Archive::Tar::File - a subclass for in-memory extracted file from Archive::Tar

=head1 DESCRIPTION

Archive::Tar::Files provides a neat little object layer for in-memory
Archive::Tar::File provides a neat little object layer for in-memory
extracted files. It's mostly used internally in Archive::Tar to tidy
up the code, but there's no reason users shouldn't use this API as
well.
Expand Down Expand Up @@ -486,7 +486,9 @@ sub full_path {
return $self->name unless defined $self->prefix and length $self->prefix;

### or otherwise, catfile'd
return File::Spec::Unix->catfile( $self->prefix, $self->name );
my $path = File::Spec::Unix->catfile( $self->prefix, $self->name );
$path .= "/" if $self->name =~ m{/$}; # Re-add trailing slash if necessary, as catfile() strips them off.
return $path;
}


Expand Down Expand Up @@ -601,7 +603,7 @@ sub rename {
return 1;
}

=head2 $bool = $file->chmod $mode)
=head2 $bool = $file->chmod( $mode )

Change mode of $file to $mode. The mode can be a string or a number
which is interpreted as octal whether or not a leading 0 is given.
Expand Down
28 changes: 28 additions & 0 deletions cpan/Archive-Tar/t/02_methods.t
Original file line number Diff line number Diff line change
Expand Up @@ -570,6 +570,34 @@ SKIP: { ### pesky warnings
}


### extract tests with different $EXTRACT_BLOCK_SIZE values ###
SKIP: { ### pesky warnings
skip $ebcdic_skip_msg, 431 if ord "A" != 65;

skip('no IO::String', 431) if !$Archive::Tar::HAS_PERLIO &&
!$Archive::Tar::HAS_PERLIO &&
!$Archive::Tar::HAS_IO_STRING &&
!$Archive::Tar::HAS_IO_STRING;

my $tar = $Class->new;
ok( $tar->read( $TAR_FILE ), "Read in '$TAR_FILE'" );

for my $aref ( [$tar, \@EXPECT_NORMAL],
[$TARBIN, \@EXPECTBIN],
[$TARX, \@EXPECTX]
) {
my($obj, $struct) = @$aref;

for my $block_size ((1, BLOCK, 1024 * 1024, 2**31 - 4096, 2**31 - 1)) {
local $Archive::Tar::EXTRACT_BLOCK_SIZE = $block_size;

ok( $obj->extract, " Extracted with 'extract'" );
check_tar_extract( $obj, $struct );
}
}
}


### clear tests ###
SKIP: { ### pesky warnings
skip $ebcdic_skip_msg, 3 if ord "A" != 65;
Expand Down
1 change: 1 addition & 0 deletions cpan/Archive-Tar/t/04_resolved_issues.t
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ SKIP: {
### bug #78030
### tests for symlinks with relative paths
### seen on MSWin32
if ($^O ne 'msys') # symlink tests fail on Windows/msys2
{ ok( 1, "Testing bug 78030" );
my $archname = 'tmp-symlink.tar.gz';
{ #build archive
Expand Down
1 change: 1 addition & 0 deletions cpan/Archive-Tar/t/09_roundtrip.t
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ push @file_only_archives, [qw( src short foo.txz )]

my @file_and_directory_archives = (
[qw( src long bar.tar )],
[qw( src long prefix-directory-concat.tar )],
[qw( src linktest linktest_with_dir.tar )],
);
push @file_and_directory_archives, [qw( src long foo.tgz )]
Expand Down
55 changes: 0 additions & 55 deletions cpan/Archive-Tar/t/90_symlink.t

This file was deleted.

Binary file not shown.