Skip Menu |

This queue is for tickets about the cpan2rpm CPAN distribution.

Report information
The Basics
Id: 24502
Status: open
Priority: 0/
Queue: cpan2rpm

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

Bug Information
Severity: Wishlist
Broken in: 2.028
Fixed in: (no value)



Subject: Does not read metadata from META.yml
CPAN distributions contain a META.yml file containing such information as author and version. cpan2rpm ought to read this file in preference of trying to parse out data from a Makefile.PL, because the former is present in all CPAN dists, not just those using EU::MM. I shall take a look at the code; if it looks an easy fix expect a patch submission.. -- Paul Evans
This patch works for me. Just use: patch -p0 cpan2rpm < meta-yml.patch Matt
--- cpan2rpm 2008-04-16 11:31:28.000000000 -0400 +++ cpan2rpm 2008-04-16 11:32:31.000000000 -0400 @@ -29,6 +29,7 @@ use Getopt::Long; use Sys::Hostname; use Pod::Text; +use YAML; my ($ME, $RPM, $TMPDIR, %RPMDIR, $CWD, %info, %meta, $ARGS); @@ -389,12 +390,15 @@ chdir $info->{evaldir} || die "get_meta(): $!"; + my $METAYML = "$info->{evaldir}/META.yml"; + $METAYML = undef unless -e $METAYML; $_ = "$info->{evaldir}/Build.PL"; $_ = "$info->{evaldir}/Makefile.PL" unless -e; die qq/No PL file [$_] in tarball/ unless -e; die qq/Cannot read PL file [$_]/ unless -r; ($info->{PL} = $_) =~ s|.*/||; + # we want to protect us from exit()ing but without modifying the # actual Makefile.PL since we may be operating in a source directory @@ -456,7 +460,20 @@ # map Build.PL hash keys to MakeMaker's - if ($info->{PL} =~ /^Build/) { + if (defined($METAYML)) { + print "Using bundled META.yml for meta info ...", "\n"; + my ($yml) = YAML::LoadFile($METAYML); + my %y2m = qw/ + requires PREREQ_PM + name NAME + author AUTHOR + version VERSION + dist_version_from VERSION_FROM + /; + $meta{$y2m{$_}} = $yml->{$_} for keys %y2m; + $meta{NAME} =~ s/-/::/g; + } + elsif ($info->{PL} =~ /^Build/) { my %b2m = qw/ requires PREREQ_PM module_name NAME @@ -475,6 +492,9 @@ for (keys %$deps) { my $use = "use $_"; $use .= " $deps->{$_}" if $deps->{$_}; + if ($_ eq 'perl') { + $use = "use $deps->{$_}"; + } local $^W = 0; $@ = ""; eval $use;
Here's another patch... uses YAML::Syck and won't clobber anything... Will fail if no YAML::Syck or META.yml.
--- cpan2rpm 2008-11-12 15:08:06.000000000 -0500 +++ cpan2rpm 2008-11-21 15:29:02.000000000 -0500 @@ -370,6 +370,26 @@ print "Tarball extraction: [$f]\n"; $info->{evaldir} = untar($f); } + eval { use YAML::Syck }; + if ( $@ ) { + warn "Not parsing META.yml: $@"; + } + else { + my $file = join '/', $info->{evaldir}, 'META.yml'; + if ( -e $file ) { + my $meta = LoadFile($file); + foreach ( keys %$meta ) { + $info->{$_} = $meta->{$_} unless defined $info->{$_}; + } + foreach my $k ( qw( provides requires ) ) { + $info->{$k} = [ map {"perl($_)"} keys %{ $info->{$k} } ] + if ref $info->{$k} eq 'HASH'; + } + } + else { + warn "Not parsing missing META.yml"; + } + } eval "use File::Find"; if ($@) {