2 # Reports, in a perl source tree, which dual-lived core modules have not the
3 # same version than the corresponding module on CPAN.
10 use Maintainers qw(get_module_files %Modules);
12 our $packagefile = '02packages.details.txt';
16 $0 - report which core modules are outdated.
17 To be run at the root of a perl source tree.
20 -v : verbose (print all versions of all files, not only those which differ)
21 -f : force download of $packagefile from CPAN
22 (it's expected to be found in the current directory)
26 sub get_package_details () {
27 my $url = 'http://www.cpan.org/modules/02packages.details.txt.gz';
29 system("wget $url && gunzip $packagefile.gz") == 0
30 or die "Failed to get package details\n";
35 our $opt_f or !-f $packagefile and get_package_details;
37 # Load the package details. All of them.
39 open my $fh, $packagefile or die $!;
41 my ($p, $v) = split ' ';
42 $cpanversions{$p} = $v;
46 for my $dist (sort keys %Modules) {
47 next unless $Modules{$dist}{CPAN};
48 print "Module $dist...\n";
49 for my $file (get_module_files($dist)) {
50 next if $file !~ /\.pm\z/ or $file =~ m{^t/} or $file =~ m{/t/};
51 my $vcore = MM->parse_version($file) // 'undef';
53 $module =~ s/\.pm\z//;
54 # some heuristics to figure out the module name from the file name
55 $module =~ s{^(lib|ext)/}{}
57 and ( $module =~ s{^(.*)/lib/\1\b}{$1},
58 $module =~ s{(\w+)/\1\b}{$1},
59 $module =~ s{^Encode/encoding}{encoding},
60 $module =~ s{^MIME/Base64/QuotedPrint}{MIME/QuotedPrint},
61 $module =~ s{^List/Util/lib/Scalar}{Scalar},
64 my $vcpan = $cpanversions{$module} // 'not found';
65 if (our $opt_v or $vcore ne $vcpan) {
66 print " $file: core=$vcore, cpan=$vcpan\n";