This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
bisect-runner.pl: Reword some pod examples
[perl5.git] / Porting / makemeta
CommitLineData
3e9ed10a
FD
1#!./perl -w
2# this script must be run by the current perl to get perl's version right
0c429c78 3#
bfc0a3e7 4# Create META.yml and META.json files in the current directory. Must be run from the
0c429c78 5# root directory of a perl source tree.
0cf51544
JH
6
7use strict;
8use warnings;
0cf51544 9
bfc0a3e7
CBW
10my $opts = {
11 'META.yml' => { version => '1.4' },
12 'META.json' => { version => '2' },
13};
14
15my $file = shift;
16die "Must specify META.yml or META.json" unless $file and defined $opts->{$file};
3e9ed10a 17
bfc0a3e7
CBW
18my $status = _determine_status();
19
20my $distmeta = {
21 'version' => $],
22 'name' => 'perl',
23 'author' => [
24 'perl5-porters@perl.org'
25 ],
26 'license' => [
27 'perl_5'
28 ],
29 'abstract' => 'The Perl 5 language interpreter',
30 'release_status' => $status,
31 'dynamic_config' => 1,
32 'resources' => {
33 'repository' => {
34 'url' => 'http://perl5.git.perl.org/'
35 },
36 'homepage' => 'http://www.perl.org/',
37 'bugtracker' => {
38 'web' => 'http://rt.perl.org/perlbug/'
39 },
40 'license' => [
41 'http://dev.perl.org/licenses/'
42 ],
43 },
44};
45
46use lib "Porting";
47use File::Basename qw( dirname );
48use CPAN::Meta;
df1ad5b3
JV
49
50BEGIN {
51 # Get function prototypes
2bd4012d 52 require 'regen/regen_lib.pl';
df1ad5b3
JV
53}
54
0cf51544
JH
55use Maintainers qw(%Modules get_module_files get_module_pat);
56
57my @CPAN = grep { $Modules{$_}{CPAN} } keys %Modules;
1ce0c05c 58my @files = ('autodoc.pl', 'lib/unicore/mktables', 'TestInit.pm',
bfc0a3e7
CBW
59 'Porting/Maintainers.pm', 'Porting/perldelta_template.pod',
60 map { get_module_files($_) } @CPAN);
a3265265 61my @dirs = ('cpan', 'win32', 'mad', grep { -d $_ && $_ !~ /^cpan/ } map { get_module_pat($_) } @CPAN);
0cf51544 62
3e9ed10a
FD
63my %dirs;
64@dirs{@dirs} = ();
65
bfc0a3e7 66@files =
3e9ed10a
FD
67 grep {
68 my $d = $_;
2ccec147 69 my $previous_d = '';
3e9ed10a 70 while(($d = dirname($d)) ne "."){
2ccec147 71 last if $d eq $previous_d; # safety valve
3e9ed10a 72 last if exists $dirs{$d};
2ccec147 73 $previous_d = $d;
3e9ed10a
FD
74 }
75
76 # if $d is "." it means we tried every parent dir of the file and none
77 # of them were in the private list
bfc0a3e7 78
2ccec147 79 $d eq "." || $d eq $previous_d;
3e9ed10a
FD
80 }
81 sort { lc $a cmp lc $b } @files;
82
bfc0a3e7 83@dirs = sort { lc $a cmp lc $b } @dirs;
0cf51544 84
bfc0a3e7
CBW
85$distmeta->{no_index}->{file} = \@files;
86$distmeta->{no_index}->{directory} = \@dirs;
0cf51544 87
bfc0a3e7
CBW
88my $meta = CPAN::Meta->create( $distmeta );
89my $fh = open_new($file);
90print $fh $meta->as_string( $opts->{$file} );
284e4287 91close_and_rename($fh);
bfc0a3e7
CBW
92exit 0;
93
94sub _determine_status {
95 my $patchlevel_h = 'patchlevel.h';
96 return unless -e $patchlevel_h;
97 my $status = '';
98 {
99 my %defines;
100 open my $fh, '<', $patchlevel_h;
101 my @vers;
102 while (<$fh>) {
103 chomp;
104 next unless m!^#define! or m!!;
105 if ( m!^#define! ) {
106 my ($foo,$bar) = ( split /\s+/ )[1,2];
107 $defines{$foo} = $bar;
108 }
109 elsif ( m!\"RC\d+\"! ) {
110 $status = 'testing';
111 last;
112 }
113 }
114 unless ( $status ) {
115 $status = $defines{PERL_VERSION} % 2 ? 'unstable' : 'stable';
116 }
117 }
118 return $status;
119}