From 93da707f3ca60e25185caf73056ffc6acac7f0fc Mon Sep 17 00:00:00 2001 From: "H.Merijn Brand - Tux" Date: Mon, 15 Apr 2013 00:25:33 +0200 Subject: [PATCH] The Lancaster Consensus changes the META-2.0 to 1.4 conversion --- sandbox/genMETA.pl | 4 ++-- sandbox/genMETA.pm | 30 ++++++++++++++++++++++++++++-- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/sandbox/genMETA.pl b/sandbox/genMETA.pl index d46bb58..3f79b16 100755 --- a/sandbox/genMETA.pl +++ b/sandbox/genMETA.pl @@ -59,8 +59,8 @@ test_requires: Test::More: 0.88 Test::NoWarnings: 0 recommends: - perl: 5.016002 - Data::Dumper: 2.139 + perl: 5.016003 + Data::Dumper: 2.145 Perl::Tidy: 0 test_recommends: Test::More: 0.98 diff --git a/sandbox/genMETA.pm b/sandbox/genMETA.pm index dfaa812..7cdf019 100644 --- a/sandbox/genMETA.pm +++ b/sandbox/genMETA.pm @@ -326,14 +326,40 @@ sub fix_meta if (my $tp = delete $yml->{prereqs}{test}) { foreach my $phase (keys %{$tp}) { my $p = $tp->{$phase}; - $yml->{runtime}{$phase}{$_} //= $p->{$_} for keys %{$p}; + #DDumper { $phase => $p }; + $yml->{prereqs}{runtime}{$phase}{$_} //= $p->{$_} for keys %{$p}; } } + + # Optional features in 1.4 knows requires, but not recommends. + # The Lancaster Consensus moves 2.0 optional recommends promote to + # requires in 1.4 + if (my $of = $yml->{optional_features}) { + foreach my $f (keys %$of) { + if (my $r = delete $of->{$f}{prereqs}{runtime}{recommends}) { + $of->{$f}{requires} = $r; + } + } + } + # runtime and test_requires are unknown as top-level in 1.4 + foreach my $phase (qw( xuntime test_requires )) { + if (my $p = delete $yml->{$phase}) { + foreach my $f (keys %$p) { + $yml->{$f}{$_} ||= $p->{$f}{$_} for keys %{$p->{$f}}; + } + } + } + #DDumper $yml; # This does NOT create a correct YAML id the source does not comply! $yml = CPAN::Meta::Converter->new ($yml)->convert (version => "1.4"); + $yml->{requires}{perl} //= $jsn->{prereqs}{runtime}{requires}{perl} + // $self->{h}{requires}{perl} + // ""; + $yml->{build_requires} && !keys %{$yml->{build_requires}} and + delete $yml->{build_requires}; #DDumper $yml; - exit; + #exit; @my == 1 && open my $my, ">", $yf or croak "Cannot update $yf\n"; print $my Dump $yml; # @{$self->{yml}}; -- 2.11.4.GIT