CC: | wosch [...] freebsd.org, pmqs [...] cpan.org |
Subject: | Cannot deal with .tar.bz2 distributions created by pbzip2 |
Archive::Tar->extract_archive fails on (some) tarballs compressed with pbzip2, the parallel variant of bzip2. The error message looks like this:
Read error on tarfile (missing data) 'testdir/test' at offset 1024
The problem was already discussed in this ticket in the IO-Compress queue:
https://rt.cpan.org/Ticket/Display.html?id=77743
The proposed fix was to use MultiStream=>1 when constructing the IO::Uncompress::Bunzip2 object.
I can confirm that this works; monkey-patching the Archive::Tar::_get_handle method like this works for me:
no warnings 'redefine';
*Archive::Tar::_get_handle = sub {
my($self, $file) = @_;
no warnings 'once';
my $fh = IO::Uncompress::Bunzip2->new( $file, MultiStream => 1 ) ||
$self->_error( qq[Could not read '$file': ] .
$IO::Uncompress::Bunzip2::Bunzip2Error
);
$fh;
};
In my experiments MultiStream=>1 works also for tarballs compressed with traditional bzip2.