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('nbyj', \%switches);
25 ./perl -Ilib Porting/makemeta
33 The default is to update both, META.yml and META.json
37 Don't update any files, exit with 1 if changes would be made
41 No-op, kept for historical purposes
47 push @metafiles, 'META.yml';
49 elsif ( $switches{j} ) {
50 push @metafiles, 'META.json';
53 push @metafiles, keys %$opts;
56 my ($vers, $stat ) = _determine_status();
62 'perl5-porters@perl.org'
67 'abstract' => 'The Perl 5 language interpreter',
68 'release_status' => $stat,
69 'dynamic_config' => 1,
72 'url' => 'https://github.com/Perl/perl5'
74 'homepage' => 'https://www.perl.org/',
76 'web' => 'https://github.com/Perl/perl5/issues'
79 'https://dev.perl.org/licenses/'
85 use File::Basename qw( dirname );
90 # Get function prototypes
91 require './regen/regen_lib.pl';
94 use Maintainers qw(%Modules get_module_files get_module_pat);
96 my @CPAN = grep { $Modules{$_}{CPAN} } keys %Modules;
97 my @files = ('autodoc.pl', 'lib/unicore/mktables', 'TestInit.pm',
98 'Porting/Maintainers.pm', 'Porting/perldelta_template.pod',
99 map { get_module_files($_) } @CPAN);
100 my @extt = map { my $t = File::Spec->catdir($_, "t");
101 -d $t ? ( $_ . "t" ) : () }
102 grep { /^ext\b/ } split ' ', $Modules{_PERLLIB}{FILES};
103 my @dirs = ('cpan', 'win32', 'lib/perl5db', @extt, grep { -d $_ && $_ !~ /^cpan/ } map { get_module_pat($_) } @CPAN);
112 while(($d = dirname($d)) ne "."){
113 last if $d eq $previous_d; # safety valve
114 last if exists $dirs{$d};
118 # if $d is "." it means we tried every parent dir of the file and none
119 # of them were in the private list
121 $d eq "." || $d eq $previous_d;
123 sort { lc $a cmp lc $b } @files;
125 @dirs = sort { lc $a cmp lc $b } @dirs;
127 $distmeta->{no_index}->{file} = \@files;
128 $distmeta->{no_index}->{directory} = \@dirs;
130 my $meta = CPAN::Meta->create( $distmeta );
131 foreach my $file ( @metafiles ) {
132 my $new = $meta->as_string( $opts->{$file} );
134 open my $fh, '<:raw', $file;
141 my $fh = open_new($file);
143 close_and_rename($fh);
148 sub _determine_status {
149 my $patchlevel_h = 'patchlevel.h';
150 return unless -e $patchlevel_h;
155 open my $fh, '<', $patchlevel_h;
159 next unless m!^#define! or m!!;
161 my ($foo,$bar) = ( split /\s+/ )[1,2];
162 $defines{$foo} = $bar;
164 elsif ( m!\"RC\d+\"! ) {
170 $status = $defines{PERL_VERSION} % 2 ? 'unstable' : 'stable';
172 if ( my @wotsits = grep { defined $defines{$_} } qw(PERL_REVISION PERL_VERSION PERL_SUBVERSION) ) {
173 $version = sprintf '%d.%03d%03d', map { $defines{$_} } @wotsits;
176 # Well, you never know
177 $version = sprintf '5.%03d_%02d', map { $defines{$_} } qw(PATCHLEVEL SUBVERSION);
180 return ( $version, $status );