r5989 - /scripts/qa/versioncheck.pl

dmn at users.alioth.debian.org dmn at users.alioth.debian.org
Thu Jul 26 15:12:16 UTC 2007


Author: dmn
Date: Thu Jul 26 15:12:15 2007
New Revision: 5989

URL: http://svn.debian.org/wsvn/?sc=1&rev=5989
Log:
Add blind conversion from package name to module name

Modified:
    scripts/qa/versioncheck.pl

Modified: scripts/qa/versioncheck.pl
URL: http://svn.debian.org/wsvn/scripts/qa/versioncheck.pl?rev=5989&op=diff
==============================================================================
--- scripts/qa/versioncheck.pl (original)
+++ scripts/qa/versioncheck.pl Thu Jul 26 15:12:15 2007
@@ -235,36 +235,52 @@
         {
             push @vers, $cpan_mod->cpan_version;
         }
-#        elsif( ! /^Net::/ )
-#        {
-#            $cpan_mod = $cpan->expand('Module', "Net::$_");
-#            push @vers, $cpan_mod->cpan_version if $cpan_mod;
-#        }
-        else
-        {
+
+        do {
             # Try to gyess real module name given the distribution file
             # name (without version) and the perl package name
             my $tmp = $pkg;
             $tmp =~ s/^lib//; $tmp =~ s/-perl$//;
             my @pkg_parts = split(/-/, $tmp);
 
-            $warch_mod = 'Net'.$watch_mod if @pkg_parts[0] eq 'net';
+            my $watch_mod = $_;
+            $watch_mod = 'Net'.$watch_mod if $pkg_parts[0] eq 'net';
 
             my @mod_parts;
-            my $watch_mod = $_;
             while( @pkg_parts and $watch_mod =~ s/^($pkg_parts[0])-?//xi )
             {
                 push @mod_parts, $1;
                 shift @pkg_parts;
             }
 
-            return undef if @pkg_parts;
-
-            my $mod_name = join( '::', @mod_parts );
+            unless( @pkg_parts )
+            {
+                my $mod_name = join( '::', @mod_parts );
+                debugmsg( sprintf( "    cpan search %s\n", $mod_name ) );
+                $cpan_mod = $cpan->expand( 'Module', $mod_name );
+                push @vers, $cpan_mod->cpan_version if $cpan_mod;
+            }
+        };
+
+        do {
+            # Last try - blindly convert package name to perl module
+            my $tmp = $pkg;
+            $tmp =~ s/^lib//; $tmp =~ s/-perl$//;
+            my @pkg_parts = split(/-/, $tmp);
+            s/^(.)/\U$1/ foreach @pkg_parts;
+                
+            my $mod_name = join( '::', @pkg_parts );
             debugmsg( sprintf( "    cpan search %s\n", $mod_name ) );
             $cpan_mod = $cpan->expand( 'Module', $mod_name );
             push @vers, $cpan_mod->cpan_version if $cpan_mod;
-        }
+
+            #unless( @vers )
+            #{
+            #    # This is slow - last resort
+            #    $cpan_mod = $cpan->expand( 'Module', "/$mod_name/");
+            #    push @vers, $cpan_mod->cpan_version if $cpan_mod;
+            #}
+        };
     }
 
     @vers = sort { cmp_ver($a,$b) } @vers;
@@ -560,4 +576,4 @@
 
 exit 0
 
-# vim: et:sts=4:ai
+# vim: et:sts=4:ai:sw=4




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