line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# --8<--8<--8<--8<-- |
2
|
|
|
|
|
|
|
# |
3
|
|
|
|
|
|
|
# Copyright (C) 2011 Smithsonian Astrophysical Observatory |
4
|
|
|
|
|
|
|
# |
5
|
|
|
|
|
|
|
# This file is part of Module::Install::TemplateInstallPath |
6
|
|
|
|
|
|
|
# |
7
|
|
|
|
|
|
|
# Module::Install::TemplateInstallPath is free software: you can |
8
|
|
|
|
|
|
|
# redistribute it and/or modify it under the terms of the GNU General |
9
|
|
|
|
|
|
|
# Public License as published by the Free Software Foundation, either |
10
|
|
|
|
|
|
|
# version 3 of the License, or (at your option) any later version. |
11
|
|
|
|
|
|
|
# |
12
|
|
|
|
|
|
|
# This program is distributed in the hope that it will be useful, |
13
|
|
|
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
|
|
|
|
# GNU General Public License for more details. |
16
|
|
|
|
|
|
|
# |
17
|
|
|
|
|
|
|
# You should have received a copy of the GNU General Public License |
18
|
|
|
|
|
|
|
# along with this program. If not, see . |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
# -->8-->8-->8-->8-- |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
package Module::Install::TemplateInstallPath; |
23
|
|
|
|
|
|
|
|
24
|
1
|
|
|
1
|
|
56843
|
use strict; |
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
74
|
|
25
|
1
|
|
|
1
|
|
12
|
use warnings; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
100
|
|
26
|
1
|
|
|
1
|
|
4
|
use Carp; |
|
1
|
|
|
|
|
34
|
|
|
1
|
|
|
|
|
255
|
|
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
29
|
|
|
|
|
|
|
|
30
|
1
|
|
|
1
|
|
5
|
use base 'Module::Install::Base'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
859
|
|
31
|
|
|
|
|
|
|
|
32
|
1
|
|
|
1
|
|
1100
|
use File::Spec::Functions qw[ catdir ]; |
|
1
|
|
|
|
|
1879
|
|
|
1
|
|
|
|
|
701
|
|
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
my %Tokens = ( |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
'%n' => sub { $_[0]->name }, |
37
|
|
|
|
|
|
|
'%v' => sub { $_[0]->version }, |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
sub _fill_template { |
42
|
|
|
|
|
|
|
|
43
|
0
|
|
|
0
|
|
|
my $self = shift; |
44
|
0
|
|
|
|
|
|
my ( $tpl, $tokens ) = @_; |
45
|
|
|
|
|
|
|
|
46
|
0
|
|
|
|
|
|
my ( $token, $value ); |
47
|
|
|
|
|
|
|
|
48
|
0
|
|
|
|
|
|
while ( ( $token, $value ) = each %$tokens ) |
49
|
|
|
|
|
|
|
{ |
50
|
0
|
0
|
|
|
|
|
next unless defined $value; |
51
|
0
|
0
|
|
|
|
|
my $value = 'CODE' eq ref $value ? $value->($self) : $value; |
52
|
|
|
|
|
|
|
|
53
|
0
|
|
|
|
|
|
$tpl =~ s/$token/$value/g; |
54
|
|
|
|
|
|
|
} |
55
|
0
|
|
|
|
|
|
return $tpl; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
sub template_install_path { |
59
|
|
|
|
|
|
|
|
60
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
61
|
0
|
|
|
|
|
|
my %arg = ( template => undef, |
62
|
|
|
|
|
|
|
catdir => 1, |
63
|
|
|
|
|
|
|
tokens => {}, |
64
|
|
|
|
|
|
|
@_ ); |
65
|
|
|
|
|
|
|
|
66
|
0
|
|
|
|
|
|
my %tokens = ( %Tokens, %{$arg{tokens}} ); |
|
0
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
|
68
|
0
|
|
|
|
|
|
for my $argv ( @ARGV ) |
69
|
|
|
|
|
|
|
{ |
70
|
0
|
0
|
|
|
|
|
next unless $argv =~ /^(INSTALL_BASE|PREFIX|LIB)=(.*)/i; |
71
|
|
|
|
|
|
|
|
72
|
0
|
0
|
|
|
|
|
die ( "$1: no value specified\n" ) |
73
|
|
|
|
|
|
|
unless defined $2; |
74
|
0
|
|
|
|
|
|
my $var = $1; |
75
|
0
|
|
|
|
|
|
my $base = $2; |
76
|
|
|
|
|
|
|
|
77
|
0
|
|
|
|
|
|
my $nbase = $self->_fill_template( $base, \%tokens ); |
78
|
|
|
|
|
|
|
|
79
|
0
|
0
|
0
|
|
|
|
if ( $nbase eq $base && defined $arg{template} ) |
80
|
|
|
|
|
|
|
{ |
81
|
0
|
|
|
|
|
|
$nbase = $self->_fill_template( $arg{template}, \%tokens ); |
82
|
0
|
0
|
|
|
|
|
$nbase = catdir( $base, $nbase ) |
83
|
|
|
|
|
|
|
if $arg{catdir}; |
84
|
|
|
|
|
|
|
} |
85
|
|
|
|
|
|
|
|
86
|
0
|
|
|
|
|
|
$argv = "\U$var\E=$nbase"; |
87
|
|
|
|
|
|
|
} |
88
|
|
|
|
|
|
|
|
89
|
0
|
|
|
|
|
|
return; |
90
|
|
|
|
|
|
|
} |
91
|
|
|
|
|
|
|
1; |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
__END__ |