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.
11 # avoid unnecessary churn in x_serialization_backend in META.*
12 $ENV{PERL_JSON_BACKEND} = $ENV{CPAN_META_JSON_BACKEND} = 'JSON::PP';
13 $ENV{PERL_YAML_BACKEND} = 'CPAN::Meta::YAML';
16 'META.yml' => { version => '1.4' },
17 'META.json' => { version => '2' },
21 getopts('byj', \%switches);
25 push @metafiles, 'META.yml';
27 elsif ( $switches{j} ) {
28 push @metafiles, 'META.json';
31 push @metafiles, keys %$opts;
34 my ($vers, $stat ) = _determine_status();
40 'perl5-porters@perl.org'
45 'abstract' => 'The Perl 5 language interpreter',
46 'release_status' => $stat,
47 'dynamic_config' => 1,
50 'url' => 'https://github.com/Perl/perl5'
52 'homepage' => 'https://www.perl.org/',
54 'web' => 'https://github.com/Perl/perl5/issues'
57 'https://dev.perl.org/licenses/'
63 use File::Basename qw( dirname );
67 # Get function prototypes
68 require './regen/regen_lib.pl';
71 use Maintainers qw(%Modules get_module_files get_module_pat);
73 my @CPAN = grep { $Modules{$_}{CPAN} } keys %Modules;
74 my @files = ('autodoc.pl', 'lib/unicore/mktables', 'TestInit.pm',
75 'Porting/Maintainers.pm', 'Porting/perldelta_template.pod',
76 map { get_module_files($_) } @CPAN);
77 my @dirs = ('cpan', 'win32', 'lib/perl5db', grep { -d $_ && $_ !~ /^cpan/ } map { get_module_pat($_) } @CPAN);
86 while(($d = dirname($d)) ne "."){
87 last if $d eq $previous_d; # safety valve
88 last if exists $dirs{$d};
92 # if $d is "." it means we tried every parent dir of the file and none
93 # of them were in the private list
95 $d eq "." || $d eq $previous_d;
97 sort { lc $a cmp lc $b } @files;
99 @dirs = sort { lc $a cmp lc $b } @dirs;
101 $distmeta->{no_index}->{file} = \@files;
102 $distmeta->{no_index}->{directory} = \@dirs;
104 my $meta = CPAN::Meta->create( $distmeta );
105 foreach my $file ( @metafiles ) {
106 my $fh = open_new($file);
107 print $fh $meta->as_string( $opts->{$file} );
108 close_and_rename($fh);
112 sub _determine_status {
113 my $patchlevel_h = 'patchlevel.h';
114 return unless -e $patchlevel_h;
119 open my $fh, '<', $patchlevel_h;
123 next unless m!^#define! or m!!;
125 my ($foo,$bar) = ( split /\s+/ )[1,2];
126 $defines{$foo} = $bar;
128 elsif ( m!\"RC\d+\"! ) {
134 $status = $defines{PERL_VERSION} % 2 ? 'unstable' : 'stable';
136 if ( my @wotsits = grep { defined $defines{$_} } qw(PERL_REVISION PERL_VERSION PERL_SUBVERSION) ) {
137 $version = sprintf '%d.%03d%03d', map { $defines{$_} } @wotsits;
140 # Well, you never know
141 $version = sprintf '5.%03d_%02d', map { $defines{$_} } qw(PATCHLEVEL SUBVERSION);
144 return ( $version, $status );