2 # Generates info for Module::CoreList from this perl tree
3 # run this from the root of a clean perl tree
10 use Maintainers qw(%Modules files_to_modules);
20 = File::Spec->catfile($cpan, 'modules', '02packages.details.txt');
21 open my $fh, '<', $modlistfile or die "Couldn't open $modlistfile: $!";
25 die "Incompatible modlist format"
26 unless <$fh> =~ /^Columns: +package name, version, path/m;
29 # Converting the file to a hash is about 5 times faster than a regexp flat
32 next unless /^([A-Za-z_:0-9]+) +[-0-9.undefHASHVERSIONvsetwhenloadingbogus]+ +(\S+)/;
38 /(\.pm|_pm\.PL)$/ or return;
39 /PPPort\.pm$/ and return;
40 my $module = $File::Find::name;
41 $module =~ /\b(demo|t|private)\b/ and return; # demo or test modules
42 my $version = MM->parse_version($_);
43 defined $version or $version = 'undef';
44 $version =~ /\d/ and $version = "'$version'";
45 # some heuristics to figure out the module name from the file name
46 $module =~ s{^(lib|(win32/|vms/|symbian/)?ext)/}{}
48 and ( $module =~ s{\b(\w+)/\1\b}{$1},
49 $module =~ s{^B/O}{O},
50 $module =~ s{^Devel-PPPort}{Devel},
51 $module =~ s{^Encode/encoding}{encoding},
52 $module =~ s{^IPC-SysV/}{IPC/},
53 $module =~ s{^MIME-Base64/QuotedPrint}{MIME/QuotedPrint},
54 $module =~ s{^(?:DynaLoader|Errno|Opcode)/}{},
58 $module =~ s{^.*::lib::}{};
59 $module =~ s/(\.pm|_pm\.PL)$//;
60 $lines{$module} = $version;
61 $module_to_file{$module} = $File::Find::name;
62 }, 'lib', 'ext', 'vms/ext', 'symbian/ext');
64 -e 'configpm' and $lines{Config} = 'undef';
66 if (open my $ucdv, "<", "lib/unicore/version") {
67 chomp (my $ucd = <$ucdv>);
68 $lines{Unicode} = "'$ucd'";
77 printf "\t%-24s=> $lines{$_},\n", "'$_'" foreach sort keys %lines;
82 # We have to go through this two stage lookup, given how Maintainers.pl keys its
83 # data by "Module", which is really a dist.
84 my $file_to_M = files_to_modules(values %module_to_file);
86 my %module_to_upstream;
88 my %dist_to_meta_YAML;
89 while (my ($module, $file) = each %module_to_file) {
90 my $M = $file_to_M->{$file};
92 next if $Modules{$M}{MAINTAINER} eq 'p5p';
93 $module_to_upstream{$module} = $Modules{$M}{UPSTREAM};
94 next if defined $module_to_upstream{$module} &&
95 $module_to_upstream{$module} =~ /^(?:blead|first-come)$/;
96 my $dist = $modlist{$module};
98 warn "Can't find a distribution for $module";
101 $module_to_dist{$module} = $dist;
103 next if exists $dist_to_meta_YAML{$dist};
105 $dist_to_meta_YAML{$dist} = undef;
107 # Like it or lump it, this has to be Unix format.
108 my $meta_YAML_path = "$cpan/authors/id/$dist";
109 $meta_YAML_path =~ s/(?:tar\.gz|zip)$/meta/ or die "$meta_YAML_path";
110 unless (-e $meta_YAML_path) {
111 warn "$meta_YAML_path does not exist for $module";
112 # I tried code to open the tarballs with Archive::Tar to find and
113 # extract META.yml, but only Text-Tabs+Wrap-2006.1117.tar.gz had one,
114 # so it's not worth including.
117 require Parse::CPAN::Meta;
118 $dist_to_meta_YAML{$dist} = Parse::CPAN::Meta::LoadFile($meta_YAML_path);
121 print "\n%upstream = (\n";
122 foreach my $module (sort keys %module_to_upstream) {
123 my $upstream = defined $module_to_upstream{$module}
124 ? "'$module_to_upstream{$module}'" : 'undef';
125 printf " %-24s=> $upstream,\n", "'$module'";
129 print "\n%bug_tracker = (\n";
130 foreach my $module (sort keys %module_to_upstream) {
131 my $upstream = defined $module_to_upstream{$module};
132 next if defined $upstream
133 and $upstream eq 'blead' || $upstream eq 'first-come';
137 my $dist = $module_to_dist{$module};
138 $bug_tracker = $dist_to_meta_YAML{$dist}->{resources}{bugtracker}
141 $bug_tracker = defined $bug_tracker ? "'$bug_tracker'" : 'undef';
142 next if $bug_tracker eq "'http://rt.perl.org/perlbug/'";
143 printf " %-24s=> $bug_tracker,\n", "'$module'";