line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
1277
|
use v5.14.0; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
29
|
|
2
|
1
|
|
|
1
|
|
3
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
25
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package OS::Package::Artifact::Role::Extract; |
5
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
227
|
use Archive::Extract; |
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
7
|
|
|
|
|
|
|
use File::Copy; |
8
|
|
|
|
|
|
|
use File::Path qw( make_path remove_tree ); |
9
|
|
|
|
|
|
|
use Path::Tiny; |
10
|
|
|
|
|
|
|
use OS::Package::Config; |
11
|
|
|
|
|
|
|
use OS::Package::Log; |
12
|
|
|
|
|
|
|
use Role::Tiny; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# ABSTRACT: Provides the extract method for Artifact role. |
15
|
|
|
|
|
|
|
our $VERSION = '0.2.5'; # 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__ |