line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::HandleConfig; |
2
|
13
|
|
|
13
|
|
590
|
use strict; |
|
13
|
|
|
|
|
31
|
|
|
13
|
|
|
|
|
458
|
|
3
|
13
|
|
|
13
|
|
78
|
use vars qw(%can %keys $loading $VERSION); |
|
13
|
|
|
|
|
27
|
|
|
13
|
|
|
|
|
802
|
|
4
|
13
|
|
|
13
|
|
86
|
use File::Path (); |
|
13
|
|
|
|
|
26
|
|
|
13
|
|
|
|
|
226
|
|
5
|
13
|
|
|
13
|
|
70
|
use File::Spec (); |
|
13
|
|
|
|
|
64
|
|
|
13
|
|
|
|
|
262
|
|
6
|
13
|
|
|
13
|
|
77
|
use File::Basename (); |
|
13
|
|
|
|
|
30
|
|
|
13
|
|
|
|
|
225
|
|
7
|
13
|
|
|
13
|
|
69
|
use Carp (); |
|
13
|
|
|
|
|
25
|
|
|
13
|
|
|
|
|
63407
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
=head1 NAME |
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
CPAN::HandleConfig - internal configuration handling for CPAN.pm |
12
|
|
|
|
|
|
|
|
13
|
|
|
|
|
|
|
=cut |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
$VERSION = "5.5008"; # see also CPAN::Config::VERSION at end of file |
16
|
|
|
|
|
|
|
|
17
|
|
|
|
|
|
|
%can = ( |
18
|
|
|
|
|
|
|
commit => "Commit changes to disk", |
19
|
|
|
|
|
|
|
defaults => "Reload defaults from disk", |
20
|
|
|
|
|
|
|
help => "Short help about 'o conf' usage", |
21
|
|
|
|
|
|
|
init => "Interactive setting of all options", |
22
|
|
|
|
|
|
|
); |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# Q: where is the "How do I add a new config option" HOWTO? |
25
|
|
|
|
|
|
|
# A1: svn diff -r 757:758 # where dagolden added test_report [git e997b71de88f1019a1472fc13cb97b1b7f96610f] |
26
|
|
|
|
|
|
|
# A2: svn diff -r 985:986 # where andk added yaml_module [git 312b6d9b12b1bdec0b6e282d853482145475021f] |
27
|
|
|
|
|
|
|
# A3: 1. add new config option to %keys below |
28
|
|
|
|
|
|
|
# 2. add a Pod description in CPAN::FirstTime; it should include a |
29
|
|
|
|
|
|
|
# prompt line; see others for examples |
30
|
|
|
|
|
|
|
# 3. add a "matcher" section in CPAN::FirstTime::init that includes |
31
|
|
|
|
|
|
|
# a prompt function; see others for examples |
32
|
|
|
|
|
|
|
# 4. add config option to documentation section in CPAN.pm |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
%keys = map { $_ => undef } |
35
|
|
|
|
|
|
|
( |
36
|
|
|
|
|
|
|
"applypatch", |
37
|
|
|
|
|
|
|
"auto_commit", |
38
|
|
|
|
|
|
|
"build_cache", |
39
|
|
|
|
|
|
|
"build_dir", |
40
|
|
|
|
|
|
|
"build_dir_reuse", |
41
|
|
|
|
|
|
|
"build_requires_install_policy", |
42
|
|
|
|
|
|
|
"bzip2", |
43
|
|
|
|
|
|
|
"cache_metadata", |
44
|
|
|
|
|
|
|
"check_sigs", |
45
|
|
|
|
|
|
|
"cleanup_after_install", |
46
|
|
|
|
|
|
|
"colorize_debug", |
47
|
|
|
|
|
|
|
"colorize_output", |
48
|
|
|
|
|
|
|
"colorize_print", |
49
|
|
|
|
|
|
|
"colorize_warn", |
50
|
|
|
|
|
|
|
"commandnumber_in_prompt", |
51
|
|
|
|
|
|
|
"commands_quote", |
52
|
|
|
|
|
|
|
"connect_to_internet_ok", |
53
|
|
|
|
|
|
|
"cpan_home", |
54
|
|
|
|
|
|
|
"curl", |
55
|
|
|
|
|
|
|
"dontload_hash", # deprecated after 1.83_68 (rev. 581) |
56
|
|
|
|
|
|
|
"dontload_list", |
57
|
|
|
|
|
|
|
"ftp", |
58
|
|
|
|
|
|
|
"ftp_passive", |
59
|
|
|
|
|
|
|
"ftp_proxy", |
60
|
|
|
|
|
|
|
"ftpstats_size", |
61
|
|
|
|
|
|
|
"ftpstats_period", |
62
|
|
|
|
|
|
|
"getcwd", |
63
|
|
|
|
|
|
|
"gpg", |
64
|
|
|
|
|
|
|
"gzip", |
65
|
|
|
|
|
|
|
"halt_on_failure", |
66
|
|
|
|
|
|
|
"histfile", |
67
|
|
|
|
|
|
|
"histsize", |
68
|
|
|
|
|
|
|
"http_proxy", |
69
|
|
|
|
|
|
|
"inactivity_timeout", |
70
|
|
|
|
|
|
|
"index_expire", |
71
|
|
|
|
|
|
|
"inhibit_startup_message", |
72
|
|
|
|
|
|
|
"keep_source_where", |
73
|
|
|
|
|
|
|
"load_module_verbosity", |
74
|
|
|
|
|
|
|
"lynx", |
75
|
|
|
|
|
|
|
"make", |
76
|
|
|
|
|
|
|
"make_arg", |
77
|
|
|
|
|
|
|
"make_install_arg", |
78
|
|
|
|
|
|
|
"make_install_make_command", |
79
|
|
|
|
|
|
|
"makepl_arg", |
80
|
|
|
|
|
|
|
"mbuild_arg", |
81
|
|
|
|
|
|
|
"mbuild_install_arg", |
82
|
|
|
|
|
|
|
"mbuild_install_build_command", |
83
|
|
|
|
|
|
|
"mbuildpl_arg", |
84
|
|
|
|
|
|
|
"ncftp", |
85
|
|
|
|
|
|
|
"ncftpget", |
86
|
|
|
|
|
|
|
"no_proxy", |
87
|
|
|
|
|
|
|
"pager", |
88
|
|
|
|
|
|
|
"password", |
89
|
|
|
|
|
|
|
"patch", |
90
|
|
|
|
|
|
|
"patches_dir", |
91
|
|
|
|
|
|
|
"perl5lib_verbosity", |
92
|
|
|
|
|
|
|
"plugin_list", |
93
|
|
|
|
|
|
|
"prefer_external_tar", |
94
|
|
|
|
|
|
|
"prefer_installer", |
95
|
|
|
|
|
|
|
"prefs_dir", |
96
|
|
|
|
|
|
|
"prerequisites_policy", |
97
|
|
|
|
|
|
|
"proxy_pass", |
98
|
|
|
|
|
|
|
"proxy_user", |
99
|
|
|
|
|
|
|
"randomize_urllist", |
100
|
|
|
|
|
|
|
"recommends_policy", |
101
|
|
|
|
|
|
|
"scan_cache", |
102
|
|
|
|
|
|
|
"shell", |
103
|
|
|
|
|
|
|
"show_unparsable_versions", |
104
|
|
|
|
|
|
|
"show_upload_date", |
105
|
|
|
|
|
|
|
"show_zero_versions", |
106
|
|
|
|
|
|
|
"suggests_policy", |
107
|
|
|
|
|
|
|
"tar", |
108
|
|
|
|
|
|
|
"tar_verbosity", |
109
|
|
|
|
|
|
|
"term_is_latin", |
110
|
|
|
|
|
|
|
"term_ornaments", |
111
|
|
|
|
|
|
|
"test_report", |
112
|
|
|
|
|
|
|
"trust_test_report_history", |
113
|
|
|
|
|
|
|
"unzip", |
114
|
|
|
|
|
|
|
"urllist", |
115
|
|
|
|
|
|
|
"use_prompt_default", |
116
|
|
|
|
|
|
|
"use_sqlite", |
117
|
|
|
|
|
|
|
"username", |
118
|
|
|
|
|
|
|
"version_timeout", |
119
|
|
|
|
|
|
|
"wait_list", |
120
|
|
|
|
|
|
|
"wget", |
121
|
|
|
|
|
|
|
"yaml_load_code", |
122
|
|
|
|
|
|
|
"yaml_module", |
123
|
|
|
|
|
|
|
); |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
my %prefssupport = map { $_ => 1 } |
126
|
|
|
|
|
|
|
( |
127
|
|
|
|
|
|
|
"build_requires_install_policy", |
128
|
|
|
|
|
|
|
"check_sigs", |
129
|
|
|
|
|
|
|
"make", |
130
|
|
|
|
|
|
|
"make_install_make_command", |
131
|
|
|
|
|
|
|
"prefer_installer", |
132
|
|
|
|
|
|
|
"test_report", |
133
|
|
|
|
|
|
|
); |
134
|
|
|
|
|
|
|
|
135
|
|
|
|
|
|
|
# returns true on successful action |
136
|
|
|
|
|
|
|
sub edit { |
137
|
0
|
|
|
0
|
0
|
0
|
my($self,@args) = @_; |
138
|
0
|
0
|
|
|
|
0
|
return unless @args; |
139
|
0
|
|
|
|
|
0
|
CPAN->debug("self[$self]args[".join(" | ",@args)."]"); |
140
|
0
|
|
|
|
|
0
|
my($o,$str,$func,$args,$key_exists); |
141
|
0
|
|
|
|
|
0
|
$o = shift @args; |
142
|
0
|
0
|
|
|
|
0
|
if($can{$o}) { |
143
|
0
|
|
|
|
|
0
|
my $success = $self->$o(args => \@args); # o conf init => sub init => sub load |
144
|
0
|
0
|
|
|
|
0
|
unless ($success) { |
145
|
0
|
|
|
|
|
0
|
die "Panic: could not configure CPAN.pm for args [@args]. Giving up."; |
146
|
|
|
|
|
|
|
} |
147
|
|
|
|
|
|
|
} else { |
148
|
0
|
0
|
|
|
|
0
|
CPAN->debug("o[$o]") if $CPAN::DEBUG; |
149
|
0
|
0
|
|
|
|
0
|
unless (exists $keys{$o}) { |
150
|
0
|
|
|
|
|
0
|
$CPAN::Frontend->mywarn("Warning: unknown configuration variable '$o'\n"); |
151
|
|
|
|
|
|
|
} |
152
|
0
|
|
|
|
|
0
|
my $changed; |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
# one day I used randomize_urllist for a boolean, so we must |
156
|
|
|
|
|
|
|
# list them explicitly --ak |
157
|
0
|
0
|
|
|
|
0
|
if (0) { |
|
|
0
|
|
|
|
|
|
158
|
0
|
|
|
|
|
0
|
} elsif ($o =~ /^(wait_list|urllist|dontload_list|plugin_list)$/) { |
159
|
|
|
|
|
|
|
|
160
|
|
|
|
|
|
|
# |
161
|
|
|
|
|
|
|
# ARRAYS |
162
|
|
|
|
|
|
|
# |
163
|
|
|
|
|
|
|
|
164
|
0
|
|
|
|
|
0
|
$func = shift @args; |
165
|
0
|
|
0
|
|
|
0
|
$func ||= ""; |
166
|
0
|
0
|
|
|
|
0
|
CPAN->debug("func[$func]args[@args]") if $CPAN::DEBUG; |
167
|
|
|
|
|
|
|
# Let's avoid eval, it's easier to comprehend without. |
168
|
0
|
0
|
|
|
|
0
|
if ($func eq "push") { |
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
169
|
0
|
|
|
|
|
0
|
push @{$CPAN::Config->{$o}}, @args; |
|
0
|
|
|
|
|
0
|
|
170
|
0
|
|
|
|
|
0
|
$changed = 1; |
171
|
|
|
|
|
|
|
} elsif ($func eq "pop") { |
172
|
0
|
|
|
|
|
0
|
pop @{$CPAN::Config->{$o}}; |
|
0
|
|
|
|
|
0
|
|
173
|
0
|
|
|
|
|
0
|
$changed = 1; |
174
|
|
|
|
|
|
|
} elsif ($func eq "shift") { |
175
|
0
|
|
|
|
|
0
|
shift @{$CPAN::Config->{$o}}; |
|
0
|
|
|
|
|
0
|
|
176
|
0
|
|
|
|
|
0
|
$changed = 1; |
177
|
|
|
|
|
|
|
} elsif ($func eq "unshift") { |
178
|
0
|
|
|
|
|
0
|
unshift @{$CPAN::Config->{$o}}, @args; |
|
0
|
|
|
|
|
0
|
|
179
|
0
|
|
|
|
|
0
|
$changed = 1; |
180
|
|
|
|
|
|
|
} elsif ($func eq "splice") { |
181
|
0
|
|
0
|
|
|
0
|
my $offset = shift @args || 0; |
182
|
0
|
|
0
|
|
|
0
|
my $length = shift @args || 0; |
183
|
0
|
|
|
|
|
0
|
splice @{$CPAN::Config->{$o}}, $offset, $length, @args; # may warn |
|
0
|
|
|
|
|
0
|
|
184
|
0
|
|
|
|
|
0
|
$changed = 1; |
185
|
|
|
|
|
|
|
} elsif ($func) { |
186
|
0
|
|
|
|
|
0
|
$CPAN::Config->{$o} = [$func, @args]; |
187
|
0
|
|
|
|
|
0
|
$changed = 1; |
188
|
|
|
|
|
|
|
} else { |
189
|
0
|
|
|
|
|
0
|
$self->prettyprint($o); |
190
|
|
|
|
|
|
|
} |
191
|
0
|
0
|
|
|
|
0
|
if ($changed) { |
192
|
0
|
0
|
|
|
|
0
|
if ($o eq "urllist") { |
|
|
0
|
|
|
|
|
|
193
|
|
|
|
|
|
|
# reset the cached values |
194
|
0
|
|
|
|
|
0
|
undef $CPAN::FTP::Thesite; |
195
|
0
|
|
|
|
|
0
|
undef $CPAN::FTP::Themethod; |
196
|
0
|
|
|
|
|
0
|
$CPAN::Index::LAST_TIME = 0; |
197
|
|
|
|
|
|
|
} elsif ($o eq "dontload_list") { |
198
|
|
|
|
|
|
|
# empty it, it will be built up again |
199
|
0
|
|
|
|
|
0
|
$CPAN::META->{dontload_hash} = {}; |
200
|
|
|
|
|
|
|
} |
201
|
|
|
|
|
|
|
} |
202
|
|
|
|
|
|
|
} elsif ($o =~ /_hash$/) { |
203
|
|
|
|
|
|
|
|
204
|
|
|
|
|
|
|
# |
205
|
|
|
|
|
|
|
# HASHES |
206
|
|
|
|
|
|
|
# |
207
|
|
|
|
|
|
|
|
208
|
0
|
0
|
0
|
|
|
0
|
if (@args==1 && $args[0] eq "") { |
|
|
0
|
|
|
|
|
|
209
|
0
|
|
|
|
|
0
|
@args = (); |
210
|
|
|
|
|
|
|
} elsif (@args % 2) { |
211
|
0
|
|
|
|
|
0
|
push @args, ""; |
212
|
|
|
|
|
|
|
} |
213
|
0
|
|
|
|
|
0
|
$CPAN::Config->{$o} = { @args }; |
214
|
0
|
|
|
|
|
0
|
$changed = 1; |
215
|
|
|
|
|
|
|
} else { |
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
# |
218
|
|
|
|
|
|
|
# SCALARS |
219
|
|
|
|
|
|
|
# |
220
|
|
|
|
|
|
|
|
221
|
0
|
0
|
|
|
|
0
|
if (defined $args[0]) { |
222
|
0
|
|
|
|
|
0
|
$CPAN::CONFIG_DIRTY = 1; |
223
|
0
|
|
|
|
|
0
|
$CPAN::Config->{$o} = $args[0]; |
224
|
0
|
|
|
|
|
0
|
$changed = 1; |
225
|
|
|
|
|
|
|
} |
226
|
|
|
|
|
|
|
$self->prettyprint($o) |
227
|
0
|
0
|
0
|
|
|
0
|
if exists $keys{$o} or defined $CPAN::Config->{$o}; |
228
|
|
|
|
|
|
|
} |
229
|
0
|
0
|
|
|
|
0
|
if ($changed) { |
230
|
0
|
0
|
|
|
|
0
|
if ($CPAN::Config->{auto_commit}) { |
231
|
0
|
|
|
|
|
0
|
$self->commit; |
232
|
|
|
|
|
|
|
} else { |
233
|
0
|
|
|
|
|
0
|
$CPAN::CONFIG_DIRTY = 1; |
234
|
0
|
|
|
|
|
0
|
$CPAN::Frontend->myprint("Please use 'o conf commit' to ". |
235
|
|
|
|
|
|
|
"make the config permanent!\n\n"); |
236
|
|
|
|
|
|
|
} |
237
|
|
|
|
|
|
|
} |
238
|
|
|
|
|
|
|
} |
239
|
|
|
|
|
|
|
} |
240
|
|
|
|
|
|
|
|
241
|
|
|
|
|
|
|
sub prettyprint { |
242
|
0
|
|
|
0
|
0
|
0
|
my($self,$k) = @_; |
243
|
0
|
|
|
|
|
0
|
my $v = $CPAN::Config->{$k}; |
244
|
0
|
0
|
|
|
|
0
|
if (ref $v) { |
|
|
0
|
|
|
|
|
|
245
|
0
|
|
|
|
|
0
|
my(@report); |
246
|
0
|
0
|
|
|
|
0
|
if (ref $v eq "ARRAY") { |
247
|
0
|
|
|
|
|
0
|
@report = map {"\t$_ \[$v->[$_]]\n"} 0..$#$v; |
|
0
|
|
|
|
|
0
|
|
248
|
|
|
|
|
|
|
} else { |
249
|
|
|
|
|
|
|
@report = map |
250
|
|
|
|
|
|
|
{ |
251
|
0
|
|
|
|
|
0
|
sprintf "\t%-18s => %s\n", |
252
|
|
|
|
|
|
|
"[$_]", |
253
|
0
|
0
|
|
|
|
0
|
defined $v->{$_} ? "[$v->{$_}]" : "undef" |
254
|
|
|
|
|
|
|
} sort keys %$v; |
255
|
|
|
|
|
|
|
} |
256
|
0
|
|
|
|
|
0
|
$CPAN::Frontend->myprint( |
257
|
|
|
|
|
|
|
join( |
258
|
|
|
|
|
|
|
"", |
259
|
|
|
|
|
|
|
sprintf( |
260
|
|
|
|
|
|
|
" %-18s\n", |
261
|
|
|
|
|
|
|
$k |
262
|
|
|
|
|
|
|
), |
263
|
|
|
|
|
|
|
@report |
264
|
|
|
|
|
|
|
) |
265
|
|
|
|
|
|
|
); |
266
|
|
|
|
|
|
|
} elsif (defined $v) { |
267
|
0
|
|
|
|
|
0
|
$CPAN::Frontend->myprint(sprintf " %-18s [%s]\n", $k, $v); |
268
|
|
|
|
|
|
|
} else { |
269
|
0
|
|
|
|
|
0
|
$CPAN::Frontend->myprint(sprintf " %-18s undef\n", $k); |
270
|
|
|
|
|
|
|
} |
271
|
|
|
|
|
|
|
} |
272
|
|
|
|
|
|
|
|
273
|
|
|
|
|
|
|
# generally, this should be called without arguments so that the currently |
274
|
|
|
|
|
|
|
# loaded config file is where changes are committed. |
275
|
|
|
|
|
|
|
sub commit { |
276
|
0
|
|
|
0
|
0
|
0
|
my($self,@args) = @_; |
277
|
0
|
0
|
|
|
|
0
|
CPAN->debug("args[@args]") if $CPAN::DEBUG; |
278
|
0
|
0
|
|
|
|
0
|
if ($CPAN::RUN_DEGRADED) { |
279
|
0
|
|
|
|
|
0
|
$CPAN::Frontend->mydie( |
280
|
|
|
|
|
|
|
"'o conf commit' disabled in ". |
281
|
|
|
|
|
|
|
"degraded mode. Maybe try\n". |
282
|
|
|
|
|
|
|
" !undef \$CPAN::RUN_DEGRADED\n" |
283
|
|
|
|
|
|
|
); |
284
|
|
|
|
|
|
|
} |
285
|
0
|
|
|
|
|
0
|
my ($configpm, $must_reload); |
286
|
|
|
|
|
|
|
|
287
|
|
|
|
|
|
|
# XXX does anything do this? can it be simplified? -- dagolden, 2011-01-19 |
288
|
0
|
0
|
|
|
|
0
|
if (@args) { |
289
|
0
|
0
|
|
|
|
0
|
if ($args[0] eq "args") { |
290
|
|
|
|
|
|
|
# we have not signed that contract |
291
|
|
|
|
|
|
|
} else { |
292
|
0
|
|
|
|
|
0
|
$configpm = $args[0]; |
293
|
|
|
|
|
|
|
} |
294
|
|
|
|
|
|
|
} |
295
|
|
|
|
|
|
|
|
296
|
|
|
|
|
|
|
# use provided name or the current config or create a new MyConfig |
297
|
0
|
|
0
|
|
|
0
|
$configpm ||= require_myconfig_or_config() || make_new_config(); |
|
|
|
0
|
|
|
|
|
298
|
|
|
|
|
|
|
|
299
|
|
|
|
|
|
|
# commit to MyConfig if we can't write to Config |
300
|
0
|
0
|
0
|
|
|
0
|
if ( ! -w $configpm && $configpm =~ m{CPAN/Config\.pm} ) { |
301
|
0
|
|
|
|
|
0
|
my $myconfig = _new_config_name(); |
302
|
0
|
|
|
|
|
0
|
$CPAN::Frontend->mywarn( |
303
|
|
|
|
|
|
|
"Your $configpm file\n". |
304
|
|
|
|
|
|
|
"is not writable. I will attempt to write your configuration to\n" . |
305
|
|
|
|
|
|
|
"$myconfig instead.\n\n" |
306
|
|
|
|
|
|
|
); |
307
|
0
|
|
|
|
|
0
|
$configpm = make_new_config(); |
308
|
0
|
|
|
|
|
0
|
$must_reload++; # so it gets loaded as $INC{'CPAN/MyConfig.pm'} |
309
|
|
|
|
|
|
|
} |
310
|
|
|
|
|
|
|
|
311
|
|
|
|
|
|
|
# XXX why not just "-w $configpm"? -- dagolden, 2011-01-19 |
312
|
0
|
|
|
|
|
0
|
my($mode); |
313
|
0
|
0
|
|
|
|
0
|
if (-f $configpm) { |
314
|
0
|
|
|
|
|
0
|
$mode = (stat $configpm)[2]; |
315
|
0
|
0
|
0
|
|
|
0
|
if ($mode && ! -w _) { |
316
|
0
|
|
|
|
|
0
|
_die_cant_write_config($configpm); |
317
|
|
|
|
|
|
|
} |
318
|
|
|
|
|
|
|
} |
319
|
|
|
|
|
|
|
|
320
|
0
|
|
|
|
|
0
|
$self->_write_config_file($configpm); |
321
|
0
|
0
|
|
|
|
0
|
require_myconfig_or_config() if $must_reload; |
322
|
|
|
|
|
|
|
|
323
|
|
|
|
|
|
|
#$mode = 0444 | ( $mode & 0111 ? 0111 : 0 ); |
324
|
|
|
|
|
|
|
#chmod $mode, $configpm; |
325
|
|
|
|
|
|
|
###why was that so? $self->defaults; |
326
|
0
|
|
|
|
|
0
|
$CPAN::Frontend->myprint("commit: wrote '$configpm'\n"); |
327
|
0
|
|
|
|
|
0
|
$CPAN::CONFIG_DIRTY = 0; |
328
|
0
|
|
|
|
|
0
|
1; |
329
|
|
|
|
|
|
|
} |
330
|
|
|
|
|
|
|
|
331
|
|
|
|
|
|
|
sub _write_config_file { |
332
|
0
|
|
|
0
|
|
0
|
my ($self, $configpm) = @_; |
333
|
0
|
|
|
|
|
0
|
my $msg; |
334
|
0
|
0
|
|
|
|
0
|
$msg = <
|
335
|
|
|
|
|
|
|
|
336
|
|
|
|
|
|
|
# This is CPAN.pm's systemwide configuration file. This file provides |
337
|
|
|
|
|
|
|
# defaults for users, and the values can be changed in a per-user |
338
|
|
|
|
|
|
|
# configuration file. |
339
|
|
|
|
|
|
|
|
340
|
|
|
|
|
|
|
EOF |
341
|
0
|
|
0
|
|
|
0
|
$msg ||= "\n"; |
342
|
0
|
|
|
|
|
0
|
my($fh) = FileHandle->new; |
343
|
0
|
0
|
|
|
|
0
|
rename $configpm, "$configpm~" if -f $configpm; |
344
|
0
|
0
|
|
|
|
0
|
open $fh, ">$configpm" or |
345
|
|
|
|
|
|
|
$CPAN::Frontend->mydie("Couldn't open >$configpm: $!"); |
346
|
0
|
|
|
|
|
0
|
$fh->print(qq[$msg\$CPAN::Config = \{\n]); |
347
|
0
|
|
|
|
|
0
|
foreach (sort keys %$CPAN::Config) { |
348
|
0
|
0
|
|
|
|
0
|
unless (exists $keys{$_}) { |
349
|
|
|
|
|
|
|
# do not drop them: forward compatibility! |
350
|
0
|
|
|
|
|
0
|
$CPAN::Frontend->mywarn("Unknown config variable '$_'\n"); |
351
|
0
|
|
|
|
|
0
|
next; |
352
|
|
|
|
|
|
|
} |
353
|
|
|
|
|
|
|
$fh->print( |
354
|
|
|
|
|
|
|
" '$_' => ", |
355
|
0
|
|
|
|
|
0
|
$self->neatvalue($CPAN::Config->{$_}), |
356
|
|
|
|
|
|
|
",\n" |
357
|
|
|
|
|
|
|
); |
358
|
|
|
|
|
|
|
} |
359
|
0
|
|
|
|
|
0
|
$fh->print("};\n1;\n__END__\n"); |
360
|
0
|
|
|
|
|
0
|
close $fh; |
361
|
|
|
|
|
|
|
|
362
|
0
|
|
|
|
|
0
|
return; |
363
|
|
|
|
|
|
|
} |
364
|
|
|
|
|
|
|
|
365
|
|
|
|
|
|
|
|
366
|
|
|
|
|
|
|
# stolen from MakeMaker; not taking the original because it is buggy; |
367
|
|
|
|
|
|
|
# bugreport will have to say: keys of hashes remain unquoted and can |
368
|
|
|
|
|
|
|
# produce syntax errors |
369
|
|
|
|
|
|
|
sub neatvalue { |
370
|
7
|
|
|
7
|
0
|
5094
|
my($self, $v) = @_; |
371
|
7
|
50
|
|
|
|
29
|
return "undef" unless defined $v; |
372
|
7
|
|
|
|
|
21
|
my($t) = ref $v; |
373
|
7
|
100
|
|
|
|
23
|
unless ($t) { |
374
|
4
|
|
|
|
|
18
|
$v =~ s/\\/\\\\/g; |
375
|
4
|
|
|
|
|
28
|
return "q[$v]"; |
376
|
|
|
|
|
|
|
} |
377
|
3
|
100
|
|
|
|
15
|
if ($t eq 'ARRAY') { |
378
|
1
|
|
|
|
|
3
|
my(@m, @neat); |
379
|
1
|
|
|
|
|
8
|
push @m, "["; |
380
|
1
|
|
|
|
|
6
|
foreach my $elem (@$v) { |
381
|
1
|
|
|
|
|
6
|
push @neat, "q[$elem]"; |
382
|
|
|
|
|
|
|
} |
383
|
1
|
|
|
|
|
7
|
push @m, join ", ", @neat; |
384
|
1
|
|
|
|
|
7
|
push @m, "]"; |
385
|
1
|
|
|
|
|
8
|
return join "", @m; |
386
|
|
|
|
|
|
|
} |
387
|
2
|
50
|
|
|
|
10
|
return "$v" unless $t eq 'HASH'; |
388
|
2
|
|
|
|
|
7
|
my @m; |
389
|
2
|
|
|
|
|
13
|
foreach my $key (sort keys %$v) { |
390
|
2
|
|
|
|
|
7
|
my $val = $v->{$key}; |
391
|
2
|
|
|
|
|
18
|
push(@m,"q[$key]=>".$self->neatvalue($val)) ; |
392
|
|
|
|
|
|
|
} |
393
|
2
|
|
|
|
|
17
|
return "{ ".join(', ',@m)." }"; |
394
|
|
|
|
|
|
|
} |
395
|
|
|
|
|
|
|
|
396
|
|
|
|
|
|
|
sub defaults { |
397
|
0
|
|
|
0
|
0
|
0
|
my($self) = @_; |
398
|
0
|
0
|
|
|
|
0
|
if ($CPAN::RUN_DEGRADED) { |
399
|
0
|
|
|
|
|
0
|
$CPAN::Frontend->mydie( |
400
|
|
|
|
|
|
|
"'o conf defaults' disabled in ". |
401
|
|
|
|
|
|
|
"degraded mode. Maybe try\n". |
402
|
|
|
|
|
|
|
" !undef \$CPAN::RUN_DEGRADED\n" |
403
|
|
|
|
|
|
|
); |
404
|
|
|
|
|
|
|
} |
405
|
0
|
|
|
|
|
0
|
my $done; |
406
|
0
|
|
|
|
|
0
|
for my $config (qw(CPAN/MyConfig.pm CPAN/Config.pm)) { |
407
|
0
|
0
|
|
|
|
0
|
if ($INC{$config}) { |
408
|
0
|
0
|
|
|
|
0
|
CPAN->debug("INC{'$config'}[$INC{$config}]") if $CPAN::DEBUG; |
409
|
0
|
|
|
|
|
0
|
CPAN::Shell->_reload_this($config,{reloforce => 1}); |
410
|
0
|
|
|
|
|
0
|
$CPAN::Frontend->myprint("'$INC{$config}' reread\n"); |
411
|
0
|
|
|
|
|
0
|
last; |
412
|
|
|
|
|
|
|
} |
413
|
|
|
|
|
|
|
} |
414
|
0
|
|
|
|
|
0
|
$CPAN::CONFIG_DIRTY = 0; |
415
|
0
|
|
|
|
|
0
|
1; |
416
|
|
|
|
|
|
|
} |
417
|
|
|
|
|
|
|
|
418
|
|
|
|
|
|
|
=head2 C<< CLASS->safe_quote ITEM >> |
419
|
|
|
|
|
|
|
|
420
|
|
|
|
|
|
|
Quotes an item to become safe against spaces |
421
|
|
|
|
|
|
|
in shell interpolation. An item is enclosed |
422
|
|
|
|
|
|
|
in double quotes if: |
423
|
|
|
|
|
|
|
|
424
|
|
|
|
|
|
|
- the item contains spaces in the middle |
425
|
|
|
|
|
|
|
- the item does not start with a quote |
426
|
|
|
|
|
|
|
|
427
|
|
|
|
|
|
|
This happens to avoid shell interpolation |
428
|
|
|
|
|
|
|
problems when whitespace is present in |
429
|
|
|
|
|
|
|
directory names. |
430
|
|
|
|
|
|
|
|
431
|
|
|
|
|
|
|
This method uses C to determine |
432
|
|
|
|
|
|
|
the correct quote. If C is |
433
|
|
|
|
|
|
|
a space, no quoting will take place. |
434
|
|
|
|
|
|
|
|
435
|
|
|
|
|
|
|
|
436
|
|
|
|
|
|
|
if it starts and ends with the same quote character: leave it as it is |
437
|
|
|
|
|
|
|
|
438
|
|
|
|
|
|
|
if it contains no whitespace: leave it as it is |
439
|
|
|
|
|
|
|
|
440
|
|
|
|
|
|
|
if it contains whitespace, then |
441
|
|
|
|
|
|
|
|
442
|
|
|
|
|
|
|
if it contains quotes: better leave it as it is |
443
|
|
|
|
|
|
|
|
444
|
|
|
|
|
|
|
else: quote it with the correct quote type for the box we're on |
445
|
|
|
|
|
|
|
|
446
|
|
|
|
|
|
|
=cut |
447
|
|
|
|
|
|
|
|
448
|
|
|
|
|
|
|
{ |
449
|
|
|
|
|
|
|
# Instead of patching the guess, set commands_quote |
450
|
|
|
|
|
|
|
# to the right value |
451
|
|
|
|
|
|
|
my ($quotes,$use_quote) |
452
|
|
|
|
|
|
|
= $^O eq 'MSWin32' |
453
|
|
|
|
|
|
|
? ('"', '"') |
454
|
|
|
|
|
|
|
: (q{"'}, "'") |
455
|
|
|
|
|
|
|
; |
456
|
|
|
|
|
|
|
|
457
|
|
|
|
|
|
|
sub safe_quote { |
458
|
2
|
|
|
2
|
1
|
7
|
my ($self, $command) = @_; |
459
|
|
|
|
|
|
|
# Set up quote/default quote |
460
|
2
|
|
33
|
|
|
16
|
my $quote = $CPAN::Config->{commands_quote} || $quotes; |
461
|
|
|
|
|
|
|
|
462
|
2
|
50
|
33
|
|
|
15
|
if ($quote ne ' ' |
|
|
|
33
|
|
|
|
|
|
|
|
33
|
|
|
|
|
463
|
|
|
|
|
|
|
and defined($command ) |
464
|
|
|
|
|
|
|
and $command =~ /\s/ |
465
|
|
|
|
|
|
|
and $command !~ /[$quote]/) { |
466
|
0
|
|
|
|
|
0
|
return qq<$use_quote$command$use_quote> |
467
|
|
|
|
|
|
|
} |
468
|
2
|
|
|
|
|
5
|
return $command; |
469
|
|
|
|
|
|
|
} |
470
|
|
|
|
|
|
|
} |
471
|
|
|
|
|
|
|
|
472
|
|
|
|
|
|
|
sub init { |
473
|
0
|
|
|
0
|
0
|
0
|
my($self,@args) = @_; |
474
|
0
|
|
|
|
|
0
|
CPAN->debug("self[$self]args[".join(",",@args)."]"); |
475
|
0
|
|
|
|
|
0
|
$self->load(do_init => 1, @args); |
476
|
0
|
|
|
|
|
0
|
1; |
477
|
|
|
|
|
|
|
} |
478
|
|
|
|
|
|
|
|
479
|
|
|
|
|
|
|
# Loads CPAN::MyConfig or fall-back to CPAN::Config. Will not reload a file |
480
|
|
|
|
|
|
|
# if already loaded. Returns the path to the file %INC or else the empty string |
481
|
|
|
|
|
|
|
# |
482
|
|
|
|
|
|
|
# Note -- if CPAN::Config were loaded and CPAN::MyConfig subsequently |
483
|
|
|
|
|
|
|
# created, calling this again will leave *both* in %INC |
484
|
|
|
|
|
|
|
|
485
|
|
|
|
|
|
|
sub require_myconfig_or_config () { |
486
|
7
|
50
|
33
|
7
|
0
|
46
|
if ( $INC{"CPAN/MyConfig.pm"} || _try_loading("CPAN::MyConfig", cpan_home())) { |
|
|
0
|
0
|
|
|
|
|
487
|
7
|
|
|
|
|
30
|
return $INC{"CPAN/MyConfig.pm"}; |
488
|
|
|
|
|
|
|
} |
489
|
|
|
|
|
|
|
elsif ( $INC{"CPAN/Config.pm"} || _try_loading("CPAN::Config") ) { |
490
|
0
|
|
|
|
|
0
|
return $INC{"CPAN/Config.pm"}; |
491
|
|
|
|
|
|
|
} |
492
|
|
|
|
|
|
|
else { |
493
|
0
|
|
|
|
|
0
|
return q{}; |
494
|
|
|
|
|
|
|
} |
495
|
|
|
|
|
|
|
} |
496
|
|
|
|
|
|
|
|
497
|
|
|
|
|
|
|
# Load a module, but ignore "can't locate..." errors |
498
|
|
|
|
|
|
|
# Optionally take a list of directories to add to @INC for the load |
499
|
|
|
|
|
|
|
sub _try_loading { |
500
|
0
|
|
|
0
|
|
0
|
my ($module, @dirs) = @_; |
501
|
0
|
|
|
|
|
0
|
(my $file = $module) =~ s{::}{/}g; |
502
|
0
|
|
|
|
|
0
|
$file .= ".pm"; |
503
|
|
|
|
|
|
|
|
504
|
0
|
|
|
|
|
0
|
local @INC = @INC; |
505
|
0
|
|
|
|
|
0
|
for my $dir ( @dirs ) { |
506
|
0
|
0
|
|
|
|
0
|
if ( -f File::Spec->catfile($dir, $file) ) { |
507
|
0
|
|
|
|
|
0
|
unshift @INC, $dir; |
508
|
0
|
|
|
|
|
0
|
last; |
509
|
|
|
|
|
|
|
} |
510
|
|
|
|
|
|
|
} |
511
|
|
|
|
|
|
|
|
512
|
0
|
|
|
|
|
0
|
eval { require $file }; |
|
0
|
|
|
|
|
0
|
|
513
|
0
|
|
|
|
|
0
|
my $err_myconfig = $@; |
514
|
0
|
0
|
0
|
|
|
0
|
if ($err_myconfig and $err_myconfig !~ m#locate \Q$file\E#) { |
515
|
0
|
|
|
|
|
0
|
die "Error while requiring ${module}:\n$err_myconfig"; |
516
|
|
|
|
|
|
|
} |
517
|
0
|
|
|
|
|
0
|
return $INC{$file}; |
518
|
|
|
|
|
|
|
} |
519
|
|
|
|
|
|
|
|
520
|
|
|
|
|
|
|
# prioritized list of possible places for finding "CPAN/MyConfig.pm" |
521
|
|
|
|
|
|
|
sub cpan_home_dir_candidates { |
522
|
0
|
|
|
0
|
0
|
0
|
my @dirs; |
523
|
0
|
|
|
|
|
0
|
my $old_v = $CPAN::Config->{load_module_verbosity}; |
524
|
0
|
|
|
|
|
0
|
$CPAN::Config->{load_module_verbosity} = q[none]; |
525
|
0
|
0
|
|
|
|
0
|
if ($CPAN::META->has_usable('File::HomeDir')) { |
526
|
0
|
0
|
|
|
|
0
|
if ($^O ne 'darwin') { |
527
|
0
|
|
|
|
|
0
|
push @dirs, File::HomeDir->my_data; |
528
|
|
|
|
|
|
|
# my_data is ~/Library/Application Support on darwin, |
529
|
|
|
|
|
|
|
# which causes issues in the toolchain. |
530
|
|
|
|
|
|
|
} |
531
|
0
|
|
|
|
|
0
|
push @dirs, File::HomeDir->my_home; |
532
|
|
|
|
|
|
|
} |
533
|
|
|
|
|
|
|
# Windows might not have HOME, so check it first |
534
|
0
|
0
|
|
|
|
0
|
push @dirs, $ENV{HOME} if $ENV{HOME}; |
535
|
|
|
|
|
|
|
# Windows might have these instead |
536
|
|
|
|
|
|
|
push( @dirs, File::Spec->catpath($ENV{HOMEDRIVE}, $ENV{HOMEPATH}, '') ) |
537
|
0
|
0
|
0
|
|
|
0
|
if $ENV{HOMEDRIVE} && $ENV{HOMEPATH}; |
538
|
0
|
0
|
|
|
|
0
|
push @dirs, $ENV{USERPROFILE} if $ENV{USERPROFILE}; |
539
|
|
|
|
|
|
|
|
540
|
0
|
|
|
|
|
0
|
$CPAN::Config->{load_module_verbosity} = $old_v; |
541
|
0
|
0
|
|
|
|
0
|
my $dotcpan = $^O eq 'VMS' ? '_cpan' : '.cpan'; |
542
|
0
|
|
|
|
|
0
|
@dirs = map { File::Spec->catdir($_, $dotcpan) } grep { defined } @dirs; |
|
0
|
|
|
|
|
0
|
|
|
0
|
|
|
|
|
0
|
|
543
|
0
|
0
|
|
|
|
0
|
return wantarray ? @dirs : $dirs[0]; |
544
|
|
|
|
|
|
|
} |
545
|
|
|
|
|
|
|
|
546
|
|
|
|
|
|
|
sub load { |
547
|
7
|
|
|
7
|
0
|
48
|
my($self, %args) = @_; |
548
|
7
|
|
|
|
|
25
|
$CPAN::Be_Silent+=0; # protect against 'used only once' |
549
|
7
|
50
|
|
|
|
37
|
$CPAN::Be_Silent++ if $args{be_silent}; # do not use; planned to be removed in 2011 |
550
|
7
|
|
50
|
|
|
57
|
my $do_init = delete $args{do_init} || 0; |
551
|
7
|
|
|
|
|
18
|
my $make_myconfig = delete $args{make_myconfig}; |
552
|
7
|
100
|
|
|
|
33
|
$loading = 0 unless defined $loading; |
553
|
|
|
|
|
|
|
|
554
|
7
|
|
|
|
|
47
|
my $configpm = require_myconfig_or_config; |
555
|
7
|
|
|
|
|
43
|
my @miss = $self->missing_config_data; |
556
|
7
|
50
|
|
|
|
33
|
CPAN->debug("do_init[$do_init]loading[$loading]miss[@miss]") if $CPAN::DEBUG; |
557
|
7
|
50
|
33
|
|
|
71
|
return unless $do_init || @miss; |
558
|
|
|
|
|
|
|
|
559
|
|
|
|
|
|
|
# I'm not how we'd ever wind up in a recursive loop, but I'm leaving |
560
|
|
|
|
|
|
|
# this here for safety's sake -- dagolden, 2011-01-19 |
561
|
0
|
0
|
|
|
|
0
|
return if $loading; |
562
|
0
|
|
0
|
|
|
0
|
local $loading = ($loading||0) + 1; |
563
|
|
|
|
|
|
|
|
564
|
|
|
|
|
|
|
# Warn if we have a config file, but things were found missing |
565
|
0
|
0
|
0
|
|
|
0
|
if ($configpm && @miss && !$do_init) { |
|
|
|
0
|
|
|
|
|
566
|
0
|
0
|
0
|
|
|
0
|
if ($make_myconfig || ( ! -w $configpm && $configpm =~ m{CPAN/Config\.pm})) { |
|
|
|
0
|
|
|
|
|
567
|
0
|
|
|
|
|
0
|
$configpm = make_new_config(); |
568
|
0
|
|
|
|
|
0
|
$CPAN::Frontend->myprint(<
|
569
|
|
|
|
|
|
|
The system CPAN configuration file has provided some default values, |
570
|
|
|
|
|
|
|
but you need to complete the configuration dialog for CPAN.pm. |
571
|
|
|
|
|
|
|
Configuration will be written to |
572
|
|
|
|
|
|
|
<<$configpm>> |
573
|
|
|
|
|
|
|
END |
574
|
|
|
|
|
|
|
} |
575
|
|
|
|
|
|
|
else { |
576
|
0
|
|
|
|
|
0
|
$CPAN::Frontend->myprint(<
|
577
|
|
|
|
|
|
|
Sorry, we have to rerun the configuration dialog for CPAN.pm due to |
578
|
|
|
|
|
|
|
some missing parameters. Configuration will be written to |
579
|
|
|
|
|
|
|
<<$configpm>> |
580
|
|
|
|
|
|
|
|
581
|
|
|
|
|
|
|
END |
582
|
|
|
|
|
|
|
} |
583
|
|
|
|
|
|
|
} |
584
|
|
|
|
|
|
|
|
585
|
0
|
|
|
|
|
0
|
require CPAN::FirstTime; |
586
|
0
|
|
0
|
|
|
0
|
return CPAN::FirstTime::init($configpm || make_new_config(), %args); |
587
|
|
|
|
|
|
|
} |
588
|
|
|
|
|
|
|
|
589
|
|
|
|
|
|
|
# Creates a new, empty config file at the preferred location |
590
|
|
|
|
|
|
|
# Any existing will be renamed with a ".bak" suffix if possible |
591
|
|
|
|
|
|
|
# If the file cannot be created, an exception is thrown |
592
|
|
|
|
|
|
|
sub make_new_config { |
593
|
0
|
|
|
0
|
0
|
0
|
my $configpm = _new_config_name(); |
594
|
0
|
|
|
|
|
0
|
my $configpmdir = File::Basename::dirname( $configpm ); |
595
|
0
|
0
|
|
|
|
0
|
File::Path::mkpath($configpmdir) unless -d $configpmdir; |
596
|
|
|
|
|
|
|
|
597
|
0
|
0
|
|
|
|
0
|
if ( -w $configpmdir ) { |
598
|
|
|
|
|
|
|
#_#_# following code dumped core on me with 5.003_11, a.k. |
599
|
0
|
0
|
|
|
|
0
|
if( -f $configpm ) { |
600
|
0
|
|
|
|
|
0
|
my $configpm_bak = "$configpm.bak"; |
601
|
0
|
0
|
|
|
|
0
|
unlink $configpm_bak if -f $configpm_bak; |
602
|
0
|
0
|
|
|
|
0
|
if( rename $configpm, $configpm_bak ) { |
603
|
0
|
|
|
|
|
0
|
$CPAN::Frontend->mywarn(<
|
604
|
|
|
|
|
|
|
Old configuration file $configpm |
605
|
|
|
|
|
|
|
moved to $configpm_bak |
606
|
|
|
|
|
|
|
END |
607
|
|
|
|
|
|
|
} |
608
|
|
|
|
|
|
|
} |
609
|
0
|
|
|
|
|
0
|
my $fh = FileHandle->new; |
610
|
0
|
0
|
|
|
|
0
|
if ($fh->open(">$configpm")) { |
611
|
0
|
|
|
|
|
0
|
$fh->print("1;\n"); |
612
|
0
|
|
|
|
|
0
|
return $configpm; |
613
|
|
|
|
|
|
|
} |
614
|
|
|
|
|
|
|
} |
615
|
0
|
|
|
|
|
0
|
_die_cant_write_config($configpm); |
616
|
|
|
|
|
|
|
} |
617
|
|
|
|
|
|
|
|
618
|
|
|
|
|
|
|
sub _die_cant_write_config { |
619
|
0
|
|
|
0
|
|
0
|
my ($configpm) = @_; |
620
|
0
|
|
|
|
|
0
|
$CPAN::Frontend->mydie(<<"END"); |
621
|
|
|
|
|
|
|
WARNING: CPAN.pm is unable to write a configuration file. You |
622
|
|
|
|
|
|
|
must be able to create and write to '$configpm'. |
623
|
|
|
|
|
|
|
|
624
|
|
|
|
|
|
|
Aborting configuration. |
625
|
|
|
|
|
|
|
END |
626
|
|
|
|
|
|
|
|
627
|
|
|
|
|
|
|
} |
628
|
|
|
|
|
|
|
|
629
|
|
|
|
|
|
|
# From candidate directories, we would like (in descending preference order): |
630
|
|
|
|
|
|
|
# * the one that contains a MyConfig file |
631
|
|
|
|
|
|
|
# * one that exists (even without MyConfig) |
632
|
|
|
|
|
|
|
# * the first one on the list |
633
|
|
|
|
|
|
|
sub cpan_home { |
634
|
0
|
|
|
0
|
0
|
0
|
my @dirs = cpan_home_dir_candidates(); |
635
|
0
|
|
|
|
|
0
|
for my $d (@dirs) { |
636
|
0
|
0
|
|
|
|
0
|
return $d if -f "$d/CPAN/MyConfig.pm"; |
637
|
|
|
|
|
|
|
} |
638
|
0
|
|
|
|
|
0
|
for my $d (@dirs) { |
639
|
0
|
0
|
|
|
|
0
|
return $d if -d $d; |
640
|
|
|
|
|
|
|
} |
641
|
0
|
|
|
|
|
0
|
return $dirs[0]; |
642
|
|
|
|
|
|
|
} |
643
|
|
|
|
|
|
|
|
644
|
|
|
|
|
|
|
sub _new_config_name { |
645
|
0
|
|
|
0
|
|
0
|
return File::Spec->catfile(cpan_home(), 'CPAN', 'MyConfig.pm'); |
646
|
|
|
|
|
|
|
} |
647
|
|
|
|
|
|
|
|
648
|
|
|
|
|
|
|
# returns mandatory but missing entries in the Config |
649
|
|
|
|
|
|
|
sub missing_config_data { |
650
|
7
|
|
|
7
|
0
|
21
|
my(@miss); |
651
|
7
|
50
|
|
|
|
57
|
for ( |
652
|
|
|
|
|
|
|
"auto_commit", |
653
|
|
|
|
|
|
|
"build_cache", |
654
|
|
|
|
|
|
|
"build_dir", |
655
|
|
|
|
|
|
|
"cache_metadata", |
656
|
|
|
|
|
|
|
"cpan_home", |
657
|
|
|
|
|
|
|
"ftp_proxy", |
658
|
|
|
|
|
|
|
#"gzip", |
659
|
|
|
|
|
|
|
"http_proxy", |
660
|
|
|
|
|
|
|
"index_expire", |
661
|
|
|
|
|
|
|
#"inhibit_startup_message", |
662
|
|
|
|
|
|
|
"keep_source_where", |
663
|
|
|
|
|
|
|
#"make", |
664
|
|
|
|
|
|
|
"make_arg", |
665
|
|
|
|
|
|
|
"make_install_arg", |
666
|
|
|
|
|
|
|
"makepl_arg", |
667
|
|
|
|
|
|
|
"mbuild_arg", |
668
|
|
|
|
|
|
|
"mbuild_install_arg", |
669
|
|
|
|
|
|
|
($^O eq "MSWin32" ? "" : "mbuild_install_build_command"), |
670
|
|
|
|
|
|
|
"mbuildpl_arg", |
671
|
|
|
|
|
|
|
"no_proxy", |
672
|
|
|
|
|
|
|
#"pager", |
673
|
|
|
|
|
|
|
"prerequisites_policy", |
674
|
|
|
|
|
|
|
"scan_cache", |
675
|
|
|
|
|
|
|
#"tar", |
676
|
|
|
|
|
|
|
#"unzip", |
677
|
|
|
|
|
|
|
"urllist", |
678
|
|
|
|
|
|
|
) { |
679
|
140
|
50
|
|
|
|
460
|
next unless exists $keys{$_}; |
680
|
140
|
50
|
|
|
|
335
|
push @miss, $_ unless defined $CPAN::Config->{$_}; |
681
|
|
|
|
|
|
|
} |
682
|
7
|
|
|
|
|
85
|
return @miss; |
683
|
|
|
|
|
|
|
} |
684
|
|
|
|
|
|
|
|
685
|
|
|
|
|
|
|
sub help { |
686
|
0
|
|
|
0
|
0
|
|
$CPAN::Frontend->myprint(q[ |
687
|
|
|
|
|
|
|
Known options: |
688
|
|
|
|
|
|
|
commit commit session changes to disk |
689
|
|
|
|
|
|
|
defaults reload default config values from disk |
690
|
|
|
|
|
|
|
help this help |
691
|
|
|
|
|
|
|
init enter a dialog to set all or a set of parameters |
692
|
|
|
|
|
|
|
|
693
|
|
|
|
|
|
|
Edit key values as in the following (the "o" is a literal letter o): |
694
|
|
|
|
|
|
|
o conf build_cache 15 |
695
|
|
|
|
|
|
|
o conf build_dir "/foo/bar" |
696
|
|
|
|
|
|
|
o conf urllist shift |
697
|
|
|
|
|
|
|
o conf urllist unshift ftp://ftp.foo.bar/ |
698
|
|
|
|
|
|
|
o conf inhibit_startup_message 1 |
699
|
|
|
|
|
|
|
|
700
|
|
|
|
|
|
|
]); |
701
|
0
|
|
|
|
|
|
1; #don't reprint CPAN::Config |
702
|
|
|
|
|
|
|
} |
703
|
|
|
|
|
|
|
|
704
|
|
|
|
|
|
|
sub cpl { |
705
|
0
|
|
|
0
|
0
|
|
my($word,$line,$pos) = @_; |
706
|
0
|
|
0
|
|
|
|
$word ||= ""; |
707
|
0
|
0
|
|
|
|
|
CPAN->debug("word[$word] line[$line] pos[$pos]") if $CPAN::DEBUG; |
708
|
0
|
|
|
|
|
|
my(@words) = split " ", substr($line,0,$pos+1); |
709
|
0
|
0
|
0
|
|
|
|
if ( |
|
|
0
|
0
|
|
|
|
|
|
|
0
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
710
|
|
|
|
|
|
|
defined($words[2]) |
711
|
|
|
|
|
|
|
and |
712
|
|
|
|
|
|
|
$words[2] =~ /list$/ |
713
|
|
|
|
|
|
|
and |
714
|
|
|
|
|
|
|
( |
715
|
|
|
|
|
|
|
@words == 3 |
716
|
|
|
|
|
|
|
|| |
717
|
|
|
|
|
|
|
@words == 4 && length($word) |
718
|
|
|
|
|
|
|
) |
719
|
|
|
|
|
|
|
) { |
720
|
0
|
|
|
|
|
|
return grep /^\Q$word\E/, qw(splice shift unshift pop push); |
721
|
|
|
|
|
|
|
} elsif (defined($words[2]) |
722
|
|
|
|
|
|
|
and |
723
|
|
|
|
|
|
|
$words[2] eq "init" |
724
|
|
|
|
|
|
|
and |
725
|
|
|
|
|
|
|
( |
726
|
|
|
|
|
|
|
@words == 3 |
727
|
|
|
|
|
|
|
|| |
728
|
|
|
|
|
|
|
@words >= 4 && length($word) |
729
|
|
|
|
|
|
|
)) { |
730
|
0
|
|
|
|
|
|
return sort grep /^\Q$word\E/, keys %keys; |
731
|
|
|
|
|
|
|
} elsif (@words >= 4) { |
732
|
0
|
|
|
|
|
|
return (); |
733
|
|
|
|
|
|
|
} |
734
|
0
|
|
|
|
|
|
my %seen; |
735
|
0
|
|
|
|
|
|
my(@o_conf) = sort grep { !$seen{$_}++ } |
|
0
|
|
|
|
|
|
|
736
|
|
|
|
|
|
|
keys %can, |
737
|
|
|
|
|
|
|
keys %$CPAN::Config, |
738
|
|
|
|
|
|
|
keys %keys; |
739
|
0
|
|
|
|
|
|
return grep /^\Q$word\E/, @o_conf; |
740
|
|
|
|
|
|
|
} |
741
|
|
|
|
|
|
|
|
742
|
|
|
|
|
|
|
sub prefs_lookup { |
743
|
0
|
|
|
0
|
0
|
|
my($self,$distro,$what) = @_; |
744
|
|
|
|
|
|
|
|
745
|
0
|
0
|
|
|
|
|
if ($prefssupport{$what}) { |
746
|
|
|
|
|
|
|
return $CPAN::Config->{$what} unless |
747
|
|
|
|
|
|
|
$distro |
748
|
|
|
|
|
|
|
and $distro->prefs |
749
|
|
|
|
|
|
|
and $distro->prefs->{cpanconfig} |
750
|
0
|
0
|
0
|
|
|
|
and defined $distro->prefs->{cpanconfig}{$what}; |
|
|
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
751
|
0
|
|
|
|
|
|
return $distro->prefs->{cpanconfig}{$what}; |
752
|
|
|
|
|
|
|
} else { |
753
|
0
|
|
|
|
|
|
$CPAN::Frontend->mywarn("Warning: $what not yet officially ". |
754
|
|
|
|
|
|
|
"supported for distroprefs, doing a normal lookup"); |
755
|
0
|
|
|
|
|
|
return $CPAN::Config->{$what}; |
756
|
|
|
|
|
|
|
} |
757
|
|
|
|
|
|
|
} |
758
|
|
|
|
|
|
|
|
759
|
|
|
|
|
|
|
|
760
|
|
|
|
|
|
|
{ |
761
|
|
|
|
|
|
|
package |
762
|
|
|
|
|
|
|
CPAN::Config; ####::###### #hide from indexer |
763
|
|
|
|
|
|
|
# note: J. Nick Koston wrote me that they are using |
764
|
|
|
|
|
|
|
# CPAN::Config->commit although undocumented. I suggested |
765
|
|
|
|
|
|
|
# CPAN::Shell->o("conf","commit") even when ugly it is at least |
766
|
|
|
|
|
|
|
# documented |
767
|
|
|
|
|
|
|
|
768
|
|
|
|
|
|
|
# that's why I added the CPAN::Config class with autoload and |
769
|
|
|
|
|
|
|
# deprecated warning |
770
|
|
|
|
|
|
|
|
771
|
13
|
|
|
13
|
|
153
|
use strict; |
|
13
|
|
|
|
|
36
|
|
|
13
|
|
|
|
|
401
|
|
772
|
13
|
|
|
13
|
|
78
|
use vars qw($AUTOLOAD $VERSION); |
|
13
|
|
|
|
|
33
|
|
|
13
|
|
|
|
|
2965
|
|
773
|
|
|
|
|
|
|
$VERSION = "5.5008"; |
774
|
|
|
|
|
|
|
|
775
|
|
|
|
|
|
|
# formerly CPAN::HandleConfig was known as CPAN::Config |
776
|
|
|
|
|
|
|
sub AUTOLOAD { ## no critic |
777
|
0
|
|
|
0
|
|
|
my $class = shift; # e.g. in dh-make-perl: CPAN::Config |
778
|
0
|
|
|
|
|
|
my($l) = $AUTOLOAD; |
779
|
0
|
|
|
|
|
|
$CPAN::Frontend->mywarn("Dispatching deprecated method '$l' to CPAN::HandleConfig\n"); |
780
|
0
|
|
|
|
|
|
$l =~ s/.*:://; |
781
|
0
|
|
|
|
|
|
CPAN::HandleConfig->$l(@_); |
782
|
|
|
|
|
|
|
} |
783
|
|
|
|
|
|
|
} |
784
|
|
|
|
|
|
|
|
785
|
|
|
|
|
|
|
1; |
786
|
|
|
|
|
|
|
|
787
|
|
|
|
|
|
|
__END__ |