2 # this script must be run by the current perl to get perl's version right
4 # Create META.yml and META.json files in the current directory. Must be run from the
5 # root directory of a perl source tree.
12 'META.yml' => { version => '1.4' },
13 'META.json' => { version => '2' },
17 getopts('byj', \%switches);
21 push @metafiles, 'META.yml';
23 elsif ( $switches{j} ) {
24 push @metafiles, 'META.json';
27 push @metafiles, keys %$opts;
30 my ($vers, $stat ) = _determine_status();
36 'perl5-porters@perl.org'
41 'abstract' => 'The Perl 5 language interpreter',
42 'release_status' => $stat,
43 'dynamic_config' => 1,
46 'url' => 'http://perl5.git.perl.org/'
48 'homepage' => 'http://www.perl.org/',
50 'web' => 'https://rt.perl.org/'
53 'http://dev.perl.org/licenses/'
59 use File::Basename qw( dirname );
63 # Get function prototypes
64 require 'regen/regen_lib.pl';
67 use Maintainers qw(%Modules get_module_files get_module_pat);
69 my @CPAN = grep { $Modules{$_}{CPAN} } keys %Modules;
70 my @files = ('autodoc.pl', 'lib/unicore/mktables', 'TestInit.pm',
71 'Porting/Maintainers.pm', 'Porting/perldelta_template.pod',
72 map { get_module_files($_) } @CPAN);
73 my @dirs = ('cpan', 'win32', 'lib/perl5db', grep { -d $_ && $_ !~ /^cpan/ } map { get_module_pat($_) } @CPAN);
82 while(($d = dirname($d)) ne "."){
83 last if $d eq $previous_d; # safety valve
84 last if exists $dirs{$d};
88 # if $d is "." it means we tried every parent dir of the file and none
89 # of them were in the private list
91 $d eq "." || $d eq $previous_d;
93 sort { lc $a cmp lc $b } @files;
95 @dirs = sort { lc $a cmp lc $b } @dirs;
97 $distmeta->{no_index}->{file} = \@files;
98 $distmeta->{no_index}->{directory} = \@dirs;
100 my $meta = CPAN::Meta->create( $distmeta );
101 foreach my $file ( @metafiles ) {
102 my $fh = open_new($file);
103 print $fh $meta->as_string( $opts->{$file} );
104 close_and_rename($fh);
108 sub _determine_status {
109 my $patchlevel_h = 'patchlevel.h';
110 return unless -e $patchlevel_h;
115 open my $fh, '<', $patchlevel_h;
119 next unless m!^#define! or m!!;
121 my ($foo,$bar) = ( split /\s+/ )[1,2];
122 $defines{$foo} = $bar;
124 elsif ( m!\"RC\d+\"! ) {
130 $status = $defines{PERL_VERSION} % 2 ? 'unstable' : 'stable';
132 if ( my @wotsits = grep { defined $defines{$_} } qw(PERL_REVISION PERL_VERSION PERL_SUBVERSION) ) {
133 $version = sprintf '%d.%03d%03d', map { $defines{$_} } @wotsits;
136 # Well, you never know
137 $version = sprintf '5.%03d_%02d', map { $defines{$_} } qw(PATCHLEVEL SUBVERSION);
140 return ( $version, $status );