| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Module::Plan::Archive; |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# Simple module for creating Module::Build::Plan archives, which are |
|
4
|
|
|
|
|
|
|
# single-file packaged sets of tarballs with a build in p5i script. |
|
5
|
|
|
|
|
|
|
|
|
6
|
1
|
|
|
1
|
|
925
|
use 5.006; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
45
|
|
|
7
|
1
|
|
|
1
|
|
12
|
use strict; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
40
|
|
|
8
|
1
|
|
|
1
|
|
8
|
use Params::Util (); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
21
|
|
|
9
|
1
|
|
|
1
|
|
2287
|
use Archive::Tar (); |
|
|
1
|
|
|
|
|
135400
|
|
|
|
1
|
|
|
|
|
27
|
|
|
10
|
1
|
|
|
1
|
|
11
|
use Module::Plan::Base (); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
16
|
|
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
5
|
use vars qw{$VERSION}; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
76
|
|
|
13
|
|
|
|
|
|
|
BEGIN { |
|
14
|
1
|
|
|
1
|
|
610
|
$VERSION = '1.19'; |
|
15
|
|
|
|
|
|
|
} |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
##################################################################### |
|
22
|
|
|
|
|
|
|
# Constructor and Accessors |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub new { |
|
25
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
26
|
0
|
|
|
|
|
|
my $self = bless { @_ }, $class; |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
# Check params |
|
29
|
0
|
0
|
|
|
|
|
unless ( Params::Util::_INSTANCE($self->plan, 'Module::Plan::Base') ) { |
|
30
|
0
|
|
|
|
|
|
Carp("Did not provide a Module::Plan::Base object to Archive contructor"); |
|
31
|
|
|
|
|
|
|
} |
|
32
|
0
|
0
|
|
|
|
|
unless ( $self->plan->can('fetch') ) { |
|
33
|
0
|
|
|
|
|
|
Carp("The plan does not implement a 'fetch' method"); |
|
34
|
|
|
|
|
|
|
} |
|
35
|
|
|
|
|
|
|
|
|
36
|
0
|
|
|
|
|
|
return $self; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub from_p5i { |
|
40
|
0
|
|
|
0
|
0
|
|
my $class = shift; |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
# Create an archive from a file name |
|
43
|
0
|
|
|
|
|
|
my $file = shift; |
|
44
|
0
|
0
|
0
|
|
|
|
unless ( Params::Util::_STRING($file) and -f $file ) { |
|
45
|
0
|
|
|
|
|
|
Carp('Missing or invalid file name'); |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
# Create the plan, and from that the archive |
|
49
|
0
|
|
|
|
|
|
return $class->new( |
|
50
|
|
|
|
|
|
|
plan => Module::Plan::Base->read( $file, @_ ), |
|
51
|
|
|
|
|
|
|
); |
|
52
|
|
|
|
|
|
|
} |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub plan { |
|
55
|
0
|
|
|
0
|
0
|
|
$_[0]->{plan}; |
|
56
|
|
|
|
|
|
|
} |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub no_inject { |
|
59
|
0
|
|
|
0
|
0
|
|
$_[0]->plan->no_inject; |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
##################################################################### |
|
67
|
|
|
|
|
|
|
# Archive Generation |
|
68
|
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub save { |
|
70
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
71
|
0
|
|
|
|
|
|
my $file = shift; |
|
72
|
0
|
|
|
|
|
|
my $archive = $self->archive; |
|
73
|
0
|
|
|
|
|
|
my $rv = $archive->write( $file, 9 ); |
|
74
|
0
|
|
|
|
|
|
return 1; |
|
75
|
|
|
|
|
|
|
} |
|
76
|
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub archive { |
|
78
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
79
|
0
|
|
|
|
|
|
my $plan = $self->plan; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
# Create the tarball and add the plan |
|
82
|
0
|
|
|
|
|
|
my $tar = Archive::Tar->new; |
|
83
|
0
|
|
|
|
|
|
$tar->add_data( 'default.p5i', $self->default_p5i ); |
|
84
|
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
# Add the files |
|
86
|
0
|
|
|
|
|
|
foreach my $name ( $plan->names ) { |
|
87
|
0
|
0
|
|
|
|
|
unless ( $plan->dists_hash->{$name} ) { |
|
88
|
0
|
|
|
|
|
|
$plan->_fetch_uri($name); |
|
89
|
|
|
|
|
|
|
} |
|
90
|
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
# Read the dist into memory and add to tarball |
|
92
|
0
|
|
|
|
|
|
my $file = $plan->dists_hash->{$name}; |
|
93
|
0
|
|
|
|
|
|
my $buffer = ''; |
|
94
|
0
|
|
|
|
|
|
SCOPE: { |
|
95
|
0
|
|
|
|
|
|
local $/ = undef; |
|
96
|
0
|
0
|
|
|
|
|
open( DIST, $file ) or die "open: $!"; |
|
97
|
0
|
0
|
|
|
|
|
defined($buffer = ) or die "read: $!"; |
|
98
|
0
|
0
|
|
|
|
|
close( DIST ) or die "close: $!"; |
|
99
|
|
|
|
|
|
|
} |
|
100
|
0
|
|
|
|
|
|
$tar->add_data( $name, $buffer ); |
|
101
|
|
|
|
|
|
|
} |
|
102
|
|
|
|
|
|
|
|
|
103
|
0
|
|
|
|
|
|
return $tar; |
|
104
|
|
|
|
|
|
|
} |
|
105
|
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
# Generate the new default.p5i plan file for the archive |
|
107
|
|
|
|
|
|
|
sub default_p5i { |
|
108
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
109
|
0
|
0
|
|
|
|
|
my $class = $self->can('ref') ? $self->ref : ref($self); |
|
110
|
0
|
|
|
|
|
|
return join '', map { "$_\n" } ( $class, "", $self->plan->names ); |
|
|
0
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
} |
|
112
|
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
1; |