line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package CPAN::Mini::Inject::Server; |
2
|
1
|
|
|
1
|
|
21939
|
use base 'CGI::Application'; |
|
1
|
|
|
|
|
4
|
|
|
1
|
|
|
|
|
1268
|
|
3
|
|
|
|
|
|
|
|
4
|
1
|
|
|
1
|
|
8880
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
31
|
|
5
|
1
|
|
|
1
|
|
5
|
use warnings; |
|
1
|
|
|
|
|
7
|
|
|
1
|
|
|
|
|
26
|
|
6
|
1
|
|
|
1
|
|
5
|
use Carp; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
70
|
|
7
|
1
|
|
|
1
|
|
1099
|
use CGI::Application::Plugin::AutoRunmode; |
|
1
|
|
|
|
|
10850
|
|
|
1
|
|
|
|
|
8
|
|
8
|
1
|
|
|
1
|
|
1299
|
use CPAN::Mini::Inject; |
|
1
|
|
|
|
|
435282
|
|
|
1
|
|
|
|
|
364
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
=head1 NAME |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
CPAN::Mini::Inject::Server - Inject into your CPAN mirror from over there |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
=head1 VERSION |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
Version 0.03 |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=cut |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
our $VERSION = '0.03'; |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
=head1 SYNOPSIS |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
#under test server |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use CGI::Application::Dispatch::Server; |
28
|
|
|
|
|
|
|
my $server = CGI::Application::Dispatch::Server->new( |
29
|
|
|
|
|
|
|
class => 'CPAN::Mini::Inject::Server::Dispatch', |
30
|
|
|
|
|
|
|
port => '9000' |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
$server->run; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
#under plain cgi |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#!/usr/bin/perl |
38
|
|
|
|
|
|
|
use FindBin '$Bin'; |
39
|
|
|
|
|
|
|
use lib "$Bin/../../rel/path/to/my/perllib"; |
40
|
|
|
|
|
|
|
use CPAN::Mini::Inject::Server::Dispatch |
41
|
|
|
|
|
|
|
CPAN::Mini::Inject::Server::Dispatch->dispatch(); |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
#Apache and mod perl |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
SetHandler perl-script |
47
|
|
|
|
|
|
|
PerlHandler CPAN::Mini::Inject::Server::Dispatch |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
=cut |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
=head1 DESCRIPTION |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
This module is a simple Restish webservice that makes the basic functionality |
55
|
|
|
|
|
|
|
and interface of mcpani (of the CPAN::Mini::Inject package) available from |
56
|
|
|
|
|
|
|
accross a network allowing for remote management of a cpan mirror. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
The original envisaged use for this module was for a continuous integration |
59
|
|
|
|
|
|
|
platform with distributed build nodes to be able to commit its build artifacts |
60
|
|
|
|
|
|
|
back to a common CPAN repository so that subsequent builds of other modules |
61
|
|
|
|
|
|
|
could use source the new version of the software. |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
=cut |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
=head1 FUNCTIONS |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=cut |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
###### |
71
|
|
|
|
|
|
|
# |
72
|
|
|
|
|
|
|
# _mcpi |
73
|
|
|
|
|
|
|
# |
74
|
|
|
|
|
|
|
# Accessor for a mini cpan instance |
75
|
|
|
|
|
|
|
# |
76
|
|
|
|
|
|
|
### |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
sub _mcpi { |
79
|
0
|
|
|
0
|
|
|
my $self = shift; |
80
|
|
|
|
|
|
|
|
81
|
0
|
0
|
|
|
|
|
if (not $self->{mcpi}) |
82
|
|
|
|
|
|
|
{ |
83
|
0
|
|
|
|
|
|
$self->{mcpi} = CPAN::Mini::Inject->new; |
84
|
0
|
|
|
|
|
|
$self->{mcpi}->loadcfg(); |
85
|
0
|
|
|
|
|
|
$self->{mcpi}->parsecfg(); |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
0
|
|
|
|
|
|
return $self->{mcpi}; |
89
|
|
|
|
|
|
|
} # end of method _mcpi |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
=head2 add |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
Invokes the controller to add a new module to the CPAN::Mini server |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
=cut |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
sub add :Runmode { |
99
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
100
|
0
|
|
|
|
|
0
|
$self->header_add(-status => '501 Not Implemented'); |
101
|
|
|
|
|
|
|
|
102
|
0
|
|
|
|
|
0
|
my $query = $self->query(); |
103
|
|
|
|
|
|
|
|
104
|
0
|
|
|
|
|
0
|
my $module_name = $query->param('module'); |
105
|
0
|
|
|
|
|
0
|
my $module_author = $query->param('authorid'); |
106
|
0
|
|
|
|
|
0
|
my $module_version = $query->param('version'); |
107
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
0
|
my $module_filename = $query->param('file'); |
109
|
|
|
|
|
|
|
|
110
|
0
|
0
|
|
|
|
0
|
if (not $module_filename) |
111
|
|
|
|
|
|
|
{ |
112
|
0
|
|
|
|
|
0
|
$self->header_add(-status => '400 No module archive supplied'); |
113
|
0
|
|
|
|
|
0
|
return; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
# check filename ends with tar.gz |
117
|
|
|
|
|
|
|
|
118
|
0
|
|
|
|
|
0
|
my $bytesread; |
119
|
|
|
|
|
|
|
my $tmp_fh; |
120
|
|
|
|
|
|
|
|
121
|
|
|
|
|
|
|
# -e tmp file here to check we don't bash on it can be racey, just forget |
122
|
|
|
|
|
|
|
# about it |
123
|
|
|
|
|
|
|
|
124
|
0
|
|
|
|
|
0
|
my $tmp_module_filename = $module_name; |
125
|
0
|
|
|
|
|
0
|
$tmp_module_filename =~ s/::/-/g; |
126
|
0
|
|
|
|
|
0
|
$tmp_module_filename = "/tmp/$tmp_module_filename-$module_version.tar.gz"; |
127
|
|
|
|
|
|
|
|
128
|
0
|
0
|
|
|
|
0
|
if (not open ($tmp_fh, '>', $tmp_module_filename)) |
129
|
|
|
|
|
|
|
{ |
130
|
0
|
|
|
|
|
0
|
$self->header_add(-status => '500 Internal System Error'); |
131
|
0
|
|
|
|
|
0
|
return; |
132
|
|
|
|
|
|
|
} |
133
|
|
|
|
|
|
|
|
134
|
0
|
|
|
|
|
0
|
while ($bytesread = read($module_filename, my $buffer, 1024)) |
135
|
|
|
|
|
|
|
{ |
136
|
0
|
|
|
|
|
0
|
print $tmp_fh $buffer; |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
0
|
|
|
|
|
0
|
close ($tmp_fh); |
140
|
|
|
|
|
|
|
|
141
|
|
|
|
|
|
|
|
142
|
0
|
|
|
|
|
0
|
my $mcpi = $self->_mcpi(); |
143
|
0
|
|
|
|
|
0
|
$mcpi->add( |
144
|
|
|
|
|
|
|
module => $module_name, |
145
|
|
|
|
|
|
|
authorid => $module_author, |
146
|
|
|
|
|
|
|
version => $module_version, |
147
|
|
|
|
|
|
|
file => $tmp_module_filename, |
148
|
|
|
|
|
|
|
); |
149
|
|
|
|
|
|
|
|
150
|
0
|
|
|
|
|
0
|
unlink $tmp_module_filename; |
151
|
|
|
|
|
|
|
|
152
|
0
|
|
|
|
|
0
|
$mcpi->writelist(); |
153
|
|
|
|
|
|
|
|
154
|
0
|
|
|
|
|
0
|
$self->header_add(-status => '202 Module added'); |
155
|
0
|
|
|
|
|
0
|
return; |
156
|
1
|
|
|
1
|
|
14
|
} # end of subroutine add |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
9
|
|
157
|
|
|
|
|
|
|
|
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=head2 update |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
Updates the cpan mirror |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
=cut |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
sub update :Runmode { |
166
|
0
|
|
|
0
|
1
|
0
|
my $self = shift; |
167
|
|
|
|
|
|
|
|
168
|
0
|
|
|
|
|
0
|
my $mcpi = $self->_mcpi(); |
169
|
|
|
|
|
|
|
|
170
|
0
|
|
|
|
|
0
|
$mcpi->update_mirror(); |
171
|
0
|
|
|
|
|
0
|
$mcpi->inject(); |
172
|
|
|
|
|
|
|
|
173
|
0
|
|
|
|
|
0
|
$self->header_add(-status => '202 Mirror updated'); |
174
|
0
|
|
|
|
|
0
|
return; |
175
|
1
|
|
|
1
|
|
543
|
} # end of subroutine update |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
4
|
|
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
=head2 inject |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
Injects all added modules into the cpan mirror |
181
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
=cut |
183
|
|
|
|
|
|
|
|
184
|
|
|
|
|
|
|
sub inject :Runmode { |
185
|
0
|
|
|
0
|
1
|
|
my $self = shift; |
186
|
|
|
|
|
|
|
|
187
|
0
|
|
|
|
|
|
my $mcpi = $self->_mcpi(); |
188
|
|
|
|
|
|
|
|
189
|
0
|
|
|
|
|
|
$mcpi->inject(); |
190
|
|
|
|
|
|
|
|
191
|
0
|
|
|
|
|
|
$self->header_add(-status => '202 Modules injected'); |
192
|
0
|
|
|
|
|
|
return; |
193
|
1
|
|
|
1
|
|
333
|
} # end of subroutine inject |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
5
|
|
194
|
|
|
|
|
|
|
|
195
|
|
|
|
|
|
|
|
196
|
|
|
|
|
|
|
=head1 AUTHOR |
197
|
|
|
|
|
|
|
|
198
|
|
|
|
|
|
|
Christopher Mckay, C<< >> |
199
|
|
|
|
|
|
|
|
200
|
|
|
|
|
|
|
=head1 BUGS |
201
|
|
|
|
|
|
|
|
202
|
|
|
|
|
|
|
Please report any bugs or feature requests to C, or through |
203
|
|
|
|
|
|
|
the web interface at L. I will be notified, and then you'll |
204
|
|
|
|
|
|
|
automatically be notified of progress on your bug as I make changes. |
205
|
|
|
|
|
|
|
|
206
|
|
|
|
|
|
|
=head1 TO DO |
207
|
|
|
|
|
|
|
|
208
|
|
|
|
|
|
|
Need to add logging down to trace levels to this |
209
|
|
|
|
|
|
|
|
210
|
|
|
|
|
|
|
=head1 SUPPORT |
211
|
|
|
|
|
|
|
|
212
|
|
|
|
|
|
|
You can find documentation for this module with the perldoc command. |
213
|
|
|
|
|
|
|
|
214
|
|
|
|
|
|
|
perldoc CPAN::Mini::Inject::Server |
215
|
|
|
|
|
|
|
|
216
|
|
|
|
|
|
|
|
217
|
|
|
|
|
|
|
You can also look for information at: |
218
|
|
|
|
|
|
|
|
219
|
|
|
|
|
|
|
=over 4 |
220
|
|
|
|
|
|
|
|
221
|
|
|
|
|
|
|
=item * RT: CPAN's request tracker |
222
|
|
|
|
|
|
|
|
223
|
|
|
|
|
|
|
L |
224
|
|
|
|
|
|
|
|
225
|
|
|
|
|
|
|
=item * AnnoCPAN: Annotated CPAN documentation |
226
|
|
|
|
|
|
|
|
227
|
|
|
|
|
|
|
L |
228
|
|
|
|
|
|
|
|
229
|
|
|
|
|
|
|
=item * CPAN Ratings |
230
|
|
|
|
|
|
|
|
231
|
|
|
|
|
|
|
L |
232
|
|
|
|
|
|
|
|
233
|
|
|
|
|
|
|
=item * Search CPAN |
234
|
|
|
|
|
|
|
|
235
|
|
|
|
|
|
|
L |
236
|
|
|
|
|
|
|
|
237
|
|
|
|
|
|
|
=back |
238
|
|
|
|
|
|
|
|
239
|
|
|
|
|
|
|
|
240
|
|
|
|
|
|
|
=head1 ACKNOWLEDGEMENTS |
241
|
|
|
|
|
|
|
|
242
|
|
|
|
|
|
|
|
243
|
|
|
|
|
|
|
=head1 COPYRIGHT & LICENSE |
244
|
|
|
|
|
|
|
|
245
|
|
|
|
|
|
|
Copyright 2009 Christopher Mckay. |
246
|
|
|
|
|
|
|
|
247
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify it |
248
|
|
|
|
|
|
|
under the terms of either: the GNU General Public License as published |
249
|
|
|
|
|
|
|
by the Free Software Foundation; or the Artistic License. |
250
|
|
|
|
|
|
|
|
251
|
|
|
|
|
|
|
See http://dev.perl.org/licenses/ for more information. |
252
|
|
|
|
|
|
|
|
253
|
|
|
|
|
|
|
|
254
|
|
|
|
|
|
|
=cut |
255
|
|
|
|
|
|
|
|
256
|
|
|
|
|
|
|
1; # End of CPAN::Mini::Inject::Server |