blob: 39f4ff97519ccbbdd09bffcabaae65624f9fae37 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
|
#!perl
#
# This program generates the list of registered CPAN sites in perlmodlib.PL
#
use strict;
use warnings;
use 5.14.0;
use autodie;
use HTTP::Tiny;
use JSON::PP;
$|=1;
my $http = HTTP::Tiny->new;
my $url = 'http://www.cpan.org/indices/mirrors.json';
my $response = $http->get($url);
unless ( $response->{success} ) {
die "Error downloading $url";
}
die "No content" unless $response->{content};
my $json = JSON::PP->new->utf8;
my $mirrors = $json->decode( $response->{content} );
my %sorted;
my @rsync;
foreach my $mirror ( sort { $a->{continent} cmp $b->{continent} || $a->{country} cmp $b->{country} } @{ $mirrors } ) {
if ( $mirror->{country} eq 'United States' ) {
push @{ $sorted{ $mirror->{continent} }{ $mirror->{country} }{ $mirror->{region} } }, $mirror;
}
else {
push @{ $sorted{ $mirror->{continent} }{ $mirror->{country} } }, $mirror;
}
}
say 'Registered CPAN sites';
say '';
say '=for maintainers';
say 'Generated by Porting/make_modlib_cpan.pl';
say '';
foreach my $continent ( sort { $a cmp $b } keys %sorted ) {
say "=head2 $continent";
say '';
say '=over 4';
say '';
foreach my $country ( sort { $a cmp $b } keys %{ $sorted{ $continent } } ) {
say "=item $country";
say '';
if ( $country eq 'United States' ) {
say '=over 8';
say '';
foreach my $state ( sort { $a cmp $b } keys %{ $sorted{ $continent }{ $country } } ) {
say "=item $state";
say '';
foreach my $mirror ( @{ $sorted{ $continent }{ $country }{ $state } } ) {
say " " . $mirror->{http} if $mirror->{http};
say " " . $mirror->{ftp} if $mirror->{ftp};
push @rsync, $mirror->{rsync} if $mirror->{rsync};
}
say '';
}
say '=back';
say '';
}
else {
foreach my $mirror ( @{ $sorted{ $continent }{ $country } } ) {
say " " . $mirror->{http} if $mirror->{http};
say " " . $mirror->{ftp} if $mirror->{ftp};
push @rsync, $mirror->{rsync} if $mirror->{rsync};
}
say '';
}
}
say '=back';
say '';
}
say '=head2 RSYNC Mirrors';
say '';
foreach my $rsync ( @rsync ) {
say "\t\t$rsync";
}
say '';
|