line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Shipwright::Source::Compressed; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
1429
|
use warnings; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
112
|
|
4
|
3
|
|
|
3
|
|
11
|
use strict; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
93
|
|
5
|
3
|
|
|
3
|
|
14
|
use File::Spec::Functions qw/catfile catdir/; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
164
|
|
6
|
|
|
|
|
|
|
|
7
|
3
|
|
|
3
|
|
14
|
use base qw/Shipwright::Source::Base/; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
1082
|
|
8
|
3
|
|
|
3
|
|
2496
|
use Archive::Extract; |
|
3
|
|
|
|
|
322106
|
|
|
3
|
|
|
|
|
36
|
|
9
|
3
|
|
|
3
|
|
135
|
use File::Temp qw/tempdir/; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
161
|
|
10
|
3
|
|
|
3
|
|
14
|
use File::Copy::Recursive qw/rmove/; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
111
|
|
11
|
3
|
|
|
3
|
|
16
|
use Shipwright::Util; |
|
3
|
|
|
|
|
5
|
|
|
3
|
|
|
|
|
279
|
|
12
|
3
|
|
|
3
|
|
16
|
use Cwd qw/getcwd/; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
1561
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head2 run |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=cut |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
sub run { |
19
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
20
|
|
|
|
|
|
|
|
21
|
0
|
0
|
|
|
|
|
$self->name( $self->just_name( $self->path ) ) unless $self->name; |
22
|
0
|
0
|
|
|
|
|
$self->version( $self->just_version( $self->path ) ) unless $self->version; |
23
|
0
|
|
|
|
|
|
$self->log->info( 'running source ' . $self->name . ': ' . $self->source ); |
24
|
|
|
|
|
|
|
|
25
|
0
|
|
|
|
|
|
$self->_update_version( $self->name, $self->version ); |
26
|
|
|
|
|
|
|
|
27
|
0
|
0
|
|
|
|
|
$self->_update_url( $self->name, 'file:' . $self->source ) |
28
|
|
|
|
|
|
|
unless $self->{_no_update_url}; |
29
|
|
|
|
|
|
|
|
30
|
0
|
|
|
|
|
|
my $newer = $self->_cmd; # if we really get something new |
31
|
|
|
|
|
|
|
|
32
|
0
|
|
|
|
|
|
my $ret = $self->SUPER::run(@_); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# follow only if --follow and we really added new stuff. |
35
|
0
|
0
|
0
|
|
|
|
$self->_follow( catdir( $self->directory, $self->name ) ) |
36
|
|
|
|
|
|
|
if $self->follow && $newer; |
37
|
0
|
|
|
|
|
|
return catdir( $self->directory, $self->name ); |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
=head2 path |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
the decompressed source path |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
=cut |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub path { |
47
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# we memoize path info so we don't need to extract on each call. |
50
|
0
|
0
|
|
|
|
|
return $self->{_path} if $self->{_path}; |
51
|
|
|
|
|
|
|
|
52
|
0
|
|
|
|
|
|
my $source = $self->source; |
53
|
0
|
|
|
|
|
|
my $ae = Archive::Extract->new( archive => $source ); |
54
|
|
|
|
|
|
|
# this's to check if $source is valid, aka. it only contains one directory. |
55
|
0
|
|
|
|
|
|
my $tmp_dir = tempdir( 'shipwright_tmp_XXXXXX', CLEANUP => 1, TMPDIR => 1 ); |
56
|
0
|
|
|
|
|
|
$ae->extract( to => $tmp_dir ); |
57
|
0
|
|
|
|
|
|
my $files = $ae->files; |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
# 1st file in Crypt-DH-0.07.tar.gz is "./" |
60
|
0
|
0
|
|
|
|
|
shift @$files if $files->[0] =~ /^\.[\/\\]$/; |
61
|
0
|
|
|
|
|
|
my $base_dir = $files->[0]; |
62
|
|
|
|
|
|
|
# some compressed file has name like ./PerlImagick-6.67/ |
63
|
0
|
|
|
|
|
|
$base_dir =~ s!^\.[/\\]!!; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
# sunnavy found that the 1st file is not the directory name when extracting |
66
|
|
|
|
|
|
|
# HTML-Strip-1.06.tar.gz, which is weird but valid compressed file. |
67
|
0
|
|
|
|
|
|
$base_dir =~ s![/\\].*!!; |
68
|
|
|
|
|
|
|
|
69
|
0
|
0
|
|
|
|
|
if ( @$files != grep { /^(?:\.[\/\\])?\Q$base_dir\E/ } @$files ) { |
|
0
|
|
|
|
|
|
|
70
|
0
|
|
|
|
|
|
confess_or_die 'only support compressed file which contains only one directory: ' |
71
|
|
|
|
|
|
|
. $base_dir; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
|
74
|
0
|
|
|
|
|
|
$self->{_path} = $base_dir; |
75
|
|
|
|
|
|
|
|
76
|
0
|
|
|
|
|
|
return $base_dir; |
77
|
|
|
|
|
|
|
} |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
sub _cmd { |
80
|
0
|
|
|
0
|
|
|
my $self = shift; |
81
|
0
|
|
|
|
|
|
my $arg; |
82
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
my ( $from, $to ); |
84
|
0
|
|
|
|
|
|
$from = catdir( $self->directory, $self->path ); |
85
|
0
|
|
|
|
|
|
$to = catdir( $self->directory, $self->name ); |
86
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
# if it already exists, assuming we have processed it already, don't do it |
88
|
|
|
|
|
|
|
# again |
89
|
0
|
0
|
|
|
|
|
return if -e $to; |
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
my $ae = Archive::Extract->new( archive => $self->source ); |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
return sub { |
94
|
0
|
|
|
0
|
|
|
$ae->extract( to => $self->directory ); |
95
|
|
|
|
|
|
|
|
96
|
0
|
0
|
0
|
|
|
|
if ( -e catfile( $from, 'dist.ini' ) |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
97
|
|
|
|
|
|
|
&& !-e catfile( $from, 'configure' ) |
98
|
|
|
|
|
|
|
&& !-e catfile( $from, 'Makefile.PL' ) |
99
|
|
|
|
|
|
|
&& !-e catfile( $from, 'Build.PL' ) ) |
100
|
|
|
|
|
|
|
{ |
101
|
|
|
|
|
|
|
# assume it's a Dist::Zilla dist |
102
|
0
|
0
|
|
|
|
|
if ( $from eq $to ) { |
103
|
0
|
|
|
|
|
|
rmove( $from, $from . '-tmp' ); |
104
|
|
|
|
|
|
|
} |
105
|
|
|
|
|
|
|
|
106
|
0
|
|
|
|
|
|
my $old = getcwd(); |
107
|
0
|
|
|
|
|
|
chdir $from . '-tmp'; |
108
|
0
|
|
|
|
|
|
run_cmd( [ $ENV{SHIPWRIGHT_DZIL}, 'build', '--in', $to ] ); |
109
|
0
|
|
|
|
|
|
chdir $old; |
110
|
|
|
|
|
|
|
} |
111
|
|
|
|
|
|
|
|
112
|
0
|
0
|
|
|
|
|
if ( $from ne $to ) { |
113
|
0
|
|
|
|
|
|
rmove( $from, $to ); |
114
|
|
|
|
|
|
|
} |
115
|
0
|
|
|
|
|
|
}; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
1; |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
__END__ |