line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
1749
|
use v5.14.0; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
35
|
|
2
|
1
|
|
|
1
|
|
4
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
38
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package OS::Package::Artifact::Role::Extract; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
2432
|
use Archive::Extract; |
|
1
|
|
|
|
|
195450
|
|
|
1
|
|
|
|
|
45
|
|
7
|
1
|
|
|
1
|
|
601
|
use File::Copy; |
|
1
|
|
|
|
|
1891
|
|
|
1
|
|
|
|
|
61
|
|
8
|
1
|
|
|
1
|
|
6
|
use File::Path qw( make_path remove_tree ); |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
39
|
|
9
|
1
|
|
|
1
|
|
4
|
use Path::Tiny; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
35
|
|
10
|
1
|
|
|
1
|
|
379
|
use OS::Package::Config; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
use OS::Package::Log; |
12
|
|
|
|
|
|
|
use Role::Tiny; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# ABSTRACT: Provides the extract method for Artifact role. |
15
|
|
|
|
|
|
|
our $VERSION = '0.2.6'; # VERSION |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
local $Archive::Extract::PREFER_BIN = 1; |
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
sub extract { |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my $self = shift; |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
if ( ! path($self->workdir)->exists ) { |
24
|
|
|
|
|
|
|
path($self->workdir)->mkpath; |
25
|
|
|
|
|
|
|
} |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
my $archive; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
if ( ! defined $self->distfile ) { |
30
|
|
|
|
|
|
|
return 1; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
if ( $self->distfile =~ /\.(tar|tgz|gz|Z|zip|bz2|tbz|lzma|xz|tx)$/ ) { |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$archive = Archive::Extract->new( archive => $self->savefile ); |
36
|
|
|
|
|
|
|
$LOGGER->info( sprintf 'extracting archive: %s', $self->distfile ); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
$archive->extract( to => $self->workdir ); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
$self->archive($archive); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
$LOGGER->info( sprintf 'extracted archive: %s', |
43
|
|
|
|
|
|
|
$self->archive->extract_path ); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
else { |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
$LOGGER->info( sprintf 'staging distfile to workdir: %s', |
48
|
|
|
|
|
|
|
$self->distfile ); |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
copy( $self->savefile, |
51
|
|
|
|
|
|
|
sprintf( '%s/%s', $self->workdir, $self->distfile ) ); |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
return 1; |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
1; |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__END__ |