line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Alien::Build::Plugin::Extract::ArchiveTar; |
2
|
|
|
|
|
|
|
|
3
|
7
|
|
|
7
|
|
1371
|
use strict; |
|
7
|
|
|
|
|
19
|
|
|
7
|
|
|
|
|
221
|
|
4
|
7
|
|
|
7
|
|
37
|
use warnings; |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
163
|
|
5
|
7
|
|
|
7
|
|
113
|
use 5.008004; |
|
7
|
|
|
|
|
38
|
|
6
|
7
|
|
|
7
|
|
462
|
use Alien::Build::Plugin; |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
47
|
|
7
|
7
|
|
|
7
|
|
973
|
use File::chdir; |
|
7
|
|
|
|
|
6489
|
|
|
7
|
|
|
|
|
854
|
|
8
|
7
|
|
|
7
|
|
60
|
use File::Temp (); |
|
7
|
|
|
|
|
25
|
|
|
7
|
|
|
|
|
138
|
|
9
|
7
|
|
|
7
|
|
57
|
use Path::Tiny (); |
|
7
|
|
|
|
|
24
|
|
|
7
|
|
|
|
|
4050
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# ABSTRACT: Plugin to extract a tarball using Archive::Tar |
12
|
|
|
|
|
|
|
our $VERSION = '2.46'; # 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
|
109959
|
my(undef, $ext) = @_; |
31
|
|
|
|
|
|
|
|
32
|
16
|
100
|
|
|
|
65
|
if($ext eq 'tar.gz') |
|
|
100
|
|
|
|
|
|
33
|
|
|
|
|
|
|
{ |
34
|
8
|
|
|
|
|
22
|
return !! eval { require Archive::Tar; Archive::Tar->has_zlib_support }; |
|
8
|
|
|
|
|
788
|
|
|
8
|
|
|
|
|
91371
|
|
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
|
|
|
|
|
28
|
|
|
3
|
|
|
|
|
29
|
|
39
|
|
|
|
|
|
|
} |
40
|
|
|
|
|
|
|
else |
41
|
|
|
|
|
|
|
{ |
42
|
5
|
|
|
|
|
25
|
return $ext eq 'tar'; |
43
|
|
|
|
|
|
|
} |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub init |
47
|
|
|
|
|
|
|
{ |
48
|
14
|
|
|
14
|
1
|
107
|
my($self, $meta) = @_; |
49
|
|
|
|
|
|
|
|
50
|
14
|
|
|
|
|
85
|
$meta->add_requires('share' => 'Archive::Tar' => 0); |
51
|
14
|
100
|
66
|
|
|
66
|
if($self->format eq 'tar.gz' || $self->format eq 'tgz') |
|
|
50
|
33
|
|
|
|
|
52
|
|
|
|
|
|
|
{ |
53
|
5
|
|
|
|
|
17
|
$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
|
|
36
|
my($build, $src) = @_; |
64
|
11
|
|
|
|
|
114
|
my $tar = Archive::Tar->new; |
65
|
11
|
|
|
|
|
210
|
$tar->read($src); |
66
|
11
|
|
|
|
|
59894
|
$tar->extract; |
67
|
|
|
|
|
|
|
} |
68
|
14
|
|
|
|
|
137
|
); |
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
|
|
535
|
my $dir = Path::Tiny->new(File::Temp::tempdir( CLEANUP => 1 )); |
76
|
3
|
|
|
|
|
1940
|
eval { |
77
|
3
|
|
|
|
|
38
|
local $CWD = $dir; |
78
|
3
|
|
|
|
|
268
|
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
|
|
|
|
|
15
|
Path::Tiny->new('xx.tar.bz2')->spew_raw($tarball); |
80
|
3
|
|
|
|
|
2461
|
require Archive::Tar; |
81
|
3
|
|
|
|
|
38
|
my $tar = Archive::Tar->new; |
82
|
3
|
|
|
|
|
62
|
$tar->read('xx.tar.bz2'); |
83
|
3
|
|
|
|
|
9037
|
$tar->extract; |
84
|
3
|
|
|
|
|
18223
|
my $content = Path::Tiny->new('xx.txt')->slurp; |
85
|
3
|
50
|
33
|
|
|
1692
|
die unless $content && $content eq "xx\n"; |
86
|
|
|
|
|
|
|
}; |
87
|
3
|
|
|
|
|
180
|
my $error = $@; |
88
|
3
|
|
|
|
|
40
|
$dir->remove_tree; |
89
|
3
|
|
|
|
|
2169
|
!$error; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
1; |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
__END__ |