| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package App::ThinPacker; |
|
2
|
1
|
|
|
1
|
|
27848
|
use 5.8.0; |
|
|
1
|
|
|
|
|
4
|
|
|
|
1
|
|
|
|
|
64
|
|
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
=pod |
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
=head1 NAME |
|
7
|
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
App::ThinPacker - enable your scripts to autoinstall their dependencies |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
11
|
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
Enables your scripts to autoinstall their dependencies by injecting a small piece of code which downloads L and uses it to install all the depenencies. |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
thinpack your-script.pl > your-script-dist.pl |
|
17
|
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 SEE ALSO |
|
19
|
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
L |
|
21
|
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
L |
|
23
|
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
=head1 BUGS AND TODO |
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
=over 4 |
|
27
|
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
=item No Windows support |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
=item Rudimentary parsing |
|
31
|
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
=item Default --sudo for cpanm |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
=item Downloading cpanm from third-party source |
|
35
|
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
=back |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
=head1 AUTHOR |
|
39
|
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
Alex Kapranoff Ekappa@cpan.orgE |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head1 CONTRIBUTORS |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
Alexey Surikov Eksuri@cpan.orgE |
|
45
|
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
=head1 LICENSE |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
This program is free software, you can redistribute it under the same terms as Perl itself. |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
|
51
|
|
|
|
|
|
|
|
|
52
|
1
|
|
|
1
|
|
6
|
use strict; |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
36
|
|
|
53
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
|
1
|
|
|
|
|
7
|
|
|
|
1
|
|
|
|
|
39
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
1
|
|
|
1
|
|
1188
|
use PPI; |
|
|
1
|
|
|
|
|
216703
|
|
|
|
1
|
|
|
|
|
34
|
|
|
56
|
1
|
|
|
1
|
|
10
|
use Pod::Find; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
54
|
|
|
57
|
1
|
|
|
1
|
|
7092
|
use Pod::Usage; |
|
|
1
|
|
|
|
|
59229
|
|
|
|
1
|
|
|
|
|
533
|
|
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
our $VERSION = '0.11'; |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
sub run { |
|
62
|
0
|
0
|
|
0
|
0
|
|
my $arg = shift or usage(); |
|
63
|
0
|
0
|
0
|
|
|
|
usage(2) if $arg eq '-h' or $arg eq '--help'; |
|
64
|
|
|
|
|
|
|
|
|
65
|
0
|
0
|
|
|
|
|
my $ppi = PPI::Document->new($arg) or usage(); |
|
66
|
0
|
|
|
|
|
|
my $includes = $ppi->find('Statement::Include'); |
|
67
|
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
my $deps = join ' ', |
|
69
|
0
|
|
|
|
|
|
grep { $_ !~ /^(?:strict|warnings|diagnostics|base|integer)$/ } |
|
70
|
0
|
|
|
|
|
|
map { $_->module } |
|
71
|
|
|
|
|
|
|
@$includes; |
|
72
|
|
|
|
|
|
|
|
|
73
|
0
|
|
|
|
|
|
my $inject = join '', map { s/%%DEPS%%/$deps/; $_ } ; |
|
|
0
|
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
|
|
75
|
0
|
0
|
|
|
|
|
open my $script, '<', $arg or exit print "Cannot open $arg: $!\n"; |
|
76
|
0
|
|
|
|
|
|
my $not_injected = 1; |
|
77
|
0
|
|
|
|
|
|
while (my $line = <$script>) { |
|
78
|
0
|
0
|
0
|
|
|
|
if ($line =~ /^use / && $not_injected) { |
|
79
|
0
|
|
|
|
|
|
print "BEGIN {\n$inject\n}\n"; |
|
80
|
0
|
|
|
|
|
|
$not_injected = 0; |
|
81
|
|
|
|
|
|
|
} |
|
82
|
|
|
|
|
|
|
|
|
83
|
0
|
|
|
|
|
|
print $line; |
|
84
|
|
|
|
|
|
|
} |
|
85
|
|
|
|
|
|
|
} |
|
86
|
|
|
|
|
|
|
|
|
87
|
|
|
|
|
|
|
sub usage { |
|
88
|
0
|
|
0
|
0
|
0
|
|
pod2usage( |
|
89
|
|
|
|
|
|
|
-verbose => $_[0] || 0, |
|
90
|
|
|
|
|
|
|
-output => \*STDERR, |
|
91
|
|
|
|
|
|
|
-input => Pod::Find::pod_where( |
|
92
|
|
|
|
|
|
|
{ -inc => 1 }, |
|
93
|
|
|
|
|
|
|
__PACKAGE__, |
|
94
|
|
|
|
|
|
|
), |
|
95
|
|
|
|
|
|
|
); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
__DATA__ |