File Coverage

blib/lib/Module/Install/CustomInstallationPath.pm
Criterion Covered Total %
statement 17 29 58.6
branch 0 6 0.0
condition 0 3 0.0
subroutine 6 7 85.7
pod 1 1 100.0
total 24 46 52.1


line stmt bran cond sub pod time code
1             package Module::Install::CustomInstallationPath;
2              
3 2     2   119533 use strict;
  2         20  
  2         66  
4 2     2   118 use 5.005;
  2         7  
5 2     2   933 use File::HomeDir;
  2         10696  
  2         181  
6 2     2   13 use Config;
  2         5  
  2         112  
7              
8 2     2   12 use vars qw( @ISA $VERSION );
  2         5  
  2         78  
9              
10 2     2   793 use Module::Install::Base;
  2         1203  
  2         189  
11             @ISA = qw( Module::Install::Base );
12              
13             $VERSION = sprintf "%d.%02d%02d", q/0.10.48/ =~ /(\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