| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Alien::Build::Plugin::Extract::ArchiveTar; |
|
2
|
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
1362
|
use strict; |
|
|
7
|
|
|
|
|
18
|
|
|
|
7
|
|
|
|
|
223
|
|
|
4
|
7
|
|
|
7
|
|
38
|
use warnings; |
|
|
7
|
|
|
|
|
16
|
|
|
|
7
|
|
|
|
|
167
|
|
|
5
|
7
|
|
|
7
|
|
122
|
use 5.008004; |
|
|
7
|
|
|
|
|
25
|
|
|
6
|
7
|
|
|
7
|
|
413
|
use Alien::Build::Plugin; |
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
49
|
|
|
7
|
7
|
|
|
7
|
|
977
|
use File::chdir; |
|
|
7
|
|
|
|
|
6310
|
|
|
|
7
|
|
|
|
|
824
|
|
|
8
|
7
|
|
|
7
|
|
54
|
use File::Temp (); |
|
|
7
|
|
|
|
|
16
|
|
|
|
7
|
|
|
|
|
150
|
|
|
9
|
7
|
|
|
7
|
|
37
|
use Path::Tiny (); |
|
|
7
|
|
|
|
|
14
|
|
|
|
7
|
|
|
|
|
3946
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Plugin to extract a tarball using Archive::Tar |
|
12
|
|
|
|
|
|
|
our $VERSION = '2.45'; # VERSION |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has '+format' => 'tar'; |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub handles |
|
19
|
|
|
|
|
|
|
{ |
|
20
|
0
|
|
|
0
|
1
|
0
|
my(undef, $ext) = @_; |
|
21
|
|
|
|
|
|
|
|
|
22
|
0
|
0
|
|
|
|
0
|
return 1 if $ext =~ /^(tar|tar.gz|tar.bz2|tbz|taz)$/; |
|
23
|
|
|
|
|
|
|
|
|
24
|
0
|
|
|
|
|
0
|
return 0; |
|
25
|
|
|
|
|
|
|
} |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub available |
|
29
|
|
|
|
|
|
|
{ |
|
30
|
16
|
|
|
16
|
1
|
97159
|
my(undef, $ext) = @_; |
|
31
|
|
|
|
|
|
|
|
|
32
|
16
|
100
|
|
|
|
74
|
if($ext eq 'tar.gz') |
|
|
|
100
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
{ |
|
34
|
8
|
|
|
|
|
26
|
return !! eval { require Archive::Tar; Archive::Tar->has_zlib_support }; |
|
|
8
|
|
|
|
|
784
|
|
|
|
8
|
|
|
|
|
87854
|
|
|
35
|
|
|
|
|
|
|
} |
|
36
|
|
|
|
|
|
|
elsif($ext eq 'tar.bz2') |
|
37
|
|
|
|
|
|
|
{ |
|
38
|
3
|
100
|
|
|
|
9
|
return !! eval { require Archive::Tar; Archive::Tar->has_bzip2_support && __PACKAGE__->_can_bz2 }; |
|
|
3
|
|
|
|
|
27
|
|
|
|
3
|
|
|
|
|
30
|
|
|
39
|
|
|
|
|
|
|
} |
|
40
|
|
|
|
|
|
|
else |
|
41
|
|
|
|
|
|
|
{ |
|
42
|
5
|
|
|
|
|
27
|
return $ext eq 'tar'; |
|
43
|
|
|
|
|
|
|
} |
|
44
|
|
|
|
|
|
|
} |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub init |
|
47
|
|
|
|
|
|
|
{ |
|
48
|
14
|
|
|
14
|
1
|
81
|
my($self, $meta) = @_; |
|
49
|
|
|
|
|
|
|
|
|
50
|
14
|
|
|
|
|
72
|
$meta->add_requires('share' => 'Archive::Tar' => 0); |
|
51
|
14
|
100
|
66
|
|
|
62
|
if($self->format eq 'tar.gz' || $self->format eq 'tgz') |
|
|
|
50
|
33
|
|
|
|
|
|
52
|
|
|
|
|
|
|
{ |
|
53
|
5
|
|
|
|
|
14
|
$meta->add_requires('share' => 'IO::Zlib' => 0); |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
elsif($self->format eq 'tar.bz2' || $self->format eq 'tbz') |
|
56
|
|
|
|
|
|
|
{ |
|
57
|
0
|
|
|
|
|
0
|
$meta->add_requires('share' => 'IO::Uncompress::Bunzip2' => 0); |
|
58
|
0
|
|
|
|
|
0
|
$meta->add_requires('share' => 'IO::Compress::Bzip2' => 0); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
$meta->register_hook( |
|
62
|
|
|
|
|
|
|
extract => sub { |
|
63
|
11
|
|
|
11
|
|
35
|
my($build, $src) = @_; |
|
64
|
11
|
|
|
|
|
134
|
my $tar = Archive::Tar->new; |
|
65
|
11
|
|
|
|
|
198
|
$tar->read($src); |
|
66
|
11
|
|
|
|
|
56362
|
$tar->extract; |
|
67
|
|
|
|
|
|
|
} |
|
68
|
14
|
|
|
|
|
132
|
); |
|
69
|
|
|
|
|
|
|
} |
|
70
|
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _can_bz2 |
|
72
|
|
|
|
|
|
|
{ |
|
73
|
|
|
|
|
|
|
# even when Archive::Tar reports that it supports bz2, I can sometimes get this error: |
|
74
|
|
|
|
|
|
|
# 'Cannot read enough bytes from the tarfile', so lets just probe for actual support! |
|
75
|
3
|
|
|
3
|
|
452
|
my $dir = Path::Tiny->new(File::Temp::tempdir( CLEANUP => 1 )); |
|
76
|
3
|
|
|
|
|
1868
|
eval { |
|
77
|
3
|
|
|
|
|
38
|
local $CWD = $dir; |
|
78
|
3
|
|
|
|
|
262
|
my $tarball = unpack "u", q{M0EIH.3%!62936=+(]$0``$A[D-$0`8!``7^``!!AI)Y`!```""``=!JGIH-(MT#0]0/2!**---&F@;4#0&:D;X?(6@JH(2<%'N$%3VHC-9E>S/N@"6&I*1@GNJNHCC2>$I5(<0BKR.=XBZ""HVZ;T,CV\LJ!K&*?9`#\7
|
|
79
|
3
|
|
|
|
|
20
|
Path::Tiny->new('xx.tar.bz2')->spew_raw($tarball); |
|
80
|
3
|
|
|
|
|
1770
|
require Archive::Tar; |
|
81
|
3
|
|
|
|
|
43
|
my $tar = Archive::Tar->new; |
|
82
|
3
|
|
|
|
|
59
|
$tar->read('xx.tar.bz2'); |
|
83
|
3
|
|
|
|
|
8785
|
$tar->extract; |
|
84
|
3
|
|
|
|
|
17258
|
my $content = Path::Tiny->new('xx.txt')->slurp; |
|
85
|
3
|
50
|
33
|
|
|
1531
|
die unless $content && $content eq "xx\n"; |
|
86
|
|
|
|
|
|
|
}; |
|
87
|
3
|
|
|
|
|
189
|
my $error = $@; |
|
88
|
3
|
|
|
|
|
54
|
$dir->remove_tree; |
|
89
|
3
|
|
|
|
|
2252
|
!$error; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |