Teach makemeta to use CPAN::Meta to generate both META.json and META.yml
authorChris 'BinGOs' Williams <chris@bingosnet.co.uk>
Sat, 26 Jan 2013 12:46:44 +0000 (12:46 +0000)
committerChris 'BinGOs' Williams <chris@bingosnet.co.uk>
Sat, 2 Feb 2013 13:41:23 +0000 (13:41 +0000)
Cross/Makefile-cross-SH
MANIFEST
META.json [new file with mode: 0644]
META.yml
Makefile.SH
Porting/makemeta
t/porting/regen.t

index 6307742..6a0237c 100644 (file)
@@ -772,7 +772,10 @@ extras.install: perl$(EXE_EXT)
        no-install install.perl install.man install.html
 
 META.yml:      Porting/makemeta Porting/Maintainers.pl Porting/Maintainers.pm
-       $(LDLIBPTH) ./miniperl -Ilib Porting/makemeta
+       $(LDLIBPTH) ./miniperl -Ilib Porting/makemeta META.yml
+
+META.json:     Porting/makemeta Porting/Maintainers.pl Porting/Maintainers.pm
+       $(LDLIBPTH) ./miniperl -Ilib Porting/makemeta META.json
 
 install-strip:
        $(MAKE) STRIPFLAGS=-s install DESTDIR="$(DESTDIR)"
index f4e6190..ba687e7 100644 (file)
--- a/MANIFEST
+++ b/MANIFEST
@@ -4512,6 +4512,7 @@ MANIFEST                  This list of files
 mathoms.c                      A home for binary-compatible code artifacts
 metaconfig.h                   Control file for the metaconfig process
 metaconfig.SH                  Control file for the metaconfig process
+META.json                      Distribution meta-data in JSON
 META.yml                       Distribution meta-data in YAML
 mg.c                           Magic code
 mg.h                           Magic header
diff --git a/META.json b/META.json
new file mode 100644 (file)
index 0000000..bb3a8b9
--- /dev/null
+++ b/META.json
@@ -0,0 +1,135 @@
+{
+   "abstract" : "The Perl 5 language interpreter",
+   "author" : [
+      "perl5-porters@perl.org"
+   ],
+   "dynamic_config" : 1,
+   "generated_by" : "CPAN::Meta version 2.120921",
+   "license" : [
+      "perl_5"
+   ],
+   "meta-spec" : {
+      "version" : 2
+   },
+   "name" : "perl",
+   "no_index" : {
+      "directory" : [
+         "cpan",
+         "dist/Attribute-Handlers",
+         "dist/autouse",
+         "dist/base",
+         "dist/bignum",
+         "dist/Carp",
+         "dist/constant",
+         "dist/Cwd",
+         "dist/Data-Dumper",
+         "dist/Devel-SelfStubber",
+         "dist/Dumpvalue",
+         "dist/Env",
+         "dist/ExtUtils-CBuilder",
+         "dist/ExtUtils-Command",
+         "dist/ExtUtils-Install",
+         "dist/ExtUtils-Manifest",
+         "dist/ExtUtils-ParseXS",
+         "dist/Filter-Simple",
+         "dist/I18N-Collate",
+         "dist/I18N-LangTags",
+         "dist/if",
+         "dist/IO/",
+         "dist/lib/",
+         "dist/Locale-Maketext",
+         "dist/Math-BigInt",
+         "dist/Math-BigInt-FastCalc",
+         "dist/Math-BigRat",
+         "dist/Module-CoreList",
+         "dist/Net-Ping",
+         "dist/Safe",
+         "dist/Search-Dict",
+         "dist/SelfLoader",
+         "dist/Storable",
+         "dist/Term-Complete",
+         "dist/Term-ReadLine",
+         "dist/Text-Abbrev",
+         "dist/Thread-Queue",
+         "dist/Thread-Semaphore",
+         "dist/threads",
+         "dist/threads-shared",
+         "dist/Tie-File",
+         "dist/XSLoader",
+         "lib/version",
+         "mad",
+         "win32"
+      ],
+      "file" : [
+         "autodoc.pl",
+         "dist/IO/ChangeLog",
+         "dist/IO/hints/sco.pl",
+         "dist/IO/IO.pm",
+         "dist/IO/IO.xs",
+         "dist/IO/lib/IO/Dir.pm",
+         "dist/IO/lib/IO/File.pm",
+         "dist/IO/lib/IO/Handle.pm",
+         "dist/IO/lib/IO/Pipe.pm",
+         "dist/IO/lib/IO/Poll.pm",
+         "dist/IO/lib/IO/Seekable.pm",
+         "dist/IO/lib/IO/Select.pm",
+         "dist/IO/lib/IO/Socket.pm",
+         "dist/IO/lib/IO/Socket/INET.pm",
+         "dist/IO/lib/IO/Socket/UNIX.pm",
+         "dist/IO/Makefile.PL",
+         "dist/IO/poll.c",
+         "dist/IO/poll.h",
+         "dist/IO/README",
+         "dist/IO/t/cachepropagate-tcp.t",
+         "dist/IO/t/cachepropagate-udp.t",
+         "dist/IO/t/cachepropagate-unix.t",
+         "dist/IO/t/IO.t",
+         "dist/IO/t/io_const.t",
+         "dist/IO/t/io_dir.t",
+         "dist/IO/t/io_dup.t",
+         "dist/IO/t/io_file.t",
+         "dist/IO/t/io_file_export.t",
+         "dist/IO/t/io_linenum.t",
+         "dist/IO/t/io_multihomed.t",
+         "dist/IO/t/io_pipe.t",
+         "dist/IO/t/io_poll.t",
+         "dist/IO/t/io_sel.t",
+         "dist/IO/t/io_sock.t",
+         "dist/IO/t/io_taint.t",
+         "dist/IO/t/io_tell.t",
+         "dist/IO/t/io_udp.t",
+         "dist/IO/t/io_unix.t",
+         "dist/IO/t/io_utf8.t",
+         "dist/IO/t/io_utf8argv.t",
+         "dist/IO/t/io_xs.t",
+         "dist/lib/lib_pm.PL",
+         "dist/lib/Makefile.PL",
+         "dist/lib/t/01lib.t",
+         "lib/Exporter.pm",
+         "lib/Exporter.t",
+         "lib/Exporter/Heavy.pm",
+         "lib/unicore/mktables",
+         "lib/version.pm",
+         "lib/version.pod",
+         "pod/perlfilter.pod",
+         "pod/perlpodstyle.pod",
+         "Porting/Maintainers.pm",
+         "Porting/perldelta_template.pod",
+         "TestInit.pm"
+      ]
+   },
+   "release_status" : "unstable",
+   "resources" : {
+      "bugtracker" : {
+         "web" : "http://rt.perl.org/perlbug/"
+      },
+      "homepage" : "http://www.perl.org/",
+      "license" : [
+         "http://dev.perl.org/licenses/"
+      ],
+      "repository" : {
+         "url" : "http://perl5.git.perl.org/"
+      }
+   },
+   "version" : "5.017009"
+}
index ea45883..dfd7082 100644 (file)
--- a/META.yml
+++ b/META.yml
@@ -1,15 +1,15 @@
-name: perl
-version: 5.017009
-abstract: The Perl 5 language interpreter
-author: perl5-porters@perl.org
+---
+abstract: 'The Perl 5 language interpreter'
+author:
+  - perl5-porters@perl.org
+build_requires: {}
+dynamic_config: 1
+generated_by: 'CPAN::Meta version 2.120921, CPAN::Meta::Converter version 2.120921'
 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: Porting/makemeta
+meta-spec:
+  url: http://module-build.sourceforge.net/META-spec-v1.4.html
+  version: 1.4
+name: perl
 no_index:
   directory:
     - cpan
@@ -113,3 +113,9 @@ no_index:
     - Porting/Maintainers.pm
     - Porting/perldelta_template.pod
     - TestInit.pm
+resources:
+  bugtracker: http://rt.perl.org/perlbug/
+  homepage: http://www.perl.org/
+  license: http://dev.perl.org/licenses/
+  repository: http://perl5.git.perl.org/
+version: 5.017009
index 31cacc8..f934551 100755 (executable)
@@ -1187,10 +1187,13 @@ regen_headers regen-headers:    FORCE
        -perl regen.pl -v
        -perl regen/uconfig_h.pl -v
 
-regen_meta regen-meta:  META.yml
+regen_meta regen-meta:  META.yml META.json
 
 META.yml:   FORCE
-       PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) -Ilib Porting/makemeta
+       PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) -Ilib Porting/makemeta Meta.yml
+
+META.json:   FORCE
+       PATH="`pwd`:${PATH}" PERL5LIB="`pwd`/lib" $(RUN_PERL) -Ilib Porting/makemeta Meta.json
 
 
 regen_all regen-all: regen regen_meta
index 1dd644c..882540c 100644 (file)
@@ -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;
+}
index 221ff17..ec92dd3 100644 (file)
@@ -18,9 +18,9 @@ if ( $^O eq "VMS" ) {
 
 my $in_regen_pl = 23; # I can't see a clean way to calculate this automatically.
 my @files = qw(perly.act perly.h perly.tab keywords.c keywords.h uconfig.h);
-my @progs = qw(Porting/makemeta regen/regcharclass.pl regen/mk_PL_charclass.pl);
+my @progs = qw(regen/regcharclass.pl regen/mk_PL_charclass.pl);
 
-plan (tests => $in_regen_pl + @files + @progs);
+plan (tests => $in_regen_pl + @files + @progs + 2);
 
 OUTER: foreach my $file (@files) {
     open my $fh, '<', $file or die "Can't open $file: $!";
@@ -47,3 +47,7 @@ OUTER: foreach my $file (@files) {
 foreach (@progs, 'regen.pl') {
   system "$^X $_ --tap";
 }
+
+foreach ( 'META.yml', 'META.json' ) {
+  system "$^X Porting/makemeta --tap $_";
+}