r56139 - in /trunk/dh-make-perl: debian/changelog lib/Debian/AptContents.pm t/core-modules.t
dmn at users.alioth.debian.org
dmn at users.alioth.debian.org
Thu Apr 15 20:31:12 UTC 2010
Author: dmn
Date: Thu Apr 15 20:31:04 2010
New Revision: 56139
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=56139
Log:
rewrite core module dependency discovery
Closes: #571646 -- "Depends: perl (>= 5.11.4)" as result of is_core_module()
Thanks to Josef Kutej
Modified:
trunk/dh-make-perl/debian/changelog
trunk/dh-make-perl/lib/Debian/AptContents.pm
trunk/dh-make-perl/t/core-modules.t
Modified: trunk/dh-make-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/debian/changelog?rev=56139&op=diff
==============================================================================
--- trunk/dh-make-perl/debian/changelog (original)
+++ trunk/dh-make-perl/debian/changelog Thu Apr 15 20:31:04 2010
@@ -15,6 +15,9 @@
* don't break perl versions like '5.9.1'
* core module checks now return perl package versions suitable for
dependencies. Closes: #571642. Thanks to Josef Kutej.
+ * rewrite core module dependency discovery
+ Closes: #571646 -- "Depends: perl (>= 5.11.4)" as result of
+ is_core_module(); Thanks to Josef Kutej
-- Damyan Ivanov <dmn at debian.org> Tue, 09 Mar 2010 08:46:09 +0200
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=56139&op=diff
==============================================================================
--- trunk/dh-make-perl/lib/Debian/AptContents.pm (original)
+++ trunk/dh-make-perl/lib/Debian/AptContents.pm Thu Apr 15 20:31:04 2010
@@ -30,8 +30,10 @@
)
);
+use Config;
use Debian::Dependency;
use Debian::Version qw(deb_ver_cmp);
+use DhMakePerl::Utils qw(nice_perl_ver);
use File::Spec::Functions qw( catfile catdir splitpath );
use IO::Uncompress::Gunzip;
use List::MoreUtils qw(uniq);
@@ -392,51 +394,74 @@
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 as released by Debian, return undef.
-
-Currently Debian has only two releases of Perl: 5.8.8 (5.008008) and 5.10
-(5.010000).
-
-=cut
-
-our @debian_perls = qw( 5.008008 5.010000 5.010001 );
+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 ) = @_;
- # see if the module is included in perl core
- my $core_ver;
- for my $v (@debian_perls) {
- my $core = Module::CoreList->find_version($v);
- next unless exists $core->{$module}; # not in that perl version
-
- # reaching here, the module is in the core version in $v
- # if we don't need a particular version, we are done
- unless ( defined($version) ) {
- $core_ver = $v;
- last;
- }
-
- # OTOH, if we do need a particular version, but
- # the core module has none, try next core release
- my $ver = $core->{$module};
- next unless defined($ver);
-
- # if the core module version is sufficiently new, we're done
- if ( deb_ver_cmp( $ver, $version ) >= 0 ) {
- $core_ver = $v;
- last;
- }
- }
-
- if ($core_ver) {
- $core_ver = version->new($core_ver); # v5.9.2
- ( $core_ver = $core_ver->normal ) =~ s/^v//; # "5.9.2"
-
- return Debian::Dependency->new( 'perl', $core_ver );
+ 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
@@ -449,6 +474,13 @@
representing the required Debian package and version. If the module is a core
one, suitable dependency on perl is returned.
+If the package is also available in a separate package, an alternative
+dependency is returned.
+
+In case the version of the currently running Perl interpreter is lower than the
+version in which the wanted module is available in core, the separate package
+is preferred. Otherwise the perl dependency is the first alternative.
+
=cut
sub find_perl_module_package {
@@ -457,10 +489,6 @@
# see if the module is included in perl core
my $core_dep = $self->find_core_perl_dependency( $module, $version );
- return $core_dep if defined($core_dep);
-
- # not a core module (or at least not in any perl release available in
- # Debian)
# try module packages
my $module_file = $module;
$module_file =~ s|::|/|g;
@@ -474,10 +502,31 @@
else { return $a cmp $b; } # or 0?
} @matches;
- return Debian::Dependency->new( $matches[0], $version )
+ my $direct_dep;
+ $direct_dep = Debian::Dependency->new( $matches[0], $version )
if @matches;
- return;
+ my $running_perl = $Config::Config{version};
+
+ if ($core_dep) {
+ if ($direct_dep) {
+ # both in core and in a package.
+ if( deb_ver_cmp($running_perl, $core_dep->ver) >= 0 ) {
+ return Debian::Dependency->new("$core_dep | $direct_dep");
+ }
+ else {
+ return Debian::Dependency->new("$direct_dep | $core_dep");
+ }
+ }
+ else {
+ # only in core
+ return $core_dep;
+ }
+ }
+ else {
+ # maybe in a package
+ return $direct_dep;
+ }
}
1;
@@ -496,7 +545,7 @@
=over 4
-=item Copyright (C) 2008, 2009 Damyan Ivanov <dmn at debian.org>
+=item Copyright (C) 2008, 2009, 2010 Damyan Ivanov <dmn at debian.org>
=back
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=56139&op=diff
==============================================================================
--- trunk/dh-make-perl/t/core-modules.t (original)
+++ trunk/dh-make-perl/t/core-modules.t Thu Apr 15 20:31:04 2010
@@ -3,7 +3,7 @@
use strict;
use warnings;
-use Test::More tests => 5;
+use Test::More tests => 7;
use Debian::AptContents;
@@ -26,3 +26,13 @@
# try a bogus module
is( $apt->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 ,
+ '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' ),
+ undef, 'Module::Build 0.3603 is not in Debian\'s perl' );
More information about the Pkg-perl-cvs-commits
mailing list