r56598 - in /trunk/dh-make-perl: Changes TODO lib/Debian/Control/FromCPAN.pm lib/DhMakePerl/Utils.pm t/split_version_relation.t

dmn at users.alioth.debian.org dmn at users.alioth.debian.org
Tue Apr 20 18:25:10 UTC 2010


Author: dmn
Date: Tue Apr 20 18:25:03 2010
New Revision: 56598

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=56598
Log:
FromCPAN: handle version relation in META dependencies

Closes: #571632

Added:
    trunk/dh-make-perl/t/split_version_relation.t
Modified:
    trunk/dh-make-perl/Changes
    trunk/dh-make-perl/TODO
    trunk/dh-make-perl/lib/Debian/Control/FromCPAN.pm
    trunk/dh-make-perl/lib/DhMakePerl/Utils.pm

Modified: trunk/dh-make-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/Changes?rev=56598&op=diff
==============================================================================
--- trunk/dh-make-perl/Changes (original)
+++ trunk/dh-make-perl/Changes Tue Apr 20 18:25:03 2010
@@ -2,3 +2,5 @@
     POD: drop "--" in front of the commands.
     refresh: ensure ->rules is there before attempting to fiddle quilt
         integration
+
+    Add support for version relations in META

Modified: trunk/dh-make-perl/TODO
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/TODO?rev=56598&op=diff
==============================================================================
--- trunk/dh-make-perl/TODO (original)
+++ trunk/dh-make-perl/TODO Tue Apr 20 18:25:03 2010
@@ -31,6 +31,3 @@
 * #536838: Incorrect assumptions about perl module version -> debian package
   version. Some way of figuring out that libfoo-perl 3.42 contains Bar::Baz
   4.23 is needed. while not common, version discrepacy is very annoying.
-* #571632: META.yml dependency numbers with > or >= breaks the control
-  This probably means making use of Perl::PrereqScanner and
-  Version::Requirements

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=56598&op=diff
==============================================================================
--- trunk/dh-make-perl/lib/Debian/Control/FromCPAN.pm (original)
+++ trunk/dh-make-perl/lib/Debian/Control/FromCPAN.pm Tue Apr 20 18:25:03 2010
@@ -20,7 +20,7 @@
 
 use CPAN ();
 use Debian::Version qw(deb_ver_cmp);
-use DhMakePerl::Utils qw( is_core_module find_cpan_module nice_perl_ver );
+use DhMakePerl::Utils qw( is_core_module find_cpan_module nice_perl_ver split_version_relation );
 use File::Spec qw( catfile );
 use Module::Depends ();
 
@@ -254,6 +254,10 @@
 
     while ( my ( $module, $version ) = each %$dep_hash ) {
 
+        my $ver_rel;
+
+        ( $ver_rel, $version ) = split_version_relation($version) if $version;
+
         my $dep;
 
         if ($apt_contents) {
@@ -263,9 +267,11 @@
             $dep = Debian::Dependency->new( 'perl', $ver );
         }
 
+        $dep->rel($ver_rel) if $dep and $ver_rel;
+
+        my $mod_ver = join( " ", $module, $ver_rel, $version || () );
         if ($dep) {
             if ($verbose) {
-                my $mod_ver = join( " ", $module, $version || () );
                 if ( $dep->pkg and $dep->pkg eq 'perl' ) {
                     print "= $mod_ver is in core";
                     print " since " . $dep->ver if $dep->ver;
@@ -277,7 +283,7 @@
             }
         }
         else {
-            print "- $module not found in any package\n";
+            print "- $mod_ver not found in any package\n";
             push @missing, $module;
 
             my $mod = find_cpan_module($module);
@@ -288,7 +294,7 @@
                 print "   CPAN contains it in $dist\n";
                 print "   substituting package name of $pkg\n";
 
-                $dep = Debian::Dependency->new( $pkg, $dep_hash->{$module} );
+                $dep = Debian::Dependency->new( $pkg, $ver_rel, $version );
             }
             else {
                 print "   - it seems it is not available even via CPAN\n";

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=56598&op=diff
==============================================================================
--- trunk/dh-make-perl/lib/DhMakePerl/Utils.pm (original)
+++ trunk/dh-make-perl/lib/DhMakePerl/Utils.pm Tue Apr 20 18:25:03 2010
@@ -13,12 +13,17 @@
 
 =cut
 
-our @EXPORT_OK = qw( find_cpan_module
-                     is_core_module
-                     nice_perl_ver
-                     find_core_perl_dependency );
+our @EXPORT_OK = qw(
+    find_core_perl_dependency
+    find_cpan_module
+    is_core_module
+    nice_perl_ver
+    split_version_relation
+);
 
 use base Exporter;
+
+use 5.10.0;
 
 use Module::CoreList ();
 use Debian::Dependency;
@@ -201,6 +206,41 @@
     return undef;
 }
 
+=item split_version_relation I<string>
+
+Splits the string, typicaly found in dependency fields' values in CPAN META
+into relation and version. If no relation is found in the string, C<< >= >> is
+assumed.
+
+Returns a list of relation and version. The relation is suitable for using in
+debian package dependency version requirements.
+
+For example
+
+=over
+
+=item split_version_relation('0.45') returns ( '>=', '0.45' )
+
+=item split_version_relation('< 0.56') returns ( '<<', '0.56' )
+
+=back
+
+=cut
+
+sub split_version_relation {
+    my $in = shift;
+
+    $in =~ s/^\s*([<>=!])\s*//;
+
+    my $rel = $1 // '>=';
+
+    $rel = '>>' if  $rel eq '>';
+
+    $rel = '<<' if $rel eq '<';
+
+    return ( $rel, $in );
+}
+
 =back
 
 =head1 COPYRIGHT & LICENSE

Added: trunk/dh-make-perl/t/split_version_relation.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/t/split_version_relation.t?rev=56598&op=file
==============================================================================
--- trunk/dh-make-perl/t/split_version_relation.t (added)
+++ trunk/dh-make-perl/t/split_version_relation.t Tue Apr 20 18:25:03 2010
@@ -1,0 +1,15 @@
+#!perl -T
+
+use Test::More tests => 3;
+
+BEGIN { use_ok( 'DhMakePerl::Utils', qw( split_version_relation ) ) };
+
+is_deeply(
+    [ split_version_relation('0.45') ],
+    [ '>=', '0.45' ],
+);
+
+is_deeply(
+    [ split_version_relation('> 0.56') ],
+    [ '>>', '0.56' ],
+);




More information about the Pkg-perl-cvs-commits mailing list