| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package CPAN::Mini::Inject::Config; |
|
2
|
|
|
|
|
|
|
|
|
3
|
13
|
|
|
13
|
|
99
|
use strict; |
|
|
13
|
|
|
|
|
31
|
|
|
|
13
|
|
|
|
|
395
|
|
|
4
|
13
|
|
|
13
|
|
86
|
use warnings; |
|
|
13
|
|
|
|
|
37
|
|
|
|
13
|
|
|
|
|
427
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
13
|
|
|
13
|
|
75
|
use Carp; |
|
|
13
|
|
|
|
|
28
|
|
|
|
13
|
|
|
|
|
937
|
|
|
7
|
13
|
|
|
13
|
|
5620
|
use File::Spec::Functions qw(rootdir catfile); |
|
|
13
|
|
|
|
|
8931
|
|
|
|
13
|
|
|
|
|
7830
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
CPAN::Mini::Inject::Config - Config for CPAN::Mini::Inject |
|
12
|
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=head1 VERSION |
|
14
|
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
Version 0.35 |
|
16
|
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
=cut |
|
18
|
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
our $VERSION = '0.35'; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
=head2 C |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=cut |
|
24
|
|
|
|
|
|
|
|
|
25
|
16
|
|
|
16
|
1
|
150
|
sub new { bless { file => undef }, $_[0] } |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
=head2 C<< config_file( [FILE] ) >> |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=cut |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub config_file { |
|
32
|
63
|
|
|
63
|
1
|
176
|
my ( $self, $file ) = @_; |
|
33
|
|
|
|
|
|
|
|
|
34
|
63
|
100
|
|
|
|
258
|
if ( @_ == 2 ) { |
|
35
|
18
|
50
|
|
|
|
476
|
croak( "Could not read file [$file]!" ) unless -r $file; |
|
36
|
18
|
|
|
|
|
110
|
$self->{file} = $file; |
|
37
|
|
|
|
|
|
|
} |
|
38
|
|
|
|
|
|
|
|
|
39
|
63
|
|
|
|
|
962
|
$self->{file}; |
|
40
|
|
|
|
|
|
|
} |
|
41
|
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
=head2 C<< load_config() >> |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
loadcfg accepts a CPAN::Mini::Inject config file or if not defined |
|
45
|
|
|
|
|
|
|
will search the following four places in order: |
|
46
|
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
=over 4 |
|
48
|
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
=item * file pointed to by the environment variable MCPANI_CONFIG |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
=item * $HOME/.mcpani/config |
|
52
|
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
=item * /usr/local/etc/mcpani |
|
54
|
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
=item * /etc/mcpani |
|
56
|
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
=back |
|
58
|
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
loadcfg sets the instance variable cfgfile to the file found or undef if |
|
61
|
|
|
|
|
|
|
none is found. |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
print "$mcpi->{cfgfile}\n"; # /etc/mcpani |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=cut |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub load_config { |
|
68
|
19
|
|
|
19
|
1
|
99
|
my $self = shift; |
|
69
|
|
|
|
|
|
|
|
|
70
|
19
|
|
100
|
|
|
101
|
my $cfgfile = shift || $self->_find_config; |
|
71
|
|
|
|
|
|
|
|
|
72
|
19
|
100
|
|
|
|
118
|
croak 'Unable to find config file' unless $cfgfile; |
|
73
|
18
|
|
|
|
|
94
|
$self->config_file( $cfgfile ); |
|
74
|
|
|
|
|
|
|
|
|
75
|
18
|
|
|
|
|
72
|
return $cfgfile; |
|
76
|
|
|
|
|
|
|
} |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub _find_config { |
|
79
|
|
|
|
|
|
|
my ( @files ) = ( |
|
80
|
|
|
|
|
|
|
$ENV{MCPANI_CONFIG}, |
|
81
|
|
|
|
|
|
|
( |
|
82
|
|
|
|
|
|
|
defined $ENV{HOME} |
|
83
|
3
|
100
|
|
3
|
|
55
|
? catfile( $ENV{HOME}, qw(.mcpani config) ) |
|
84
|
|
|
|
|
|
|
: () |
|
85
|
|
|
|
|
|
|
), |
|
86
|
|
|
|
|
|
|
catfile( rootdir(), qw(usr local etc mcpani) ), |
|
87
|
|
|
|
|
|
|
catfile( rootdir(), qw(etc mcpani) ), |
|
88
|
|
|
|
|
|
|
); |
|
89
|
|
|
|
|
|
|
|
|
90
|
3
|
|
|
|
|
14
|
for my $file ( @files ) { |
|
91
|
6
|
100
|
|
|
|
23
|
next unless defined $file; |
|
92
|
4
|
100
|
|
|
|
59
|
next unless -r $file; |
|
93
|
|
|
|
|
|
|
|
|
94
|
2
|
|
|
|
|
16
|
return $file; |
|
95
|
|
|
|
|
|
|
} |
|
96
|
|
|
|
|
|
|
|
|
97
|
1
|
|
|
|
|
6
|
return; |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
=head2 C<< parse_config() >> |
|
101
|
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
parsecfg reads the config file stored in the instance variable cfgfile and |
|
103
|
|
|
|
|
|
|
creates a hash in config with each setting. |
|
104
|
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
$mcpi->{config}{remote} # CPAN sites to mirror from. |
|
106
|
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
parsecfg expects the config file in the following format: |
|
108
|
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
local: /www/CPAN |
|
110
|
|
|
|
|
|
|
remote: ftp://ftp.cpan.org/pub/CPAN ftp://ftp.kernel.org/pub/CPAN |
|
111
|
|
|
|
|
|
|
repository: /work/mymodules |
|
112
|
|
|
|
|
|
|
passive: yes |
|
113
|
|
|
|
|
|
|
dirmode: 0755 |
|
114
|
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
Description of options: |
|
116
|
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=over 4 |
|
118
|
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
=item * local |
|
120
|
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
location to store local CPAN::Mini mirror (*REQUIRED*) |
|
122
|
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
=item * remote |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
CPAN site(s) to mirror from. Multiple sites can be listed space separated. |
|
126
|
|
|
|
|
|
|
(*REQUIRED*) |
|
127
|
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=item * repository |
|
129
|
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
Location to store modules to add to the local CPAN::Mini mirror. |
|
131
|
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
=item * passive |
|
133
|
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
Enable passive FTP. |
|
135
|
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
=item * dirmode |
|
137
|
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
Set the permissions of created directories to the specified mode. The default |
|
139
|
|
|
|
|
|
|
value is based on umask if supported. |
|
140
|
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
=back |
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
If either local or remote are not defined parsecfg croaks. |
|
144
|
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
=cut |
|
146
|
|
|
|
|
|
|
|
|
147
|
|
|
|
|
|
|
sub parse_config { |
|
148
|
15
|
|
|
15
|
1
|
39
|
my $self = shift; |
|
149
|
|
|
|
|
|
|
|
|
150
|
15
|
|
|
|
|
57
|
my $file = shift; |
|
151
|
|
|
|
|
|
|
|
|
152
|
15
|
|
|
|
|
53
|
my %required = map { $_, 1 } qw(local remote); |
|
|
30
|
|
|
|
|
185
|
|
|
153
|
|
|
|
|
|
|
|
|
154
|
15
|
100
|
|
|
|
85
|
$self->load_config( $file ) unless $self->config_file; |
|
155
|
|
|
|
|
|
|
|
|
156
|
15
|
50
|
|
|
|
56
|
if ( -r $self->config_file ) { |
|
157
|
15
|
50
|
|
|
|
174
|
open my ( $fh ), "<", $self->config_file |
|
158
|
|
|
|
|
|
|
or croak( "Could not open config file: $!" ); |
|
159
|
|
|
|
|
|
|
|
|
160
|
15
|
|
|
|
|
364
|
while ( <$fh> ) { |
|
161
|
73
|
100
|
|
|
|
294
|
next if /^\s*#/; |
|
162
|
71
|
100
|
|
|
|
868
|
$self->{$1} = $2 if /^\s*([^:\s]+)\s*:\s*(.*?)\s*$/; |
|
163
|
71
|
100
|
|
|
|
443
|
delete $required{$1} if defined $required{$1}; |
|
164
|
|
|
|
|
|
|
} |
|
165
|
|
|
|
|
|
|
|
|
166
|
15
|
|
|
|
|
234
|
close $fh; |
|
167
|
|
|
|
|
|
|
|
|
168
|
15
|
100
|
|
|
|
136
|
croak 'Required parameter(s): ' |
|
169
|
|
|
|
|
|
|
. join( ' ', keys %required ) |
|
170
|
|
|
|
|
|
|
. ' missing.' |
|
171
|
|
|
|
|
|
|
if keys %required; |
|
172
|
|
|
|
|
|
|
} |
|
173
|
|
|
|
|
|
|
|
|
174
|
14
|
|
|
|
|
65
|
return $self; |
|
175
|
|
|
|
|
|
|
} |
|
176
|
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
=head2 C<< get( DIRECTIVE ) >> |
|
178
|
|
|
|
|
|
|
|
|
179
|
|
|
|
|
|
|
Return the value for the named configuration directive. |
|
180
|
|
|
|
|
|
|
|
|
181
|
|
|
|
|
|
|
=cut |
|
182
|
|
|
|
|
|
|
|
|
183
|
125
|
|
|
125
|
1
|
2032
|
sub get { $_[0]->{ $_[1] } } |
|
184
|
|
|
|
|
|
|
|
|
185
|
|
|
|
|
|
|
=head2 C<< set( DIRECTIVE, VALUE ) >> |
|
186
|
|
|
|
|
|
|
|
|
187
|
|
|
|
|
|
|
Sets the value for the named configuration directive. |
|
188
|
|
|
|
|
|
|
|
|
189
|
|
|
|
|
|
|
=cut |
|
190
|
|
|
|
|
|
|
|
|
191
|
0
|
|
|
0
|
1
|
|
sub set { $_[0]->{ $_[1] } = $_[2] } |
|
192
|
|
|
|
|
|
|
|
|
193
|
|
|
|
|
|
|
=head1 CURRENT MAINTAINER |
|
194
|
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
Christian Walde C<< >> |
|
196
|
|
|
|
|
|
|
|
|
197
|
|
|
|
|
|
|
=head1 BUGS |
|
198
|
|
|
|
|
|
|
|
|
199
|
|
|
|
|
|
|
Please report any bugs or feature requests to |
|
200
|
|
|
|
|
|
|
C, or through the web interface at |
|
201
|
|
|
|
|
|
|
L. I will be notified, and then you'll automatically |
|
202
|
|
|
|
|
|
|
be notified of progress on your bug as I make changes. |
|
203
|
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
=cut |
|
205
|
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
1; |