| 1 | package App::SmokeBrew::BuildPerl; | ||||||||||||||||||||||||||||
| 2 | 4 | $App::SmokeBrew::BuildPerl::VERSION = '1.06'; | |||||||||||||||||||||||||||
| 3 | #ABSTRACT: build and install a particular version of Perl | ||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 4 | ▶ | use App::SmokeBrew::Tools; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Log::Message::Simple qw[msg error]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use CPAN::Perl::Releases qw[perl_tarballs]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use Perl::Version; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use File::Spec; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use Devel::PatchPerl; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use Config qw[]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use Cwd qw[chdir cwd]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 15 | 4 | ▶ | use IPC::Cmd qw[run can_run]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use File::Path qw[mkpath rmtree]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 17 | 4 | ▶ | use File::pushd qw[pushd]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | 4 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 20 | 4 | ▶ | use Moose::Util::TypeConstraints; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 21 | 4 | ▶ | use MooseX::Types::Path::Class qw[Dir]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 22 | 4 | ▶ | use App::SmokeBrew::Types qw[ArrayRefStr ArrayRefUri]; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | 4 | with 'App::SmokeBrew::PerlVersion'; | |||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||
| 26 | 4 | my @mirrors = ( | |||||||||||||||||||||||||||
| 27 | 'http://www.cpan.org/', | ||||||||||||||||||||||||||||
| 28 | 'http://cpan.cpantesters.org/', | ||||||||||||||||||||||||||||
| 29 | ); | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | 4 | has 'builddir' => ( | |||||||||||||||||||||||||||
| 32 | is => 'ro', | ||||||||||||||||||||||||||||
| 33 | isa => Dir, | ||||||||||||||||||||||||||||
| 34 | required => 1, | ||||||||||||||||||||||||||||
| 35 | coerce => 1, | ||||||||||||||||||||||||||||
| 36 | ); | ||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 4 | has 'prefix' => ( | |||||||||||||||||||||||||||
| 39 | is => 'ro', | ||||||||||||||||||||||||||||
| 40 | isa => Dir, | ||||||||||||||||||||||||||||
| 41 | required => 1, | ||||||||||||||||||||||||||||
| 42 | coerce => 1, | ||||||||||||||||||||||||||||
| 43 | ); | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | has 'perlargs' => ( | ||||||||||||||||||||||||||||
| 46 | is => 'ro', | ||||||||||||||||||||||||||||
| 47 | isa => 'ArrayRefStr', | ||||||||||||||||||||||||||||
| 48 | 0 | ▶ | default => sub { [] }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 49 | 4 | auto_deref => 1, | |||||||||||||||||||||||||||
| 50 | ); | ||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||
| 52 | 4 | has 'skiptest' => ( | |||||||||||||||||||||||||||
| 53 | is => 'ro', | ||||||||||||||||||||||||||||
| 54 | isa => 'Bool', | ||||||||||||||||||||||||||||
| 55 | default => 0, | ||||||||||||||||||||||||||||
| 56 | ); | ||||||||||||||||||||||||||||
| 57 | |||||||||||||||||||||||||||||
| 58 | 4 | has 'verbose' => ( | |||||||||||||||||||||||||||
| 59 | is => 'ro', | ||||||||||||||||||||||||||||
| 60 | isa => 'Bool', | ||||||||||||||||||||||||||||
| 61 | default => 0, | ||||||||||||||||||||||||||||
| 62 | ); | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | 4 | has 'noclean' => ( | |||||||||||||||||||||||||||
| 65 | is => 'ro', | ||||||||||||||||||||||||||||
| 66 | isa => 'Bool', | ||||||||||||||||||||||||||||
| 67 | default => 0, | ||||||||||||||||||||||||||||
| 68 | ); | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 4 | has 'nozapman' => ( | |||||||||||||||||||||||||||
| 71 | is => 'ro', | ||||||||||||||||||||||||||||
| 72 | isa => 'Bool', | ||||||||||||||||||||||||||||
| 73 | default => 0, | ||||||||||||||||||||||||||||
| 74 | ); | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | has 'make' => ( | ||||||||||||||||||||||||||||
| 77 | is => 'ro', | ||||||||||||||||||||||||||||
| 78 | isa => 'Str', | ||||||||||||||||||||||||||||
| 79 | 4 | ▶ | default => sub { my $make = $Config::Config{make} || 'make'; can_run( $make ) }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=2 SCAR=7.2
Condition50%1/2
$Config::Config{'make'} || 'make'
MC/DC0%0/1
$Config::Config{'make'} || 'make'
$Config::Config{'make'}
Truth table50%1/2
A
A= $Config::Config{'make'}
| |||||||||||||||||||||||||||||
| 80 | 4 | ); | |||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||
| 82 | 4 | has 'jobs' => ( | |||||||||||||||||||||||||||
| 83 | is => 'ro', | ||||||||||||||||||||||||||||
| 84 | isa => 'Int', | ||||||||||||||||||||||||||||
| 85 | ); | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | has 'mirrors' => ( | ||||||||||||||||||||||||||||
| 88 | is => 'ro', | ||||||||||||||||||||||||||||
| 89 | isa => 'ArrayRefUri', | ||||||||||||||||||||||||||||
| 90 | 4 | ▶ | default => sub { \@mirrors }, | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 91 | 4 | coerce => 1, | |||||||||||||||||||||||||||
| 92 | ); | ||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | 1 | ▶ | sub build_perl { | ||||||||||||||||||||||||||
|
Subroutine
build_perl: called CC=16 SCAR=51.3
Pod
documented
| |||||||||||||||||||||||||||||
| 95 | 1 | my $self = shift; | |||||||||||||||||||||||||||
| 96 | 1 | my $perl_version = $self->perl_version; | |||||||||||||||||||||||||||
| 97 | 1 | msg(sprintf("Starting build for '%s'",$perl_version), $self->verbose); | |||||||||||||||||||||||||||
| 98 | 1 | ▶ | if ( grep { m!Dusequadmath! } $self->perlargs ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 99 | 1 | msg(sprintf("Checking if this perl '%s' can be built with quadmath",$perl_version), $self->verbose); | |||||||||||||||||||||||||||
| 100 | 1 | ▶ | if ( ! $self->can_quadmath ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 101 | 1 | error(sprintf("This perl '%s' cannot be built with quadmath",$perl_version), $self->verbose); | |||||||||||||||||||||||||||
| 102 | 1 | return; | |||||||||||||||||||||||||||
| 103 | } | ||||||||||||||||||||||||||||
| 104 | 0 | msg(sprintf("Congratulations, this perl '%s' can be built with quadmath",$perl_version), $self->verbose); | |||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||
| 106 | 0 | $self->builddir->mkpath(); | |||||||||||||||||||||||||||
| 107 | 0 | my $file = $self->_fetch(); | |||||||||||||||||||||||||||
| 108 | 0 | ▶ | return unless $file; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 109 | 0 | my $extract = $self->_extract( $file ); | |||||||||||||||||||||||||||
| 110 | 0 | ▶ | return unless $extract; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 111 | 0 | ▶ | unlink( $file ) unless $self->noclean(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 112 | 0 | $self->prefix->mkpath(); | |||||||||||||||||||||||||||
| 113 | 0 | my $prefix = File::Spec->catdir( $self->prefix->absolute, $perl_version ); | |||||||||||||||||||||||||||
| 114 | 0 | msg("Removing existing installation at ($prefix)", $self->verbose ); | |||||||||||||||||||||||||||
| 115 | 0 | rmtree( $prefix ); | |||||||||||||||||||||||||||
| 116 | 0 | msg('Applying any applicable patches to the source', $self->verbose ); | |||||||||||||||||||||||||||
| 117 | 0 | Devel::PatchPerl->patch_source( $self->version->stringify, $extract ); | |||||||||||||||||||||||||||
| 118 | { | ||||||||||||||||||||||||||||
| 119 | 0 | my $CWD = pushd( $extract ); | |||||||||||||||||||||||||||
| 120 | 0 | mkpath( File::Spec->catdir( $prefix, 'bin' ) ); | |||||||||||||||||||||||||||
| 121 | 0 | my @conf_opts = $self->perlargs; | |||||||||||||||||||||||||||
| 122 | 0 | ▶ | push @conf_opts, '-Dusedevel' if $self->is_dev_release(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 123 | 0 | unshift @conf_opts, '-Dprefix=' . $prefix; | |||||||||||||||||||||||||||
| 124 | 0 | local $ENV{MAKE} = $self->make; | |||||||||||||||||||||||||||
| 125 | 0 | my $cmd = [ './Configure', '-des', @conf_opts ]; | |||||||||||||||||||||||||||
| 126 | 0 | ▶ | my $jobs = ( $self->jobs && $self->can_jobs ? "-j" . $self->jobs : '' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$self->jobs and $self->can_jobs
MC/DC0%0/2
$self->jobs and $self->can_jobs
$self->jobs
$self->can_jobs
Truth table0%0/3
A and B
A= $self->jobsB= $self->can_jobs
| |||||||||||||||||||||||||||||
| 127 | 0 | ▶ | return unless scalar run( command => $cmd, | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 128 | verbose => 1, ); | ||||||||||||||||||||||||||||
| 129 | 0 | ▶ | return unless scalar run( command => [ $self->make, $jobs ], verbose => $self->verbose ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 130 | 0 | ▶ | unless ( $self->skiptest ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 131 | 0 | ▶ | return unless scalar run( command => [ $self->make, $jobs, 'test' ], verbose => $self->verbose ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||
| 133 | 0 | ▶ | return unless scalar run( command => [ $self->make, $jobs, 'install' ], verbose => $self->verbose ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 134 | 0 | ▶ | rmtree ( File::Spec->catdir( $prefix, 'man' ) ) # remove the manpages | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 135 | unless $self->nozapman; | ||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||
| 137 | 0 | ▶ | rmtree( $extract ) unless $self->noclean(); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 138 | 0 | return $prefix; | |||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||
| 141 | 0 | ▶ | sub _fetch { | ||||||||||||||||||||||||||
|
Subroutine
_fetch: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 142 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 143 | 0 | my $perldist; | |||||||||||||||||||||||||||
| 144 | { | ||||||||||||||||||||||||||||
| 145 | 0 | ( my $version = $self->perl_version ) =~ s/perl-//g; | |||||||||||||||||||||||||||
| 146 | 0 | my $tarballs = perl_tarballs( $version ); | |||||||||||||||||||||||||||
| 147 | 0 | $perldist = 'authors/id/' . $tarballs->{'tar.gz'}; | |||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||
| 149 | 0 | msg("Fetching '" . $perldist . "'", $self->verbose); | |||||||||||||||||||||||||||
| 150 | 0 | my $stat = App::SmokeBrew::Tools->fetch( $perldist, $self->builddir->absolute, $self->mirrors ); | |||||||||||||||||||||||||||
| 151 | 0 | ▶ | return $stat if $stat; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 152 | 0 | error("Failed to fetch '". $perldist . "'", $self->verbose); | |||||||||||||||||||||||||||
| 153 | 0 | return $stat; | |||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||
| 155 | |||||||||||||||||||||||||||||
| 156 | 0 | ▶ | sub _extract { | ||||||||||||||||||||||||||
|
Subroutine
_extract: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||
| 157 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 158 | 0 | ▶ | my $tarball = shift || return; | ||||||||||||||||||||||||||
|
Condition0%0/2
shift() || (return)
MC/DC0%0/1
shift() || (return)
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||
| 159 | 0 | msg("Extracting '$tarball'", $self->verbose); | |||||||||||||||||||||||||||
| 160 | 0 | return App::SmokeBrew::Tools->extract( $tarball, $self->builddir->absolute ); | |||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||
| 163 | 4 | ▶ | no Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||
| 165 | 4 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||
| 167 | 4 | qq[Building a perl]; | |||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||
| 169 | __END__ | ||||||||||||||||||||||||||||