From: Jesse Vincent Date: Wed, 29 Jul 2009 22:36:12 +0000 (-0400) Subject: Porting/corelist.pl can now update Module::CoreList directly X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=dc2f75c0f2e64ac8eee5e3138845de02223668f8;p=p5sagit%2Fp5-mst-13.2.git Porting/corelist.pl can now update Module::CoreList directly Rather than requiring a release engineer to cut and paste into Module::CoreList use the magic of regexps to do a first pass. --- diff --git a/Porting/corelist.pl b/Porting/corelist.pl index bb0cf92..b213f03 100644 --- a/Porting/corelist.pl +++ b/Porting/corelist.pl @@ -1,116 +1,150 @@ #!perl # Generates info for Module::CoreList from this perl tree -# run this from the root of a perl tree, using the perl built in that tree. +# run this from the root of a perl tree # # Data is on STDOUT. # # With an optional arg specifying the root of a CPAN mirror, outputs the # %upstream and %bug_tracker hashes too. -use 5.010001; # needs Parse::CPAN::Meta - use strict; use warnings; use File::Find; use ExtUtils::MM_Unix; +use version; use lib "Porting"; use Maintainers qw(%Modules files_to_modules); use File::Spec; +use Parse::CPAN::Meta; +my $corelist_file = 'lib/Module/CoreList.pm'; my %lines; my %module_to_file; my %modlist; -die "usage: $0 [ cpan-mirror/ ]\n" unless @ARGV <= 1; -my $cpan = shift; +die "usage: $0 [ cpan-mirror/ ] [ 5.x.y] \n" unless @ARGV <= 2; +my $cpan = shift; +my $raw_version = shift || $]; +my $perl_version = version->parse("$raw_version"); +my $perl_vnum = $perl_version->numify; +my $perl_vstring = $perl_version->normal; # how do we get version.pm to not give us leading v? +$perl_vstring =~ s/^v//; -if (! -f 'MANIFEST') { - die "Must be run from the root of a clean perl tree\n" +if ( !-f 'MANIFEST' ) { + die "Must be run from the root of a clean perl tree\n"; } +open( my $corelist_fh, '<', $corelist_file ) || die "Could not open $corelist_file: $!"; +my $corelist = join( '', <$corelist_fh> ); + if ($cpan) { - my $modlistfile - = File::Spec->catfile($cpan, 'modules', '02packages.details.txt'); - open my $fh, '<', $modlistfile or die "Couldn't open $modlistfile: $!"; - - { - local $/ = "\n\n"; - die "Incompatible modlist format" - unless <$fh> =~ /^Columns: +package name, version, path/m; + my $modlistfile = File::Spec->catfile( $cpan, 'modules', '02packages.details.txt' ); + my $content; + + my $fh; + if ( -e $modlistfile ) { + warn "Reading the module list from $modlistfile"; + open $fh, '<', $modlistfile or die "Couldn't open $modlistfile: $!"; + } elsif ( -e $modlistfile . ".gz" ) { + warn "Reading the module list from $modlistfile.gz"; + open $fh, '-|', "gzcat $modlistfile.gz" or die "Couldn't zcat $modlistfile.gz: $!"; + } else { + warn "About to fetch 02packages from ftp.funet.fi. This may take a few minutes\n"; + $content = fetch_url('http://ftp.funet.fi/pub/CPAN/modules/02packages.details.txt'); + unless ($content) { + die "Unable to read 02packages.details.txt from either your CPAN mirror or ftp.funet.fi"; + } + } + + if ( $fh and !$content ) { + local $/ = "\n"; + $content = join( '', <$fh> ); } + die "Incompatible modlist format" + unless $content =~ /^Columns: +package name, version, path/m; + # Converting the file to a hash is about 5 times faster than a regexp flat # lookup. - while (<$fh>) { - next unless /^([A-Za-z_:0-9]+) +[-0-9.undefHASHVERSIONvsetwhenloadingbogus]+ +(\S+)/; - $modlist{$1} = $2; + for ( split( qr/\n/, $content ) ) { + next unless /^([A-Za-z_:0-9]+) +[-0-9.undefHASHVERSIONvsetwhenloadingbogus]+ +(\S+)/; + $modlist{$1} = $2; } } -find(sub { - /(\.pm|_pm\.PL)$/ or return; - /PPPort\.pm$/ and return; - my $module = $File::Find::name; - $module =~ /\b(demo|t|private)\b/ and return; # demo or test modules - my $version = MM->parse_version($_); - defined $version or $version = 'undef'; - $version =~ /\d/ and $version = "'$version'"; - # some heuristics to figure out the module name from the file name - $module =~ s{^(lib|(win32/|vms/|symbian/)?ext)/}{} - and $1 ne 'lib' - and ( $module =~ s{\b(\w+)/\1\b}{$1}, - $module =~ s{^B/O}{O}, - $module =~ s{^Devel-PPPort}{Devel}, - $module =~ s{^Encode/encoding}{encoding}, - $module =~ s{^IPC-SysV/}{IPC/}, - $module =~ s{^MIME-Base64/QuotedPrint}{MIME/QuotedPrint}, - $module =~ s{^(?:DynaLoader|Errno|Opcode)/}{}, - ); - $module =~ s{/}{::}g; - $module =~ s{-}{::}g; - $module =~ s{^.*::lib::}{}; - $module =~ s/(\.pm|_pm\.PL)$//; - $lines{$module} = $version; - $module_to_file{$module} = $File::Find::name; -}, 'lib', 'ext', 'vms/ext', 'symbian/ext'); +find( + sub { + /(\.pm|_pm\.PL)$/ or return; + /PPPort\.pm$/ and return; + my $module = $File::Find::name; + $module =~ /\b(demo|t|private)\b/ and return; # demo or test modules + my $version = MM->parse_version($_); + defined $version or $version = 'undef'; + $version =~ /\d/ and $version = "'$version'"; + + # some heuristics to figure out the module name from the file name + $module =~ s{^(lib|(win32/|vms/|symbian/)?ext)/}{} + and $1 ne 'lib' + and ( + $module =~ s{\b(\w+)/\1\b}{$1}, + $module =~ s{^B/O}{O}, + $module =~ s{^Devel-PPPort}{Devel}, + $module =~ s{^Encode/encoding}{encoding}, + $module =~ s{^IPC-SysV/}{IPC/}, + $module =~ s{^MIME-Base64/QuotedPrint}{MIME/QuotedPrint}, + $module =~ s{^(?:DynaLoader|Errno|Opcode)/}{}, + ); + $module =~ s{/}{::}g; + $module =~ s{-}{::}g; + $module =~ s{^.*::lib::}{}; + $module =~ s/(\.pm|_pm\.PL)$//; + $lines{$module} = $version; + $module_to_file{$module} = $File::Find::name; + }, + 'lib', + 'ext', + 'vms/ext', + 'symbian/ext' +); -e 'configpm' and $lines{Config} = 'undef'; -if (open my $ucdv, "<", "lib/unicore/version") { - chomp (my $ucd = <$ucdv>); +if ( open my $ucdv, "<", "lib/unicore/version" ) { + chomp( my $ucd = <$ucdv> ); $lines{Unicode} = "'$ucd'"; close $ucdv; - } +} -sub display_hash { - my ($hash) = @_; +my $versions_in_release = " " . $perl_vnum . " => {\n"; +foreach my $key ( sort keys %lines ) { + $versions_in_release .= sprintf "\t%-24s=> %s,\n", "'$key'", $lines{$key}; } +$versions_in_release .= " },\n"; -print " $] => {\n"; -printf "\t%-24s=> $lines{$_},\n", "'$_'" foreach sort keys %lines; -print " },\n"; +$corelist =~ s/^(%version\s*=\s*.*?)(^\);)$/$1$versions_in_release$2/xism; exit unless %modlist; # We have to go through this two stage lookup, given how Maintainers.pl keys its # data by "Module", which is really a dist. -my $file_to_M = files_to_modules(values %module_to_file); +my $file_to_M = files_to_modules( values %module_to_file ); my %module_to_upstream; my %module_to_dist; my %dist_to_meta_YAML; -while (my ($module, $file) = each %module_to_file) { +while ( my ( $module, $file ) = each %module_to_file ) { my $M = $file_to_M->{$file}; next unless $M; next if $Modules{$M}{MAINTAINER} eq 'p5p'; $module_to_upstream{$module} = $Modules{$M}{UPSTREAM}; - next if defined $module_to_upstream{$module} && - $module_to_upstream{$module} =~ /^(?:blead|first-come)$/; + next + if defined $module_to_upstream{$module} + && $module_to_upstream{$module} =~ /^(?:blead|first-come)$/; my $dist = $modlist{$module}; unless ($dist) { - warn "Can't find a distribution for $module"; - next; + warn "Can't find a distribution for $module\n"; + next; } $module_to_dist{$module} = $dist; @@ -119,41 +153,99 @@ while (my ($module, $file) = each %module_to_file) { $dist_to_meta_YAML{$dist} = undef; # Like it or lump it, this has to be Unix format. - my $meta_YAML_path = "$cpan/authors/id/$dist"; + my $meta_YAML_path = "authors/id/$dist"; $meta_YAML_path =~ s/(?:tar\.gz|zip)$/meta/ or die "$meta_YAML_path"; - unless (-e $meta_YAML_path) { - warn "$meta_YAML_path does not exist for $module"; - # I tried code to open the tarballs with Archive::Tar to find and - # extract META.yml, but only Text-Tabs+Wrap-2006.1117.tar.gz had one, - # so it's not worth including. - next; + my $meta_YAML_url = 'http://ftp.funet.fi/pub/CPAN/' . $meta_YAML_path; + + if ( -e "$cpan/$meta_YAML_path" ) { + $dist_to_meta_YAML{$dist} = Parse::CPAN::Meta::LoadFile( $cpan . "/" . $meta_YAML_path ); + } elsif ( my $content = fetch_url($meta_YAML_url) ) { + unless ($content) { + warn "Failed to fetch $meta_YAML_url\n"; + next; + } + eval { $dist_to_meta_YAML{$dist} = Parse::CPAN::Meta::Load($content); }; + if ( my $err = $@ ) { + warn "$meta_YAML_path: ".$err; + next; + } + } else { + warn "$meta_YAML_path does not exist for $module\n"; + + # I tried code to open the tarballs with Archive::Tar to find and + # extract META.yml, but only Text-Tabs+Wrap-2006.1117.tar.gz had one, + # so it's not worth including. + next; } - require Parse::CPAN::Meta; - $dist_to_meta_YAML{$dist} = Parse::CPAN::Meta::LoadFile($meta_YAML_path); } -print "\n%upstream = (\n"; -foreach my $module (sort keys %module_to_upstream) { - my $upstream = defined $module_to_upstream{$module} - ? "'$module_to_upstream{$module}'" : 'undef'; - printf " %-24s=> $upstream,\n", "'$module'"; +my $upstream_stanza = "%upstream = (\n"; +foreach my $module ( sort keys %module_to_upstream ) { + my $upstream = defined $module_to_upstream{$module} ? "'$module_to_upstream{$module}'" : 'undef'; + $upstream_stanza .= sprintf " %-24s=> %s,\n", "'$module'", $upstream; } -print ");\n"; +$upstream_stanza .= ");"; + +$corelist =~ s/^%upstream .*? ;$/$upstream_stanza/ismx; -print "\n%bug_tracker = (\n"; -foreach my $module (sort keys %module_to_upstream) { +my $tracker = "%bug_tracker = (\n"; +foreach my $module ( sort keys %module_to_upstream ) { my $upstream = defined $module_to_upstream{$module}; - next if defined $upstream - and $upstream eq 'blead' || $upstream eq 'first-come'; + next + if defined $upstream + and $upstream eq 'blead' || $upstream eq 'first-come'; my $bug_tracker; my $dist = $module_to_dist{$module}; $bug_tracker = $dist_to_meta_YAML{$dist}->{resources}{bugtracker} - if $dist; + if $dist; $bug_tracker = defined $bug_tracker ? "'$bug_tracker'" : 'undef'; next if $bug_tracker eq "'http://rt.perl.org/perlbug/'"; - printf " %-24s=> $bug_tracker,\n", "'$module'"; + $tracker .= sprintf " %-24s=> %s,\n", "'$module'", $bug_tracker; +} +$tracker .= ");"; + +$corelist =~ s/^%bug_tracker .*? ;/$tracker/eismx; + +unless ( $corelist =~ /and $perl_vstring releases of perl/ ) { + warn "Adding $perl_vstring to the list of perl versions covered by Module::CoreList\n"; + $corelist =~ s/\s*and (.*?) releases of perl/, $1 and $perl_vstring releases of perl/ism; +} + +unless ( + $corelist =~ /^%released \s* = \s* \( + .*? + $perl_vnum => .*? + \);/ismx + ) +{ + warn "Adding $perl_vnum to the list of released perl versions. Please consider adding a release date.\n"; + $corelist =~ s/^(%released \s* = \s* .*?) ( \) ) + /$1 $perl_vnum => '????-??-??',\n $2/ismx; +} + +write_corelist($corelist); + +warn "All done. Please check over lib/Module/CoreList.pm carefully before committing. Thanks!\n"; + + +sub write_corelist { + my $content = shift; + open ( my $clfh, ">", "lib/Module/CoreList.pm") || die "Failed to open lib/Module/CoreList.pm for writing: $!"; + print $clfh $content || die "Failed to write the new CoreList.pm: $!"; + close($clfh); +} + +sub fetch_url { + my $url = shift; + eval { require LWP::Simple }; + if ( LWP::Simple->can('get') ) { + return LWP::Simple->get($url); + } elsif (`which curl`) { + return `curl -s $url`; + } elsif (`which wget`) { + return `wget -q -O - $url`; + } } -print ");\n"; diff --git a/Porting/release_managers_guide.pod b/Porting/release_managers_guide.pod index b8324a1..72e93b7 100644 --- a/Porting/release_managers_guide.pod +++ b/Porting/release_managers_guide.pod @@ -430,57 +430,50 @@ Note that if this is a maint release, you should run the following actions from the maint directory, but edit the C in I and subsequently cherry-pick it. -First, in order to update the C<%upstream> and C<%bug_tracker> hashes, -the C script requires you to have a local CPAN -mirror. See http://www.cpan.org/misc/cpan-faq.html#How_mirror_CPAN for -more details, but basically: +corelist.pl uses ftp.funet.fi to verify information about dual-lifed +modules on CPAN. It can use a full, local CPAN mirror or fall back +to C or C to fetch only package metadata remotely. - $ mkdir ~/cpan-mirror - $ rsync -av --delete ftp.funet.fi::CPAN ~/cpan-mirror/ +(If you'd prefer to have a full CPAN mirror, see +http://www.cpan.org/misc/cpan-faq.html#How_mirror_CPAN) -(and re-run the rsync each time you need it to be up-to-date). -[XXX this really needs fixing to not require a whole CPAN mirror] -If necessary, bump C<$VERSION> (there's no need to do this for -every RC; in RC1, bump the version to a new clean number that will -appear in the final release, and leave as-is for the later RCs and final). +Then change to your perl checkout. -Then do +If you have a local CPAN mirror, run: - $ cd ~/perl/root; make perl - $ ./perl -Ilib Porting/corelist.pl ~/cpan-mirror/ > /tmp/corelist + $ perl -Ilib Porting/corelist.pl ~/my-cpan-mirror -This creates a file that looks something like +Otherwise, run: - 5.010001 => { - 'AnyDBM_File' => '1.00', - ... - }, + $ perl -Ilib Porting/corelist.pl cpan - %upstream = ( - 'App::Prove' => undef, - ... - ); +This will chug for a while. Assuming all goes well, it will + update lib/Module/CoreList.pm. - %bug_tracker = ( - 'App::Prove' => 'http://rt.cpan.org/...', - ... - ); +Check that file over carefully: -Cut and paste these tables into F: the module -version list should be appended as the last entry in the C<%version> hash -(or replaced, if we've already added it for an earlier release candidate), -while the existing C<%upstream> and C<%bug_tracker> hashes should be -replaced with the new versions. + $ git diff lib/Module/CoreList.pm + + +If necessary, bump C<$VERSION> (there's no need to do this for +every RC; in RC1, bump the version to a new clean number that will +appear in the final release, and leave as-is for the later RCs and final). Edit the version number in the new C<< 'Module::CoreList' => 'X.YZ' >> entry, as that is likely to reflect the previous version number. -Then, add the current perl version to the C paragraph. + + Add or update an entry to the C<%released> hash, including today's date (if this is just a release candidate, set the date to '????-??-??'). +Finally, commit the new version of Module::CoreList: + + $ git commit -m 'Updated Module::CoreList for the 5.x.y release' \ + lib/Module/Corelist.pm + =item *