line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
1
|
|
|
1
|
|
67505
|
use strict; |
|
1
|
|
|
|
|
15
|
|
|
1
|
|
|
|
|
30
|
|
2
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
43
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package CPAN::Mini::App 1.111017; |
5
|
|
|
|
|
|
|
|
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
|
|
562
|
use CPAN::Mini; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
37
|
|
17
|
1
|
|
|
1
|
|
9
|
use File::HomeDir; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
55
|
|
18
|
1
|
|
|
1
|
|
7
|
use File::Spec; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
23
|
|
19
|
1
|
|
|
1
|
|
793
|
use Getopt::Long qw(:config no_ignore_case); |
|
1
|
|
|
|
|
10715
|
|
|
1
|
|
|
|
|
5
|
|
20
|
1
|
|
|
1
|
|
739
|
use Pod::Usage 1.00; |
|
1
|
|
|
|
|
50390
|
|
|
1
|
|
|
|
|
128
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _display_version { |
23
|
0
|
|
|
0
|
|
0
|
my $class = shift; |
24
|
1
|
|
|
1
|
|
6
|
no strict 'refs'; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
443
|
|
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
|
|
16
|
my ($class, $level) = @_; |
40
|
9
|
50
|
|
|
|
43
|
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
|
22737
|
my ($class) = @_; |
54
|
|
|
|
|
|
|
|
55
|
11
|
|
|
|
|
19
|
my $version; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
my %commandline; |
58
|
|
|
|
|
|
|
|
59
|
11
|
|
|
|
|
18
|
my @option_spec = $class->_option_spec(); |
60
|
11
|
50
|
|
|
|
33
|
GetOptions(\%commandline, @option_spec) or pod2usage(2); |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
# These two options will cause the program to exit before finishing ->run |
63
|
11
|
50
|
|
|
|
12758
|
pod2usage(1) if $commandline{help}; |
64
|
11
|
50
|
|
|
|
20
|
$version = 1 if $commandline{version}; |
65
|
|
|
|
|
|
|
|
66
|
|
|
|
|
|
|
# How noisy should we be? |
67
|
11
|
|
|
|
|
13
|
my $debug = $commandline{debug}; |
68
|
11
|
|
|
|
|
17
|
my $log_level = $commandline{log_level}; |
69
|
11
|
100
|
|
|
|
17
|
my $quiet = $commandline{qq} ? 2 : $commandline{quiet}; |
70
|
|
|
|
|
|
|
|
71
|
11
|
100
|
|
|
|
32
|
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
|
|
|
28
|
$quiet ||= 0; |
76
|
9
|
100
|
|
|
|
24
|
$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
|
|
|
|
|
52
|
my %config = CPAN::Mini->read_config({ |
83
|
|
|
|
|
|
|
log_level => 'info', |
84
|
|
|
|
|
|
|
%commandline |
85
|
|
|
|
|
|
|
}); |
86
|
|
|
|
|
|
|
|
87
|
9
|
|
50
|
|
|
51
|
$config{class} ||= 'CPAN::Mini'; |
88
|
|
|
|
|
|
|
|
89
|
|
|
|
|
|
|
# Override config with commandline options |
90
|
9
|
|
|
|
|
35
|
%config = (%config, %commandline); |
91
|
|
|
|
|
|
|
|
92
|
9
|
|
100
|
|
|
30
|
$config{log_level} = $log_level || $config{log_level} || 'info'; |
93
|
9
|
|
|
|
|
30
|
$class->_validate_log_level($config{log_level}); |
94
|
|
|
|
|
|
|
|
95
|
9
|
|
|
|
|
462
|
eval "require $config{class}"; |
96
|
9
|
50
|
|
|
|
32
|
die $@ if $@; |
97
|
|
|
|
|
|
|
|
98
|
9
|
50
|
|
|
|
15
|
_display_version($config{class}) if $version; |
99
|
|
|
|
|
|
|
|
100
|
9
|
50
|
33
|
|
|
20
|
if ($config{remote_from} && ! $config{remote}) { |
101
|
|
|
|
|
|
|
$config{remote} = $config{class}->remote_from( |
102
|
|
|
|
|
|
|
$config{remote_from}, |
103
|
|
|
|
|
|
|
$config{remote}, |
104
|
|
|
|
|
|
|
$config{quiet}, |
105
|
0
|
|
|
|
|
0
|
); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
9
|
|
50
|
|
|
19
|
$config{remote} ||= 'http://www.cpan.org/'; |
109
|
|
|
|
|
|
|
|
110
|
9
|
50
|
33
|
|
|
30
|
pod2usage(2) unless $config{local} and $config{remote}; |
111
|
|
|
|
|
|
|
|
112
|
9
|
|
|
|
|
18
|
$|++; |
113
|
|
|
|
|
|
|
|
114
|
|
|
|
|
|
|
# Convert dirmode string to a real octal value, if given |
115
|
9
|
50
|
|
|
|
19
|
$config{dirmode} = oct $config{dirmode} if $config{dirmode}; |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
# Turn the 'perl' option into 'skip_perl', for backward compatibility |
118
|
9
|
|
|
|
|
20
|
$config{skip_perl} = not delete $config{perl}; |
119
|
|
|
|
|
|
|
|
120
|
9
|
|
|
|
|
37
|
return $config{class}->new(%config); |
121
|
|
|
|
|
|
|
} |
122
|
|
|
|
|
|
|
|
123
|
|
|
|
|
|
|
sub _option_spec { |
124
|
11
|
|
|
11
|
|
36
|
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__ |