my $conf = $self->parent->parent->configure_object;
$stat->mk_accessors(qw/name version author distribution desc uri src license
- meta
+ meta min_perl
fetched_arch requires
ebuild_name ebuild_version ebuild_dir ebuild_file
portdir_overlay
}
$stat->requires(\@requires);
+ $stat->min_perl(CPANPLUS::Dist::Gentoo::Maps::perl_version_c2g(
+ eval { $self->meta->{requires}->{perl} }
+ ));
+
return $OK->();
}
push @requires, $atom;
}
+ my $min_perl = $stat->min_perl;
my $perl = CPANPLUS::Dist::Gentoo::Atom->new(
category => 'dev-lang',
name => 'perl',
+ (defined $min_perl ? (version => $min_perl, range => '>=') : ()),
);
+
@requires = CPANPLUS::Dist::Gentoo::Atom->fold($perl, @requires);
my $d = $stat->header;
return $v;
}
+=head2 C<perl_version_c2g $version>
+
+Converts a perl version as you can find it in prerequisites to a Gentoo version number.
+
+=cut
+
+sub perl_version_c2g {
+ my ($v) = @_;
+
+ return unless defined $v and $v =~ /^[0-9\.]+$/;
+
+ my @parts;
+ if (my ($version, $subversion) = $v =~ /^([0-9]+)\.(0[^\.]+)$/) {
+ my $len = length $subversion;
+ if (my $pad = $len % 3) {
+ $subversion .= '0' x (3 - $pad);
+ }
+ @parts = ($version, $subversion =~ /(.{1,3})/g);
+ } else {
+ @parts = split /\./, $v;
+ }
+
+ return join '.', map int, @parts;
+}
+
=head1 SEE ALSO
L<CPANPLUS::Dist::Gentoo>.
use strict;
use warnings;
-use Test::More tests => 10;
+use Test::More tests => 10 + 7;
use CPANPLUS::Dist::Gentoo::Maps;
is vc2g('1_.1._2'), '1_p1.2', "version_c2g('1_.1._2')";
is vc2g('1_.1_2'), '1_p1.2', "version_c2g('1_.1_2')";
is vc2g('1_.1_.2'), '1_p1.2', "version_c2g('1_.1_.2')";
+
+*pvc2g = \&CPANPLUS::Dist::Gentoo::Maps::perl_version_c2g;
+
+is pvc2g('5'), '5', "perl_version_c2g('5')";
+is pvc2g('5.1'), '5.1', "perl_version_c2g('5.1')";
+is pvc2g('5.01'), '5.10', "perl_version_c2g('5.01')";
+is pvc2g('5.10'), '5.10', "perl_version_c2g('5.10')";
+is pvc2g('5.1.2'), '5.1.2', "perl_version_c2g('5.1.2')";
+is pvc2g('5.01.2'), '5.1.2', "perl_version_c2g('5.01.2')";
+is pvc2g('5.01002'), '5.10.20', "perl_version_c2g('5.01002')";