| 1 | package Module::Install::CustomInstallationPath; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 2 | ▶ | use 5.005; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | 2 | ▶ | use File::HomeDir; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 2 | ▶ | use Config; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 2 | ▶ | use vars qw( @ISA $VERSION ); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 2 | ▶ | use Module::Install::Base; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | 2 | @ISA = qw( Module::Install::Base ); | |||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 2 | $VERSION = sprintf "%d.%02d%02d", q/0.10.47/ =~ /(\d+)/g; | |||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | # --------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | sub check_custom_installation | ||||||||||||||||||||||||||||
| 18 | { | ||||||||||||||||||||||||||||
| 19 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||
|
Subroutine
check_custom_installation: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||
| 21 | 0 | $self->include_deps('File::HomeDir',0); | |||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||
| 23 | 0 | ▶ | return if (grep {/^PREFIX=/} @ARGV) || (grep {/^INSTALLDIRS=/} @ARGV); | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
grep {/^PREFIX=/;} @ARGV or grep {/^INSTALLDIRS=/;} @ARGV
MC/DC0%0/2
grep {/^PREFIX=/;} @ARGV or grep {/^INSTALLDIRS=/;} @ARGV
grep {/^PREFIX=/;} @ARGV
grep {/^INSTALLDIRS=/;} @ARGV
Truth table0%0/3
A or B
A= grep {/^PREFIX=/;} @ARGVB= grep {/^INSTALLDIRS=/;} @ARGV
| |||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | 0 | my $install_location = $self->prompt( | |||||||||||||||||||||||||||
| 26 | "Would you like to install this package into a location other than the\n" . | ||||||||||||||||||||||||||||
| 27 | "default Perl location (i.e. change the PREFIX)?" => 'n'); | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | 0 | ▶ | if ($install_location eq 'y') | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 30 | { | ||||||||||||||||||||||||||||
| 31 | 0 | my $home = home(); | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | die "Your home directory could not be determined. Aborting." | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 34 | unless defined $home; | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | 0 | print "\n","-"x78,"\n\n"; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | my $prefix = $self->prompt( | |||||||||||||||||||||||||||
| 39 | "What PREFIX should I use?\n=>" => $home); | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | push @ARGV,"PREFIX=$prefix"; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 2 | 1; | |||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | # --------------------------------------------------------------------------- | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | =head1 NAME | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | Module::Install::CustomInstallationPath - A Module::Install extension that allows the user to interactively specify custom installation directories | ||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | In Makefile.PL: | ||||||||||||||||||||||||||||
| 57 | use inc::Module::Install; | ||||||||||||||||||||||||||||
| 58 | ... | ||||||||||||||||||||||||||||
| 59 | check_custom_installation(); | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | This is a Module::Install extension that helps users who do not have root | ||||||||||||||||||||||||||||
| 65 | access to install modules. It first prompts the user for a normal installation | ||||||||||||||||||||||||||||
| 66 | into the default Perl paths, or a custom installation. If the user selects a | ||||||||||||||||||||||||||||
| 67 | custom installation, it prompts the user for the value for PREFIX. This value | ||||||||||||||||||||||||||||
| 68 | is then used to add PREFIX=value to @ARGV. | ||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | If the user specifies PREFIX or INSTALLDIRS as arguments to Makefile.PL, then | ||||||||||||||||||||||||||||
| 71 | the prompts are skipped and a normal installation is done. | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | =head1 COMPATIBILITY NOTE | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | Consider carefully whether you want to use this module. In my experience, many | ||||||||||||||||||||||||||||
| 77 | people don't want an interactive installation. For example, CPAN users have | ||||||||||||||||||||||||||||
| 78 | likely already thought about custom installation paths. Debian package | ||||||||||||||||||||||||||||
| 79 | maintainers also want non-interactive installs. | ||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | =head1 METHODS | ||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||
| 83 | =over 4 | ||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||
| 85 | =item check_custom_installation() | ||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||
| 87 | Imported into Makefile.PL by Module::Install when invoked. This causes the | ||||||||||||||||||||||||||||
| 88 | prompts to be displayed and @ARGV to be updated (if necessary). | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | =back | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | |||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | =head1 LICENSE | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | This code is distributed under the GNU General Public License (GPL) Version 2. | ||||||||||||||||||||||||||||
| 98 | See the file LICENSE in the distribution for details. | ||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||
| 100 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | David Coppit E<lt>david@coppit.orgE<gt> | ||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||
| 104 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||
| 106 | L<Module::Install> | ||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||
| 108 | =cut | ||||||||||||||||||||||||||||