| 1 | package App::cpackage; | ||||||||||
| 2 | |||||||||||
| 3 | 1 | ▶ | use 5.010; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | 1 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 6 | 1 | ▶ | use App::cpanminus 1.5002; # Dependency check | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use Capture::Tiny qw/capture/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | 1 | ▶ | use Config; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 9 | 1 | ▶ | use File::Copy; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | 1 | ▶ | use File::Spec::Functions qw/catfile curdir/; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 11 | |||||||||||
| 12 | 1 | our $VERSION = '1.01'; | |||||||||
| 13 | |||||||||||
| 14 | 0 | ▶ | sub run { | ||||||||
|
Subroutine
run: not called CC=5 SCAR=34.0
Pod
undocumented
| |||||||||||
| 15 | 0 | ▶ | die "Usage: $0 cpanm_options module_name\n" unless @ARGV; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 16 | |||||||||||
| 17 | 0 | my $module_name = pop @ARGV; | |||||||||
| 18 | 0 | my @cpanm_options = @ARGV; | |||||||||
| 19 | |||||||||||
| 20 | #--Make our own copy of the 'cpanm' executable------------------------------ | ||||||||||
| 21 | |||||||||||
| 22 | 0 | my $cpanm = catfile($Config{bin},'cpanm'); | |||||||||
| 23 | 0 | ▶ | die "Cannot find cpanm (looking in $Config{bin})" unless -e -r $cpanm; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 24 | 0 | ▶ | die "Cannot write to current directory" unless -w curdir; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 25 | |||||||||||
| 26 | 0 | mkdir 'bin'; | |||||||||
| 27 | 0 | copy $cpanm => catfile(curdir, 'bin', 'cpanm'); | |||||||||
| 28 | |||||||||||
| 29 | |||||||||||
| 30 | #--Use cpanm to get dependency list----------------------------------------- | ||||||||||
| 31 | |||||||||||
| 32 | 0 | mkdir 'extlib'; | |||||||||
| 33 | 0 | mkdir 'packages'; | |||||||||
| 34 | |||||||||||
| 35 | 0 | say "Analysing dependencies for $module_name"; | |||||||||
| 36 | 0 | ▶ | my ($dist_list, $log) = capture { | ||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||
| 37 | 0 | system($^X, 'bin/cpanm', @cpanm_options, '--format', 'dists', '--save-dists', 'packages', '-L', 'extlib', '--scandeps', $module_name); | |||||||||
| 38 | 0 | }; | |||||||||
| 39 | |||||||||||
| 40 | 0 | ▶ | die "Couldn't extract depedencies:\n\n$log\n" unless $dist_list; | ||||||||
|
Branch: 1 branch
| |||||||||||
| 41 | 0 | rmdir 'extlib'; | |||||||||
| 42 | |||||||||||
| 43 | |||||||||||
| 44 | #--Write installer script--------------------------------------------------- | ||||||||||
| 45 | |||||||||||
| 46 | 0 | my $installer = 'install.pl'; | |||||||||
| 47 | 0 | open my $fh, '>', $installer; | |||||||||
| 48 | |||||||||||
| 49 | 0 | print $fh <<'EOT'; | |||||||||
| 50 | #! /usr/bin/env perl | ||||||||||
| 51 | |||||||||||
| 52 | use strict; | ||||||||||
| 53 | use warnings; | ||||||||||
| 54 | |||||||||||
| 55 | my @cpanm_options = @ARGV; | ||||||||||
| 56 | |||||||||||
| 57 | while (<DATA>) { | ||||||||||
| 58 | chomp; | ||||||||||
| 59 | if (my ($author) = split '/') { | ||||||||||
| 60 | my $a = substr($author,0,1); | ||||||||||
| 61 | my $ab = substr($author,0,2); | ||||||||||
| 62 | |||||||||||
| 63 | system($^X, 'bin/cpanm', @cpanm_options, "packages/authors/id/$a/$ab/$_"); | ||||||||||
| 64 | } | ||||||||||
| 65 | } | ||||||||||
| 66 | __DATA__ | ||||||||||