File Coverage

blib/lib/Module/Install/CustomInstallationPath.pm
Criterion Covered Total %
statement 18 30 60.0
branch 0 6 0.0
condition 0 3 0.0
subroutine 6 7 85.7
pod 1 1 100.0
total 25 47 53.1


line stmt bran cond sub pod time code
1             package Module::Install::CustomInstallationPath;
2              
3 1     1   15137 use strict;
  1         2  
  1         31  
4 1     1   13 use 5.005;
  1         2  
  1         20  
5 1     1   1345 use File::HomeDir;
  1         4149  
  1         74  
6 1     1   6 use Config;
  1         1  
  1         51  
7              
8 1     1   6 use vars qw( @ISA $VERSION );
  1         1  
  1         230  
9              
10 1     1   539 use Module::Install::Base;
  1         463  
  1         189  
11             @ISA = qw( Module::Install::Base );
12              
13             $VERSION = sprintf "%d.%02d%02d", q/0.10.44/ =~ /(\d+)/g;
14              
15             # ---------------------------------------------------------------------------
16              
17             sub check_custom_installation
18             {
19 0     0 1   my $self = shift;
20              
21 0           $self->include_deps('File::HomeDir',0);
22              
23 0 0 0       return if (grep {/^PREFIX=/} @ARGV) || (grep {/^INSTALLDIRS=/} @ARGV);
  0            
  0            
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 0         if ($install_location eq 'y')
30             {
31 0           my $home = home();
32              
33 0 0         die "Your home directory could not be determined. Aborting."
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             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 Edavid@coppit.orgE
103              
104             =head1 SEE ALSO
105              
106             L
107              
108             =cut