r56166 - in /trunk/dh-make-perl: lib/Debian/AptContents.pm lib/DhMakePerl/Utils.pm t/core-modules.t
dmn at users.alioth.debian.org
dmn at users.alioth.debian.org
Fri Apr 16 07:25:42 UTC 2010
Author: dmn
Date: Fri Apr 16 07:25:29 2010
New Revision: 56166
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=56166
Log:
move find_core_perl_dependency and core_module_perls to Utils
AptContents is not the right place for them, they aren't tied to APT, but to
Module::CoreList
Modified:
trunk/dh-make-perl/lib/Debian/AptContents.pm
trunk/dh-make-perl/lib/DhMakePerl/Utils.pm
trunk/dh-make-perl/t/core-modules.t
Modified: trunk/dh-make-perl/lib/Debian/AptContents.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/lib/Debian/AptContents.pm?rev=56166&op=diff
==============================================================================
--- trunk/dh-make-perl/lib/Debian/AptContents.pm (original)
+++ trunk/dh-make-perl/lib/Debian/AptContents.pm Fri Apr 16 07:25:29 2010
@@ -33,7 +33,7 @@
use Config;
use Debian::Dependency;
use Debian::Version qw(deb_ver_cmp);
-use DhMakePerl::Utils qw(nice_perl_ver);
+use DhMakePerl::Utils qw(find_core_perl_dependency);
use File::Spec::Functions qw( catfile catdir splitpath );
use IO::Uncompress::Gunzip;
use List::MoreUtils qw(uniq);
@@ -394,80 +394,6 @@
return @packages;
}
-=item core_module_perls I<module>[, I<min-version>]
-
-Returns a list of Perl versions that have I<module>. If I<min-version> is
-given, the list contains only Perl versions containing I<module> at least
-version I<min-version>.
-
-=cut
-
-sub core_module_perls {
- my( $module, $version ) = @_;
-
- my @ret;
-
- $version = version->new($version) if $version;
-
- for my $v(
- sort keys %Module::CoreList::version ){
-
- next unless exists $Module::CoreList::version{$v}{$module};
-
- my $found = $Module::CoreList::version{$v}{$module};
-
- push @ret, $v
- if not defined($version)
- or $found and version->new($found) >= $version;
- }
-
- return @ret;
-}
-
-=item find_core_perl_dependency( $module[, $version] )
-
-return a dependency on perl containing the required module version. If the
-module is not available in any perl released by Debian, return undef.
-
-=cut
-
-our %debian_perl = (
- '5.8' => {
- min => '5.8.8',
- max => '5.8.8',
- },
- '5.10' => {
- min => '5.10.0',
- max => '5.10.1',
- },
-);
-
-sub find_core_perl_dependency {
- my ( $self, $module, $version ) = @_;
-
- my $perl_dep;
-
- my @perl_releases = core_module_perls( $module, $version );
-
- for my $v (@perl_releases) {
- $v = nice_perl_ver($v);
-
- $v =~ /^(\d+\.\d+)(?:\.|$)/;
- my $major = $1 or die "[$v] is a strange version";
-
- # we want to avoid depending on things like 5.8.9 which aren't in
- # Debian and can contain stuff newer than in 5.10.0
- if ( $debian_perl{$major}
- and deb_ver_cmp( $debian_perl{$major}{max}, $v ) >= 0 )
- {
- return Debian::Dependency->new( 'perl', $v );
- }
- }
-
- # not a core module
- return undef;
-}
-
=item find_perl_module_package( $module, $version )
Given Perl module name (e.g. Foo::Bar), returns a L<Debian::Dependency> object
@@ -487,7 +413,7 @@
my ( $self, $module, $version ) = @_;
# see if the module is included in perl core
- my $core_dep = $self->find_core_perl_dependency( $module, $version );
+ my $core_dep = find_core_perl_dependency( $module, $version );
# try module packages
my $module_file = $module;
Modified: trunk/dh-make-perl/lib/DhMakePerl/Utils.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/lib/DhMakePerl/Utils.pm?rev=56166&op=diff
==============================================================================
--- trunk/dh-make-perl/lib/DhMakePerl/Utils.pm (original)
+++ trunk/dh-make-perl/lib/DhMakePerl/Utils.pm Fri Apr 16 07:25:29 2010
@@ -13,11 +13,16 @@
=cut
-our @EXPORT_OK = qw( find_cpan_module is_core_module nice_perl_ver );
+our @EXPORT_OK = qw( find_cpan_module
+ is_core_module
+ nice_perl_ver
+ find_core_perl_dependency );
use base Exporter;
use Module::CoreList ();
+use Debian::Dependency;
+use Debian::Version qw(deb_ver_cmp);
=head1 FUNCTIONS
@@ -116,6 +121,80 @@
return $v;
}
+=item core_module_perls I<module>[, I<min-version>]
+
+Returns a list of Perl versions that have I<module>. If I<min-version> is
+given, the list contains only Perl versions containing I<module> at least
+version I<min-version>.
+
+=cut
+
+sub core_module_perls {
+ my( $module, $version ) = @_;
+
+ my @ret;
+
+ $version = version->new($version) if $version;
+
+ for my $v(
+ sort keys %Module::CoreList::version ){
+
+ next unless exists $Module::CoreList::version{$v}{$module};
+
+ my $found = $Module::CoreList::version{$v}{$module};
+
+ push @ret, $v
+ if not defined($version)
+ or $found and version->new($found) >= $version;
+ }
+
+ return @ret;
+}
+
+=item find_core_perl_dependency( $module[, $version] )
+
+return a dependency on perl containing the required module version. If the
+module is not available in any perl released by Debian, return undef.
+
+=cut
+
+our %debian_perl = (
+ '5.8' => {
+ min => '5.8.8',
+ max => '5.8.8',
+ },
+ '5.10' => {
+ min => '5.10.0',
+ max => '5.10.1',
+ },
+);
+
+sub find_core_perl_dependency {
+ my ( $module, $version ) = @_;
+
+ my $perl_dep;
+
+ my @perl_releases = core_module_perls( $module, $version );
+
+ for my $v (@perl_releases) {
+ $v = nice_perl_ver($v);
+
+ $v =~ /^(\d+\.\d+)(?:\.|$)/;
+ my $major = $1 or die "[$v] is a strange version";
+
+ # we want to avoid depending on things like 5.8.9 which aren't in
+ # Debian and can contain stuff newer than in 5.10.0
+ if ( $debian_perl{$major}
+ and deb_ver_cmp( $debian_perl{$major}{max}, $v ) >= 0 )
+ {
+ return Debian::Dependency->new( 'perl', $v );
+ }
+ }
+
+ # not a core module
+ return undef;
+}
+
=back
=head1 COPYRIGHT & LICENSE
Modified: trunk/dh-make-perl/t/core-modules.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/t/core-modules.t?rev=56166&op=diff
==============================================================================
--- trunk/dh-make-perl/t/core-modules.t (original)
+++ trunk/dh-make-perl/t/core-modules.t Fri Apr 16 07:25:29 2010
@@ -5,34 +5,32 @@
use Test::More tests => 7;
-use Debian::AptContents;
+use DhMakePerl::Utils qw(find_core_perl_dependency);
-my $apt = 'Debian::AptContents';
-
-is( $apt->find_core_perl_dependency('Module::CoreList'), 'perl (>= 5.10.0)',
+is( find_core_perl_dependency('Module::CoreList'), 'perl (>= 5.10.0)',
'Module::CoreList is in 5.10' );
-is( $apt->find_core_perl_dependency( 'Module::CoreList', '2.12' ), 'perl (>= 5.10.0)',
+is( find_core_perl_dependency( 'Module::CoreList', '2.12' ), 'perl (>= 5.10.0)',
'Module::CoreList 2.12 is in 5.10' );
# 2.17 is in 5.10.1, which is not in Debian
-is( $apt->find_core_perl_dependency( 'Module::CoreList', '2.17' ), 'perl (>= 5.10.1)',
+is( find_core_perl_dependency( 'Module::CoreList', '2.17' ), 'perl (>= 5.10.1)',
'Module::CoreList 2.17 is in 5.10.1' );
# try with an impossibly high version that should never exist
-is( $apt->find_core_perl_dependency( 'Module::CoreList', '999999.9' ), undef,
+is( find_core_perl_dependency( 'Module::CoreList', '999999.9' ), undef,
'Module::CoreList 999999.9 is nowhere' );
# try a bogus module
-is( $apt->find_core_perl_dependency( 'Foo::Bar', undef ), undef,
+is( find_core_perl_dependency( 'Foo::Bar', undef ), undef,
'Foo::Bar is not in core' );
# try a version that is not in Debian's perl
# this will fail when Debian's perl is sufficiently new
-is( $apt->find_core_perl_dependency( 'Module::CoreList', '2.19' ), undef ,
+is( find_core_perl_dependency( 'Module::CoreList', '2.19' ), undef ,
'Module::CoreList 2.19 is not in Debian\'s perl' );
# M::B 0.3603 is in perl 5.11.4
# perl 5.10.1 has M:B 0.340201 which may fool us
-is( $apt->find_core_perl_dependency( 'Module::Build', '0.3603' ),
+is( find_core_perl_dependency( 'Module::Build', '0.3603' ),
undef, 'Module::Build 0.3603 is not in Debian\'s perl' );
More information about the Pkg-perl-cvs-commits
mailing list