line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
40767
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
39
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
67
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package CPAN::Mini::App; |
5
|
|
|
|
|
|
|
$CPAN::Mini::App::VERSION = '1.111016'; |
6
|
|
|
|
|
|
|
# ABSTRACT: the guts of the minicpan command |
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
#pod =head1 SYNOPSIS |
9
|
|
|
|
|
|
|
#pod |
10
|
|
|
|
|
|
|
#pod #!/usr/bin/perl |
11
|
|
|
|
|
|
|
#pod use CPAN::Mini::App; |
12
|
|
|
|
|
|
|
#pod CPAN::Mini::App->run; |
13
|
|
|
|
|
|
|
#pod |
14
|
|
|
|
|
|
|
#pod =cut |
15
|
|
|
|
|
|
|
|
16
|
1
|
|
|
1
|
|
1156
|
use CPAN::Mini; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
37
|
|
17
|
1
|
|
|
1
|
|
11
|
use File::HomeDir; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
66
|
|
18
|
1
|
|
|
1
|
|
7
|
use File::Spec; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
30
|
|
19
|
1
|
|
|
1
|
|
1568
|
use Getopt::Long qw(:config no_ignore_case); |
|
1
|
|
|
|
|
15371
|
|
|
1
|
|
|
|
|
6
|
|
20
|
1
|
|
|
1
|
|
1212
|
use Pod::Usage 1.00; |
|
1
|
|
|
|
|
66379
|
|
|
1
|
|
|
|
|
157
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _display_version { |
23
|
0
|
|
|
0
|
|
0
|
my $class = shift; |
24
|
1
|
|
|
1
|
|
14
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
534
|
|
25
|
0
|
0
|
|
|
|
0
|
print "minicpan", |
26
|
|
|
|
|
|
|
($class ne 'CPAN::Mini' ? ' (from CPAN::Mini)' : q{}), |
27
|
|
|
|
|
|
|
", powered by $class ", $class->VERSION, "\n\n"; |
28
|
0
|
|
|
|
|
0
|
exit; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
#pod =method run |
32
|
|
|
|
|
|
|
#pod |
33
|
|
|
|
|
|
|
#pod This method is called by F to do all the work. Don't rely on what it |
34
|
|
|
|
|
|
|
#pod does just yet. |
35
|
|
|
|
|
|
|
#pod |
36
|
|
|
|
|
|
|
#pod =cut |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub _validate_log_level { |
39
|
9
|
|
|
9
|
|
17
|
my ($class, $level) = @_; |
40
|
9
|
50
|
|
|
|
53
|
return $level if $level =~ /\A(?:fatal|warn|debug|info)\z/; |
41
|
0
|
|
|
|
|
0
|
die "unknown logging level: $level\n"; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub run { |
45
|
0
|
|
|
0
|
1
|
0
|
my ($class) = @_; |
46
|
|
|
|
|
|
|
|
47
|
0
|
|
|
|
|
0
|
my $minicpan = $class->initialize_minicpan; |
48
|
|
|
|
|
|
|
|
49
|
0
|
|
|
|
|
0
|
$minicpan->update_mirror; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub initialize_minicpan { |
53
|
11
|
|
|
11
|
0
|
21362
|
my ($class) = @_; |
54
|
|
|
|
|
|
|
|
55
|
11
|
|
|
|
|
14
|
my $version; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my %commandline; |
58
|
|
|
|
|
|
|
|
59
|
11
|
|
|
|
|
32
|
my @option_spec = $class->_option_spec(); |
60
|
11
|
50
|
|
|
|
59
|
GetOptions(\%commandline, @option_spec) or pod2usage(2); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# These two options will cause the program to exit before finishing ->run |
63
|
11
|
50
|
|
|
|
13406
|
pod2usage(1) if $commandline{help}; |
64
|
11
|
50
|
|
|
|
31
|
$version = 1 if $commandline{version}; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# How noisy should we be? |
67
|
11
|
|
|
|
|
20
|
my $debug = $commandline{debug}; |
68
|
11
|
|
|
|
|
16
|
my $log_level = $commandline{log_level}; |
69
|
11
|
100
|
|
|
|
27
|
my $quiet = $commandline{qq} ? 2 : $commandline{quiet}; |
70
|
|
|
|
|
|
|
|
71
|
11
|
100
|
|
|
|
48
|
die "can't mix --debug, --log-level, and --debug\n" |
72
|
|
|
|
|
|
|
if defined($quiet) + defined($debug) + defined($log_level) > 1; |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
# Set log_level accordingly |
75
|
9
|
|
100
|
|
|
34
|
$quiet ||= 0; |
76
|
9
|
100
|
|
|
|
42
|
$log_level = $debug ? 'debug' |
|
|
100
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
77
|
|
|
|
|
|
|
: $quiet == 1 ? 'warn' |
78
|
|
|
|
|
|
|
: $quiet >= 2 ? 'fatal' |
79
|
|
|
|
|
|
|
: $log_level ? $log_level |
80
|
|
|
|
|
|
|
: undef; |
81
|
|
|
|
|
|
|
|
82
|
9
|
|
|
|
|
86
|
my %config = CPAN::Mini->read_config({ |
83
|
|
|
|
|
|
|
log_level => 'info', |
84
|
|
|
|
|
|
|
%commandline |
85
|
|
|
|
|
|
|
}); |
86
|
|
|
|
|
|
|
|
87
|
9
|
|
50
|
|
|
55
|
$config{class} ||= 'CPAN::Mini'; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# Override config with commandline options |
90
|
9
|
|
|
|
|
47
|
%config = (%config, %commandline); |
91
|
|
|
|
|
|
|
|
92
|
9
|
|
100
|
|
|
51
|
$config{log_level} = $log_level || $config{log_level} || 'info'; |
93
|
9
|
|
|
|
|
35
|
$class->_validate_log_level($config{log_level}); |
94
|
|
|
|
|
|
|
|
95
|
9
|
|
|
|
|
626
|
eval "require $config{class}"; |
96
|
9
|
50
|
|
|
|
39
|
die $@ if $@; |
97
|
|
|
|
|
|
|
|
98
|
9
|
50
|
|
|
|
22
|
_display_version($config{class}) if $version; |
99
|
|
|
|
|
|
|
|
100
|
9
|
50
|
33
|
|
|
29
|
if ($config{remote_from} && ! $config{remote}) { |
101
|
0
|
|
|
|
|
0
|
$config{remote} = $config{class}->remote_from( |
102
|
|
|
|
|
|
|
$config{remote_from}, |
103
|
|
|
|
|
|
|
$config{remote}, |
104
|
|
|
|
|
|
|
$config{quiet}, |
105
|
|
|
|
|
|
|
); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
9
|
|
50
|
|
|
25
|
$config{remote} ||= 'http://www.cpan.org/'; |
109
|
|
|
|
|
|
|
|
110
|
9
|
50
|
33
|
|
|
51
|
pod2usage(2) unless $config{local} and $config{remote}; |
111
|
|
|
|
|
|
|
|
112
|
9
|
|
|
|
|
26
|
$|++; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# Convert dirmode string to a real octal value, if given |
115
|
9
|
50
|
|
|
|
20
|
$config{dirmode} = oct $config{dirmode} if $config{dirmode}; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# Turn the 'perl' option into 'skip_perl', for backward compatibility |
118
|
9
|
|
|
|
|
24
|
$config{skip_perl} = not delete $config{perl}; |
119
|
|
|
|
|
|
|
|
120
|
9
|
|
|
|
|
53
|
return $config{class}->new(%config); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub _option_spec { |
124
|
11
|
|
|
11
|
|
99
|
return qw< |
125
|
|
|
|
|
|
|
class|c=s |
126
|
|
|
|
|
|
|
help|h |
127
|
|
|
|
|
|
|
version|v |
128
|
|
|
|
|
|
|
quiet|q+ |
129
|
|
|
|
|
|
|
qq |
130
|
|
|
|
|
|
|
debug |
131
|
|
|
|
|
|
|
log_level|log-level=s |
132
|
|
|
|
|
|
|
local|l=s |
133
|
|
|
|
|
|
|
remote|r=s |
134
|
|
|
|
|
|
|
dirmode|d=s |
135
|
|
|
|
|
|
|
offline |
136
|
|
|
|
|
|
|
force|f |
137
|
|
|
|
|
|
|
perl |
138
|
|
|
|
|
|
|
exact_mirror|x |
139
|
|
|
|
|
|
|
timeout|t=i |
140
|
|
|
|
|
|
|
config_file|config|C=s |
141
|
|
|
|
|
|
|
remote-from=s |
142
|
|
|
|
|
|
|
>; |
143
|
|
|
|
|
|
|
} |
144
|
|
|
|
|
|
|
|
145
|
|
|
|
|
|
|
#pod =head1 SEE ALSO |
146
|
|
|
|
|
|
|
#pod |
147
|
|
|
|
|
|
|
#pod Randal Schwartz's original article, which can be found here: |
148
|
|
|
|
|
|
|
#pod |
149
|
|
|
|
|
|
|
#pod http://www.stonehenge.com/merlyn/LinuxMag/col42.html |
150
|
|
|
|
|
|
|
#pod |
151
|
|
|
|
|
|
|
#pod =cut |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
1; |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
__END__ |