line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Portable::Config;
|
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
900
|
use 5.008;
|
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
29
|
|
4
|
1
|
|
|
1
|
|
4
|
use strict;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
23
|
|
5
|
1
|
|
|
1
|
|
4
|
use warnings;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
19
|
|
6
|
1
|
|
|
1
|
|
4
|
use Portable::FileSpec;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
344
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
our $VERSION = '1.22';
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
#####################################################################
|
11
|
|
|
|
|
|
|
# Constructor
|
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
sub new {
|
14
|
0
|
|
|
0
|
0
|
|
my $class = shift;
|
15
|
0
|
|
|
|
|
|
my $parent = shift;
|
16
|
0
|
0
|
|
|
|
|
unless ( Portable::_HASH($parent->portable_config) ) {
|
17
|
0
|
|
|
|
|
|
die('Missing or invalid config key in portable.perl');
|
18
|
|
|
|
|
|
|
}
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Create the object
|
21
|
0
|
|
|
|
|
|
my $self = bless { }, $class;
|
22
|
0
|
|
|
|
|
|
my $conf = $parent->portable_config;
|
23
|
0
|
|
|
|
|
|
my $root = $parent->dist_root;
|
24
|
0
|
|
|
|
|
|
foreach my $key ( sort keys %$conf ) {
|
25
|
0
|
0
|
0
|
|
|
|
unless (
|
|
|
|
0
|
|
|
|
|
26
|
|
|
|
|
|
|
defined $conf->{$key}
|
27
|
|
|
|
|
|
|
and
|
28
|
|
|
|
|
|
|
length $conf->{$key}
|
29
|
|
|
|
|
|
|
and not
|
30
|
|
|
|
|
|
|
$key =~ /^ld|^libpth$/
|
31
|
|
|
|
|
|
|
) {
|
32
|
0
|
|
|
|
|
|
$self->{$key} = $conf->{$key};
|
33
|
0
|
|
|
|
|
|
next;
|
34
|
|
|
|
|
|
|
}
|
35
|
|
|
|
|
|
|
#join path to directory of portable perl with value from config file
|
36
|
0
|
0
|
|
|
|
|
if ($key eq 'perlpath') {
|
37
|
0
|
|
|
|
|
|
$self->{$key} = Portable::FileSpec::catfile($root, split /\//, $conf->{$key});
|
38
|
|
|
|
|
|
|
}
|
39
|
|
|
|
|
|
|
else {
|
40
|
0
|
|
|
|
|
|
$self->{$key} = Portable::FileSpec::catdir($root, split /\//, $conf->{$key});
|
41
|
|
|
|
|
|
|
}
|
42
|
|
|
|
|
|
|
}
|
43
|
0
|
|
|
|
|
|
foreach my $key ( grep { /^ld|^libpth$/ } keys %$self ) {
|
|
0
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
#special handling of linker config variables and libpth
|
45
|
0
|
0
|
|
|
|
|
next unless defined $self->{$key};
|
46
|
0
|
|
|
|
|
|
$self->{$key} =~ s/\$(\w+)/$self->{$1}/g;
|
47
|
|
|
|
|
|
|
}
|
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
|
return $self;
|
50
|
|
|
|
|
|
|
}
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub apply {
|
53
|
0
|
|
|
0
|
0
|
|
my $self = shift;
|
54
|
0
|
|
|
|
|
|
my $parent = shift;
|
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
# Force all Config entries to load, so that
|
57
|
|
|
|
|
|
|
# all Config_heavy.pl code has run, and none
|
58
|
|
|
|
|
|
|
# of our values will be overwritten later.
|
59
|
0
|
|
|
|
|
|
require Config;
|
60
|
0
|
|
|
|
|
|
my $preload = { %Config::Config };
|
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# Shift the tie STORE method out the way
|
63
|
1
|
|
|
|
|
102
|
SCOPE: {
|
64
|
1
|
|
|
1
|
|
5
|
no warnings;
|
|
1
|
|
|
|
|
50
|
|
|
0
|
|
|
|
|
|
|
65
|
0
|
|
|
|
|
|
*Config::_TEMP = *Config::STORE;
|
66
|
|
|
|
|
|
|
*Config::STORE = sub {
|
67
|
0
|
|
|
0
|
|
|
$_[0]->{$_[1]} = $_[2];
|
68
|
0
|
|
|
|
|
|
};
|
69
|
|
|
|
|
|
|
}
|
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
# Write the values to the Config hash
|
72
|
0
|
|
|
|
|
|
foreach my $key ( sort keys %$self ) {
|
73
|
0
|
|
|
|
|
|
$Config::Config{$key} = $self->{$key};
|
74
|
|
|
|
|
|
|
}
|
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
# Restore the STORE method
|
77
|
|
|
|
|
|
|
SCOPE: {
|
78
|
1
|
|
|
1
|
|
4
|
no warnings;
|
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
150
|
|
|
0
|
|
|
|
|
|
|
79
|
0
|
|
|
|
|
|
*Config::STORE = delete $Config::{_TEMP};
|
80
|
|
|
|
|
|
|
}
|
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
# Confirm we got all the paths
|
83
|
0
|
|
|
|
|
|
my $volume = quotemeta $parent->dist_volume;
|
84
|
0
|
|
|
|
|
|
foreach my $key ( sort keys %Config::Config ) {
|
85
|
0
|
0
|
|
|
|
|
next unless defined $Config::Config{$key};
|
86
|
0
|
0
|
|
|
|
|
next if $Config::Config{$key} =~ /$volume/i;
|
87
|
0
|
0
|
|
|
|
|
next unless $Config::Config{$key} =~ /\b[a-z]\:/i;
|
88
|
0
|
|
|
|
|
|
die "Failed to localize \$Config::Config{$key} ($Config::Config{$key})";
|
89
|
|
|
|
|
|
|
}
|
90
|
|
|
|
|
|
|
|
91
|
0
|
|
|
|
|
|
return 1;
|
92
|
|
|
|
|
|
|
}
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
1;
|