r35292 - in /trunk/dh-make-perl/lib: Debian/AptContents.pm Debian/Control/FromCPAN.pm DhMakePerl.pm
dmn at users.alioth.debian.org
dmn at users.alioth.debian.org
Wed May 13 04:37:58 UTC 2009
Author: dmn
Date: Wed May 13 04:37:53 2009
New Revision: 35292
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=35292
Log:
AptContents::find_perl_module_package returns Debian::Dependency object
also an optional version argument is reflected in the returned
dependency.
it also supports core modules (returning dependency on perl-modules)
Modified:
trunk/dh-make-perl/lib/Debian/AptContents.pm
trunk/dh-make-perl/lib/Debian/Control/FromCPAN.pm
trunk/dh-make-perl/lib/DhMakePerl.pm
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=35292&op=diff
==============================================================================
--- trunk/dh-make-perl/lib/Debian/AptContents.pm (original)
+++ trunk/dh-make-perl/lib/Debian/AptContents.pm Wed May 13 04:37:53 2009
@@ -11,7 +11,7 @@
my $c = Debian::AptContents->new( { homedir => '~/.dh-make-perl' } );
my @pkgs = $c->find_file_packages('/usr/bin/foo');
- my @pkgs = $c->find_perl_module_packages('Foo::Bar');
+ my $dep = $c->find_perl_module_package('Foo::Bar');
=head1 TODO
@@ -30,9 +30,11 @@
)
);
-use Storable;
+use Debian::Dependency;
use File::Spec::Functions qw( catfile catdir splitpath );
use IO::Uncompress::Gunzip;
+use Module::CoreList ();
+use Storable;
=head1 CONSTRUCTOR
@@ -388,16 +390,25 @@
return @packages;
}
-=item find_perl_module_package
-
-Given Perl module name (e.g. Foo::Bar), returns a list of package names where
-that module was found. The list is sorted so that the most likely package is
-first.
+=item find_perl_module_package( $module, $version )
+
+Given Perl module name (e.g. Foo::Bar), returns a L<Debian::Dependency> object
+representing the required Debian package and version. If the module is a core
+one, suitable dependency on perl-modules is returned.
=cut
sub find_perl_module_package {
- my ( $self, $module ) = @_;
+ my ( $self, $module, $version ) = @_;
+
+ my $core_ver = Module::CoreList->first_release( $module, $version );
+
+ 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-modules', $core_ver );
+ }
my $module_file = $module;
$module_file =~ s|::|/|g;
@@ -411,7 +422,10 @@
else { return $a cmp $b; } # or 0?
} @matches;
- return $matches[0];
+ return Debian::Dependency->new( $matches[0], $version )
+ if @matches;
+
+ return;
}
1;
Modified: trunk/dh-make-perl/lib/Debian/Control/FromCPAN.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/lib/Debian/Control/FromCPAN.pm?rev=35292&op=diff
==============================================================================
--- trunk/dh-make-perl/lib/Debian/Control/FromCPAN.pm (original)
+++ trunk/dh-make-perl/lib/Debian/Control/FromCPAN.pm Wed May 13 04:37:53 2009
@@ -114,10 +114,9 @@
my $deps = Debian::Dependencies->new;
while( my($k,$v) = each %$src ) {
- my $pkg = $apt_contents->find_perl_module_package($k);
-
- $deps->add( Debian::Dependency->new( $pkg, $v || () ) )
- if $pkg;
+ my $pkg_dep = $apt_contents->find_perl_module_package( $k, $v );
+
+ $deps->add($pkg_dep) if $pkg_dep;
}
return $deps;
Modified: trunk/dh-make-perl/lib/DhMakePerl.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/lib/DhMakePerl.pm?rev=35292&op=diff
==============================================================================
--- trunk/dh-make-perl/lib/DhMakePerl.pm (original)
+++ trunk/dh-make-perl/lib/DhMakePerl.pm Wed May 13 04:37:53 2009
@@ -1030,16 +1030,19 @@
foreach my $module (@uses) {
- my $deb;
+ my $dep;
if ( $module eq 'perl' ) {
- $deb = 'perl';
+ $dep = Debian::Dependency->new( 'perl',
+ $self->nice_perl_ver( $dep_hash->{$module} ) );
}
elsif ($apt_contents) {
- $deb = $apt_contents->find_perl_module_package($module);
- }
-
- if ($deb) {
- print "+ $module found in $deb\n" if $self->cfg->verbose;
+ $dep = $apt_contents->find_perl_module_package( $module,
+ $dep_hash->{$module} );
+ }
+
+ if ($dep) {
+ print "+ $module found in " . $dep->pkg ."\n"
+ if $self->cfg->verbose;
}
else {
print "- $module not found in any package\n";
@@ -1053,36 +1056,14 @@
print " CPAN contains it in $dist\n";
print " substituting package name of $pkg\n";
- $deb = $pkg;
+ $dep = Debian::Dependency->new( $pkg, $dep_hash->{$module} );
}
else {
print " - it seems it is not available even via CPAN\n";
}
}
- if ($deb) {
- if ( exists $dep_hash->{$module} ) {
- my $v = $dep_hash->{$module};
- $v =~ s/^v//; # strip leading 'v' from version
-
- # perl versions need special handling
- if ( $module eq 'perl' ) {
- $v = $self->nice_perl_ver($v);
-
- # no point depending on ancient perl versions
- # perl is Priority: standard
- next
- if $AptPkg::Config::_config->system->versioning->compare(
- $v, $min_perl_version
- ) <= 0;
- }
-
- $debs += Debian::Dependency->new( $deb, $v );
- }
- else {
- $debs += Debian::Dependency->new($deb);
- }
- }
+ $debs->add($dep) if $dep;
}
return $debs, \@missing;
@@ -1992,20 +1973,13 @@
warn "Description: $short_desc\n";
}
elsif ($apt_contents) {
- my @possible_packages = $apt_contents->find_perl_module_package(
- $perlname);
-
- if ( $found = shift @possible_packages ) {
+ my $found = $apt_contents->find_perl_module_package($perlname);
+
+ if ($found) {
my $mod_name = $perlname =~ s/-/::/g;
warn "**********\n";
warn "NOTICE: the package '$found', available in APT repositories\n";
warn " already contains a module named $perlname\n";
-
- if ( @possible_packages > 1 ) {
- shift @possible_packages;
- warn "\n Other packages that contain similarly named modules are:\n";
- warn " - $_\n" for @possible_packages;
- }
}
}
More information about the Pkg-perl-cvs-commits
mailing list