r35290 - in /trunk/dh-make-perl: lib/DhMakePerl.pm t/perl-versions.t
dmn at users.alioth.debian.org
dmn at users.alioth.debian.org
Wed May 13 04:36:54 UTC 2009
Author: dmn
Date: Wed May 13 04:36:45 2009
New Revision: 35290
URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=35290
Log:
move conversion from numerical perl version to deb version into a sub
also add tests about it
Added:
trunk/dh-make-perl/t/perl-versions.t
Modified:
trunk/dh-make-perl/lib/DhMakePerl.pm
Modified: trunk/dh-make-perl/lib/DhMakePerl.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/lib/DhMakePerl.pm?rev=35290&op=diff
==============================================================================
--- trunk/dh-make-perl/lib/DhMakePerl.pm (original)
+++ trunk/dh-make-perl/lib/DhMakePerl.pm Wed May 13 04:36:45 2009
@@ -982,6 +982,27 @@
return map( Debian::Dependency->new( $_, $deps{$_} ), sort( keys(%deps) ) );
}
+sub nice_perl_ver {
+ my( $self, $v ) = @_;
+
+ if( $v =~ /\.(\d+)$/ ) {
+ my $minor = $1;
+ if( length($minor) % 3 ) {
+ # right-pad with zeroes so that the number of digits after the dot
+ # is a multiple of 3
+ $minor .= '0' x ( 3 - length($minor) % 3 );
+ }
+
+ my $ver = 0 + substr( $minor, 0, 3 );
+ if( length($minor) > 3 ) {
+ $ver .= '.' . ( 0 + substr( $minor, 3 ) );
+ }
+ $v =~ s/\.\d+$/.$ver/;
+ }
+
+ return $v;
+}
+
sub find_debs_for_modules {
my ( $self, $dep_hash, $apt_contents ) = @_;
@@ -1045,12 +1066,8 @@
$v =~ s/^v//; # strip leading 'v' from version
# perl versions need special handling
- if ( $module eq 'perl' and $v =~ /\.(\d+)$/ ) {
- my $ver = 0 + substr( $1, 0, 3 );
- if( length($1) > 3 ) {
- $ver .= '.' . ( 0 + substr( $1, 3 ) );
- }
- $v =~ s/\.\d+$/.$ver/;
+ if ( $module eq 'perl' ) {
+ $v = $self->nice_perl_ver($v);
# no point depending on ancient perl versions
# perl is Priority: standard
Added: trunk/dh-make-perl/t/perl-versions.t
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/t/perl-versions.t?rev=35290&op=file
==============================================================================
--- trunk/dh-make-perl/t/perl-versions.t (added)
+++ trunk/dh-make-perl/t/perl-versions.t Wed May 13 04:36:45 2009
@@ -1,0 +1,37 @@
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+
+use Test::More tests => 21;
+
+BEGIN {
+ use_ok('DhMakePerl');
+};
+
+sub check {
+ my( $src, $dst ) = @_;
+
+ is( DhMakePerl->nice_perl_ver($src), $dst, "perl version '$src' corresponds to Debian package version '$dst'" );
+}
+
+check( '5.006002', '5.6.2' );
+check( '5.007003', '5.7.3' );
+check( '5.008' , '5.8' );
+check( '5.008001', '5.8.1' );
+check( '5.008002', '5.8.2' );
+check( '5.008003', '5.8.3' );
+check( '5.008004', '5.8.4' );
+check( '5.008005', '5.8.5' );
+check( '5.008006', '5.8.6' );
+check( '5.008007', '5.8.7' );
+check( '5.008008', '5.8.8' );
+check( '5.008009', '5.8.9' );
+check( '5.009' , '5.9' );
+check( '5.009001', '5.9.1' );
+check( '5.009002', '5.9.2' );
+check( '5.009003', '5.9.3' );
+check( '5.009004', '5.9.4' );
+check( '5.009005', '5.9.5' );
+check( '5.01' , '5.10' );
+check( '5.010000', '5.10.0');
More information about the Pkg-perl-cvs-commits
mailing list