| 1 | package ExtUtils::InstallPAR; | ||||||||||||
| 2 | 2 | ▶ | use strict; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 3 | 2 | ▶ | use vars qw/$VERSION @ISA @EXPORT_OK %EXPORT_TAGS/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 4 | 2 | ▶ | BEGIN { | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 5 | 2 | $VERSION = '0.03'; | |||||||||||
| 6 | } | ||||||||||||
| 7 | |||||||||||||
| 8 | 2 | ▶ | use Config; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 9 | 2 | ▶ | use Carp qw/croak/; | ||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||
| 10 | 2 | require PAR::Dist; | |||||||||||
| 11 | 2 | require Config; | |||||||||||
| 12 | 2 | require File::Spec; | |||||||||||
| 13 | 2 | require Exporter; | |||||||||||
| 14 | 2 | @ISA = qw(Exporter); | |||||||||||
| 15 | 2 | %EXPORT_TAGS = ('all' => [qw(install)]); | |||||||||||
| 16 | 2 | @EXPORT_OK = @{$EXPORT_TAGS{all}}; | |||||||||||
| 17 | |||||||||||||
| 18 | =head1 NAME | ||||||||||||
| 19 | |||||||||||||
| 20 | ExtUtils::InstallPAR - Install .par's into any installed perl | ||||||||||||
| 21 | |||||||||||||
| 22 | =head1 SYNOPSIS | ||||||||||||
| 23 | |||||||||||||
| 24 | use ExtUtils::InstallPAR; | ||||||||||||
| 25 | |||||||||||||
| 26 | # Install into the currently running perl: | ||||||||||||
| 27 | ExtUtils::InstallPAR::install( | ||||||||||||
| 28 | par => './Foo-Bar-0.01-MSWin32-multi-thread-5.10.0.par', | ||||||||||||
| 29 | ); | ||||||||||||
| 30 | |||||||||||||
| 31 | # Install into a different perl on the system, | ||||||||||||
| 32 | # this requires the ExtUtils::Infer module. | ||||||||||||
| 33 | ExtUtils::InstallPAR::install( | ||||||||||||
| 34 | par => './Foo-Bar-0.01-MSWin32-multi-thread-5.10.0.par', | ||||||||||||
| 35 | perl => '/path/to/perl.exe', | ||||||||||||
| 36 | ); | ||||||||||||
| 37 | |||||||||||||
| 38 | # If LWP::Simple is available, it works with URLs, too: | ||||||||||||
| 39 | ExtUtils::InstallPAR::install( | ||||||||||||
| 40 | par => 'http://foo.com/Foo-Bar-0.01-MSWin32-multi-thread-5.10.0.par', | ||||||||||||
| 41 | ); | ||||||||||||
| 42 | |||||||||||||
| 43 | =head1 DESCRIPTION | ||||||||||||
| 44 | |||||||||||||
| 45 | This module installs PAR distributions (i.e. C<.par> files) into | ||||||||||||
| 46 | any perl installation on the system. The L<PAR::Dist> module can | ||||||||||||
| 47 | install into the currently running perl by default and provides | ||||||||||||
| 48 | the necessary parameters to override any installation directories. | ||||||||||||
| 49 | Figuring out how to use those overrides in order to install into | ||||||||||||
| 50 | an arbitrary perl installation on the system may be beyond most users, | ||||||||||||
| 51 | however. Hence this convenience wrapper using L<ExtUtils::InferConfig> | ||||||||||||
| 52 | to automatically determine the typical I<site> installation paths | ||||||||||||
| 53 | of any perl interpreter than can be executed by the current user. | ||||||||||||
| 54 | |||||||||||||
| 55 | =head1 FUNCTIONS | ||||||||||||
| 56 | |||||||||||||
| 57 | =head2 install | ||||||||||||
| 58 | |||||||||||||
| 59 | Install a PAR archive into any perl on the system. Takes named parameters: | ||||||||||||
| 60 | |||||||||||||
| 61 | C<par =E<gt> '/path/to/foo.par'> or C<par =E<gt> 'http://URL/to/foo.par'> | ||||||||||||
| 62 | specifies the path to the .par file to install or an URL to fetch it from | ||||||||||||
| 63 | (of LWP::Simple is available). This parameter is mandatory. | ||||||||||||
| 64 | |||||||||||||
| 65 | The C<perl =E<gt> '/path/to/perl'> parameter can be used to specify | ||||||||||||
| 66 | the perl interpreter to install into. If you omit this option or set | ||||||||||||
| 67 | it to C<undef>, the currently running perl will be used as target. | ||||||||||||
| 68 | If you want to install into different perls, you will need to | ||||||||||||
| 69 | install the C<ExtUtils::InferConfig> module. | ||||||||||||
| 70 | |||||||||||||
| 71 | C<verbosity =E<gt> $value> can be used to set the verbosity of the | ||||||||||||
| 72 | installation process. Defaults to C<1>. | ||||||||||||
| 73 | |||||||||||||
| 74 | =cut | ||||||||||||
| 75 | |||||||||||||
| 76 | 0 | ▶ | sub install { | ||||||||||
|
Subroutine
install: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||
| 77 | 0 | ▶ | shift if $_[0] =~ __PACKAGE__; | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 78 | 0 | my %args = @_; | |||||||||||
| 79 | |||||||||||||
| 80 | 0 | my $par = $args{par}; | |||||||||||
| 81 | 0 | my $perl = $args{perl}; | |||||||||||
| 82 | 0 | ▶ | my $verbosity = $args{verbosity} || 0; | ||||||||||
|
Condition0%0/2
$args{'verbosity'} || 0
MC/DC0%0/1
$args{'verbosity'} || 0
$args{'verbosity'}
Truth table0%0/2
A
A= $args{'verbosity'}
| |||||||||||||
| 83 | 0 | ▶ | if (not defined $par) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 84 | 0 | croak(__PACKAGE__."::install requires a 'par' parameter"); | |||||||||||
| 85 | } | ||||||||||||
| 86 | |||||||||||||
| 87 | 0 | my $name = $par; | |||||||||||
| 88 | 0 | $name =~ s/^\w+:\/\///; | |||||||||||
| 89 | 0 | my @name_elems = PAR::Dist::parse_dist_name($name); | |||||||||||
| 90 | 0 | ▶ | if (2 <= grep {defined} @name_elems) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 91 | 0 | $name = join('-', @name_elems); | |||||||||||
| 92 | } | ||||||||||||
| 93 | else { | ||||||||||||
| 94 | 0 | (undef, undef, my $file) = File::Spec->splitpath($name); | |||||||||||
| 95 | 0 | $name = $file; | |||||||||||
| 96 | 0 | $name =~ s/\.par$//i; | |||||||||||
| 97 | } | ||||||||||||
| 98 | |||||||||||||
| 99 | 0 | my $config; | |||||||||||
| 100 | 0 | ▶ | if (defined $perl) { | ||||||||||
|
Branch: 1 branch
| |||||||||||||
| 101 | 0 | require ExtUtils::InferConfig; | |||||||||||
| 102 | 0 | my $eic = ExtUtils::InferConfig->new( | |||||||||||
| 103 | perl => $perl, | ||||||||||||
| 104 | ); | ||||||||||||
| 105 | |||||||||||||
| 106 | 0 | $config = $eic->get_config(); | |||||||||||
| 107 | } | ||||||||||||
| 108 | else { | ||||||||||||
| 109 | 0 | $config = \%Config::Config; | |||||||||||
| 110 | } | ||||||||||||
| 111 | |||||||||||||
| 112 | my $par_target = { | ||||||||||||
| 113 | inst_lib => $config->{installsitelib}, | ||||||||||||
| 114 | inst_archlib => $config->{installsitearch}, | ||||||||||||
| 115 | inst_bin => $config->{installbin}, | ||||||||||||
| 116 | inst_script => $config->{installscript}, | ||||||||||||
| 117 | inst_man1dir => $config->{installman1dir}, | ||||||||||||
| 118 | inst_man3dir => $config->{installman3dir}, | ||||||||||||
| 119 | packlist_write => $config->{sitearchexp} . "/auto/$name/.packlist", | ||||||||||||
| 120 | 0 | packlist_read => $config->{sitearchexp} . "/auto/$name/.packlist", | |||||||||||
| 121 | }; | ||||||||||||
| 122 | |||||||||||||
| 123 | |||||||||||||
| 124 | 0 | return PAR::Dist::install_par( | |||||||||||
| 125 | name => $name, | ||||||||||||
| 126 | dist => $par, | ||||||||||||
| 127 | %$par_target, | ||||||||||||
| 128 | auto_inst_lib_conversion => 1, | ||||||||||||
| 129 | ); | ||||||||||||
| 130 | } | ||||||||||||
| 131 | |||||||||||||
| 132 | 2 | 1; | |||||||||||
| 133 | __END__ | ||||||||||||