-
Notifications
You must be signed in to change notification settings - Fork 6
/
cpanmeta.pl
47 lines (40 loc) · 1.18 KB
/
cpanmeta.pl
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
use 5.010;
use strict;
use warnings;
use CPAN::Meta;
use File::Spec;
my $cpan = '/home/ftp/CPAN';
my %packages;
{
my $packages = File::Spec->catfile( $cpan, 'modules', '02packages.details.txt' );
open my $fh, '<', $packages or die "$!\n";
while (<$fh>) {
last if /^\s*$/;
}
while (<$fh>) {
chomp;
my ($module,$version,$package_path) = split ' ', $_;
next unless $version eq 'undef' or !$version;
$packages{ $package_path } = undef;
}
}
foreach my $package ( sort keys %packages ) {
( my $meta = $package ) =~ s!\.(zip|tgz|tar\.gz|tar\.bz2)!!;
$meta .= '.meta';
my $metafile = File::Spec->catfile( $cpan, 'authors', 'id', $meta );
next unless -e $metafile;
my $metastr = do { local $/; open my $fh, '<', $metafile or die "$!\n"; <$fh> };
my $data;
if ( $metastr =~ m!^\{! ) {
$data = eval { CPAN::Meta->load_json_string( $metastr ) };
next unless $data;
}
else {
# assume yml
$data = eval { CPAN::Meta->load_yaml_string( $metastr ) };
next unless $data;
}
$packages{ $package } = $data->dynamic_config;
}
say "Total indexed dists: " . scalar keys %packages;
say "Total dynamic: " . scalar grep { $packages{$_} } keys %packages;