summaryrefslogtreecommitdiff
path: root/Porting/makemeta
diff options
context:
space:
mode:
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>2013-01-26 12:46:44 +0000
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>2013-02-02 13:41:23 +0000
commitbfc0a3e7042c488530b56956cb61c2000b4e0efa (patch)
tree31e20ff77abc959dc407fb3f0ecfc6374e49ad03 /Porting/makemeta
parentba9b1d719d13422abb21d059bd732a760a184388 (diff)
downloadperl-bfc0a3e7042c488530b56956cb61c2000b4e0efa.tar.gz
Teach makemeta to use CPAN::Meta to generate both META.json and META.yml
Diffstat (limited to 'Porting/makemeta')
-rw-r--r--Porting/makemeta110
1 files changed, 77 insertions, 33 deletions
diff --git a/Porting/makemeta b/Porting/makemeta
index 1dd644ca8a..882540cfb6 100644
--- a/Porting/makemeta
+++ b/Porting/makemeta
@@ -1,36 +1,69 @@
#!./perl -w
# this script must be run by the current perl to get perl's version right
#
-# Create a META.yml file in the current directory. Must be run from the
+# Create META.yml and META.json files in the current directory. Must be run from the
# root directory of a perl source tree.
use strict;
use warnings;
-use lib "Porting";
-use File::Basename qw( dirname );
+my $opts = {
+ 'META.yml' => { version => '1.4' },
+ 'META.json' => { version => '2' },
+};
+
+my $file = shift;
+die "Must specify META.yml or META.json" unless $file and defined $opts->{$file};
+my $status = _determine_status();
+
+my $distmeta = {
+ 'version' => $],
+ 'name' => 'perl',
+ 'author' => [
+ 'perl5-porters@perl.org'
+ ],
+ 'license' => [
+ 'perl_5'
+ ],
+ 'abstract' => 'The Perl 5 language interpreter',
+ 'release_status' => $status,
+ 'dynamic_config' => 1,
+ 'resources' => {
+ 'repository' => {
+ 'url' => 'http://perl5.git.perl.org/'
+ },
+ 'homepage' => 'http://www.perl.org/',
+ 'bugtracker' => {
+ 'web' => 'http://rt.perl.org/perlbug/'
+ },
+ 'license' => [
+ 'http://dev.perl.org/licenses/'
+ ],
+ },
+};
+
+use lib "Porting";
+use File::Basename qw( dirname );
+use CPAN::Meta;
BEGIN {
# Get function prototypes
require 'regen/regen_lib.pl';
}
-
-my $file = "META.yml";
-
use Maintainers qw(%Modules get_module_files get_module_pat);
my @CPAN = grep { $Modules{$_}{CPAN} } keys %Modules;
my @files = ('autodoc.pl', 'lib/unicore/mktables', 'TestInit.pm',
- 'Porting/Maintainers.pm', 'Porting/perldelta_template.pod',
- map { get_module_files($_) } @CPAN);
+ 'Porting/Maintainers.pm', 'Porting/perldelta_template.pod',
+ map { get_module_files($_) } @CPAN);
my @dirs = ('cpan', 'win32', 'mad', grep { -d $_ && $_ !~ /^cpan/ } map { get_module_pat($_) } @CPAN);
my %dirs;
@dirs{@dirs} = ();
-@files = map { " - $_" }
+@files =
grep {
my $d = $_;
my $previous_d = '';
@@ -42,34 +75,45 @@ my %dirs;
# if $d is "." it means we tried every parent dir of the file and none
# of them were in the private list
-
+
$d eq "." || $d eq $previous_d;
}
sort { lc $a cmp lc $b } @files;
-@dirs = map { " - $_" } sort { lc $a cmp lc $b } @dirs;
-
-my $fh = open_new($file);
+@dirs = sort { lc $a cmp lc $b } @dirs;
-local $" = "\n";
-print $fh <<"EOI";
-name: perl
-version: $]
-abstract: The Perl 5 language interpreter
-author: perl5-porters\@perl.org
-license: perl
-resources:
- homepage: http://www.perl.org/
- bugtracker: http://rt.perl.org/perlbug/
- license: http://dev.perl.org/licenses/
- repository: http://perl5.git.perl.org/
-distribution_type: core
-generated_by: $0
-no_index:
- directory:
-@dirs
- file:
-@files
-EOI
+$distmeta->{no_index}->{file} = \@files;
+$distmeta->{no_index}->{directory} = \@dirs;
+my $meta = CPAN::Meta->create( $distmeta );
+my $fh = open_new($file);
+print $fh $meta->as_string( $opts->{$file} );
close_and_rename($fh);
+exit 0;
+
+sub _determine_status {
+ my $patchlevel_h = 'patchlevel.h';
+ return unless -e $patchlevel_h;
+ my $status = '';
+ {
+ my %defines;
+ open my $fh, '<', $patchlevel_h;
+ my @vers;
+ while (<$fh>) {
+ chomp;
+ next unless m!^#define! or m!!;
+ if ( m!^#define! ) {
+ my ($foo,$bar) = ( split /\s+/ )[1,2];
+ $defines{$foo} = $bar;
+ }
+ elsif ( m!\"RC\d+\"! ) {
+ $status = 'testing';
+ last;
+ }
+ }
+ unless ( $status ) {
+ $status = $defines{PERL_VERSION} % 2 ? 'unstable' : 'stable';
+ }
+ }
+ return $status;
+}