r40188 - in /trunk/libmodule-scandeps-perl: ./ debian/ debian/patches/ lib/Module/ lib/Module/ScanDeps/ script/ t/

ansgar-guest at users.alioth.debian.org ansgar-guest at users.alioth.debian.org
Sun Jul 19 17:25:53 UTC 2009


Author: ansgar-guest
Date: Sun Jul 19 17:25:46 2009
New Revision: 40188

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=40188
Log:
* New upstream release
  + Refresh patches.

Added:
    trunk/libmodule-scandeps-perl/lib/Module/ScanDeps/Cache.pm
      - copied unchanged from r40187, branches/upstream/libmodule-scandeps-perl/current/lib/Module/ScanDeps/Cache.pm
    trunk/libmodule-scandeps-perl/t/14-scan_chunk.t
      - copied unchanged from r40187, branches/upstream/libmodule-scandeps-perl/current/t/14-scan_chunk.t
    trunk/libmodule-scandeps-perl/t/14-static_functional_cached.t
      - copied unchanged from r40187, branches/upstream/libmodule-scandeps-perl/current/t/14-static_functional_cached.t
Modified:
    trunk/libmodule-scandeps-perl/AUTHORS
    trunk/libmodule-scandeps-perl/Changes
    trunk/libmodule-scandeps-perl/MANIFEST
    trunk/libmodule-scandeps-perl/META.yml
    trunk/libmodule-scandeps-perl/debian/changelog
    trunk/libmodule-scandeps-perl/debian/patches/fix_references_to_renamed_executable
    trunk/libmodule-scandeps-perl/lib/Module/ScanDeps.pm
    trunk/libmodule-scandeps-perl/script/scandeps.pl
    trunk/libmodule-scandeps-perl/t/Utils.pm

Modified: trunk/libmodule-scandeps-perl/AUTHORS
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-scandeps-perl/AUTHORS?rev=40188&op=diff
==============================================================================
--- trunk/libmodule-scandeps-perl/AUTHORS (original)
+++ trunk/libmodule-scandeps-perl/AUTHORS Sun Jul 19 17:25:46 2009
@@ -6,6 +6,7 @@
 Adam Kennedy                  (ADAMK)
 Adrian Issott
 Alan Stewart
+Alexandr Ciornii              (CHORNY)
 Andrew Lee
 Brian Cassidy                 (BRICAS)
 Bruce Winter

Modified: trunk/libmodule-scandeps-perl/Changes
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-scandeps-perl/Changes?rev=40188&op=diff
==============================================================================
--- trunk/libmodule-scandeps-perl/Changes (original)
+++ trunk/libmodule-scandeps-perl/Changes Sun Jul 19 17:25:46 2009
@@ -1,3 +1,13 @@
+[Changes for 0.93 - 2009-07-19]
+* Implement caching of dependencies (Christoph Lamprecht)
+
+[Changes for 0.92 - 2009-07-19]
+* Fix bug with {type} being set to unexpected values in some cases (Christoph Lamprecht)
+* Add tests for scan_chunk (Alexandr Ciornii)
+* Add special case for parent.pm (Alexandr Ciornii)
+* Fix for "use parent::something" (Alexandr Ciornii)
+* Add special case for Catalyst.pm (Alexandr Ciornii)
+
 [Changes for 0.91 - 2009-06-22]
 * Add special case for Tk's setPalette call (Christoph Lamprecht)
 

Modified: trunk/libmodule-scandeps-perl/MANIFEST
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-scandeps-perl/MANIFEST?rev=40188&op=diff
==============================================================================
--- trunk/libmodule-scandeps-perl/MANIFEST (original)
+++ trunk/libmodule-scandeps-perl/MANIFEST Sun Jul 19 17:25:46 2009
@@ -10,6 +10,7 @@
 inc/Module/Install/Win32.pm
 inc/Module/Install/WriteAll.pm
 lib/Module/ScanDeps.pm
+lib/Module/ScanDeps/Cache.pm
 lib/Module/ScanDeps/DataFeed.pm
 Makefile.PL
 MANIFEST			This list of files
@@ -22,6 +23,8 @@
 t/11-finds-shared-lib.t
 t/12-ScanFileRE.t
 t/13-static_prefork_test.t
+t/14-scan_chunk.t
+t/14-static_functional_cached.t
 t/2-static_functional_interface_fake.t
 t/3-static_oo_interface_real.t
 t/4-static_functional_interface_options_fake.t

Modified: trunk/libmodule-scandeps-perl/META.yml
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-scandeps-perl/META.yml?rev=40188&op=diff
==============================================================================
--- trunk/libmodule-scandeps-perl/META.yml (original)
+++ trunk/libmodule-scandeps-perl/META.yml Sun Jul 19 17:25:46 2009
@@ -27,4 +27,4 @@
 resources:
   license: http://dev.perl.org/licenses/
   repository: http://svn.openfoundry.org/par/Module-ScanDeps/trunk/
-version: 0.91
+version: 0.93

Modified: trunk/libmodule-scandeps-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-scandeps-perl/debian/changelog?rev=40188&op=diff
==============================================================================
--- trunk/libmodule-scandeps-perl/debian/changelog (original)
+++ trunk/libmodule-scandeps-perl/debian/changelog Sun Jul 19 17:25:46 2009
@@ -1,3 +1,10 @@
+libmodule-scandeps-perl (0.93-1) unstable; urgency=low
+
+  * New upstream release
+    + Refresh patches.
+
+ -- Ansgar Burchardt <ansgar at 43-1.org>  Sun, 19 Jul 2009 19:25:06 +0200
+
 libmodule-scandeps-perl (0.91-1) unstable; urgency=low
 
   [ Nathan Handler ]

Modified: trunk/libmodule-scandeps-perl/debian/patches/fix_references_to_renamed_executable
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-scandeps-perl/debian/patches/fix_references_to_renamed_executable?rev=40188&op=diff
==============================================================================
--- trunk/libmodule-scandeps-perl/debian/patches/fix_references_to_renamed_executable (original)
+++ trunk/libmodule-scandeps-perl/debian/patches/fix_references_to_renamed_executable Sun Jul 19 17:25:46 2009
@@ -1,8 +1,12 @@
-From: Gunnar Wolf
-Subject: rename /usr/bin/scandeps.pl to /usr/bin/scandeps as per policy
+Subject: Fix references to scandeps
+Date: Mon, 10 Mar 2008 10:40:40 -0600
+From: Gunnar Wolf <gwolf at debian.org>
 
---- a/lib/Module/ScanDeps.pm
-+++ b/lib/Module/ScanDeps.pm
+Fixed references to scandeps.pl so they refer to scandeps.  The name of the
+program was changed to follow Debian policy.
+
+--- libmodule-scandeps-perl.orig/lib/Module/ScanDeps.pm
++++ libmodule-scandeps-perl/lib/Module/ScanDeps.pm
 @@ -36,12 +36,12 @@
  
  =head1 SYNOPSIS
@@ -21,7 +25,7 @@
  
  Used in a program;
  
-@@ -1294,7 +1294,7 @@
+@@ -1363,7 +1363,7 @@
  
  =head1 SEE ALSO
  
@@ -30,9 +34,9 @@
  for a number of files.
  
  An application of B<Module::ScanDeps> is to generate executables from
---- a/script/scandeps.pl
-+++ b/script/scandeps.pl
-@@ -136,19 +136,19 @@
+--- libmodule-scandeps-perl.orig/script/scandeps.pl
++++ libmodule-scandeps-perl/script/scandeps.pl
+@@ -137,20 +137,20 @@
  
  =head1 NAME
  
@@ -46,11 +50,13 @@
 -    % scandeps.pl -B *.pm       # Include core modules
 -    % scandeps.pl -V *.pm       # Show autoload/shared/data files
 -    % scandeps.pl -R *.pm       # Don't recurse
+-    % scandeps.pl -C CACHEFILE  # use CACHEFILE to cache dependencies
 +    % scandeps *.pm          # Print PREREQ_PM section for *.pm
-+    % scandeps -e 'STRING'   # Scan an one-liner
++    % scandeps -e 'STRING'	# Scan an one-liner
 +    % scandeps -B *.pm       # Include core modules
 +    % scandeps -V *.pm       # Show autoload/shared/data files
 +    % scandeps -R *.pm       # Don't recurse
++    % scandeps -C CACHEFILE  # use CACHEFILE to cache dependencies
  
  =head1 DESCRIPTION
  

Modified: trunk/libmodule-scandeps-perl/lib/Module/ScanDeps.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-scandeps-perl/lib/Module/ScanDeps.pm?rev=40188&op=diff
==============================================================================
--- trunk/libmodule-scandeps-perl/lib/Module/ScanDeps.pm (original)
+++ trunk/libmodule-scandeps-perl/lib/Module/ScanDeps.pm Sun Jul 19 17:25:46 2009
@@ -1,10 +1,10 @@
 package Module::ScanDeps;
-
 use 5.006;
 use strict;
+use warnings;
 use vars qw( $VERSION @EXPORT @EXPORT_OK @ISA $CurrentPackage @IncludeLibs $ScanFileRE );
 
-$VERSION   = '0.91';
+$VERSION   = '0.93';
 @EXPORT    = qw( scan_deps scan_deps_runtime );
 @EXPORT_OK = qw( scan_line scan_chunk add_deps scan_deps_runtime path_to_inc_name );
 
@@ -96,9 +96,9 @@
 =head2 B<scan_deps>
 
     $rv_ref = scan_deps(
-        files   => \@files,     recurse => $recurse,
-        rv      => \%rv,        skip    => \%skip,
-        compile => $compile,    execute => $execute,
+        files      => \@files,     recurse => $recurse,
+        rv         => \%rv,        skip    => \%skip,
+        compile    => $compile,    execute => $execute,
     );
     $rv_ref = scan_deps(@files); # shorthand, with recurse => 1
 
@@ -119,6 +119,10 @@
 
 If C<$execute> is an array reference, runs the files contained
 in it instead of C<@files>.
+
+If performance of the scanning process is a concern, C<cache_file> can be
+set to a filename. The scanning results will be cached and written to the
+file. This will speed up the scanning process on subsequent runs.
 
 Additionally, an option C<warn_missing> is recognized. If set to true,
 C<scan_deps> issues a warning to STDERR for every module file that the
@@ -500,7 +504,7 @@
     return $inc_name;
 }
 
-my $Keys = 'files|keys|recurse|rv|skip|first|execute|compile|warn_missing';
+my $Keys = 'files|keys|recurse|rv|skip|first|execute|compile|warn_missing|cache_cb|cache_file';
 sub scan_deps {
     my %args = (
         rv => {},
@@ -510,7 +514,21 @@
     if (!defined($args{keys})) {
         $args{keys} = [map {path_to_inc_name($_, $args{warn_missing})} @{$args{files}}];
     }
-
+    my $cache_file = $args{cache_file};
+    my $using_cache;
+    if ($cache_file) {
+        require Module::ScanDeps::Cache;
+        $using_cache = Module::ScanDeps::Cache::init_from_file($cache_file);
+        if( $using_cache ){
+            $args{cache_cb} = Module::ScanDeps::Cache::get_cache_cb();
+        }else{
+            my @missing = Module::ScanDeps::Cache::prereq_missing();
+            warn join(' ',
+                      "Can not use cache_file: Needs Modules [",
+                      @missing,
+                      "]\n",);
+        }
+    }
     my ($type, $path);
     foreach my $input_file (@{$args{files}}) {
         if ($input_file !~ $ScanFileRE) {
@@ -518,8 +536,7 @@
             next;
         }
 
-        $type = 'module';
-        $type = 'data' unless $input_file =~ /\.p[mh]$/io;
+        $type = _gettype($input_file);
         $path = $input_file;
         if ($type eq 'module') {
             # necessary because add_deps does the search for shared libraries and such
@@ -554,6 +571,10 @@
         );
     }
 
+    if ( $using_cache ){
+        Module::ScanDeps::Cache::store_cache();
+    }
+
     # do not include the input files themselves as dependencies!
     delete $args{rv}{$_} foreach @{$args{files}};
 
@@ -562,8 +583,12 @@
 
 sub scan_deps_static {
     my ($args) = @_;
-    my ($files, $keys, $recurse, $rv, $skip, $first, $execute, $compile, $_skip) =
-        @$args{qw( files keys recurse rv skip first execute compile _skip )};
+    my ($files,  $keys, $recurse, $rv,
+        $skip,  $first, $execute, $compile,
+        $cache_cb, $_skip)
+        = @$args{qw( files keys  recurse rv
+                     skip  first execute compile
+                     cache_cb _skip )};
 
     $rv   ||= {};
     $_skip ||= { %{$skip || {}} };
@@ -575,66 +600,62 @@
           and $file ne lc($file) and $_skip->{lc($file)}++;
         next unless $file =~ $ScanFileRE;
 
-        local *FH;
-        open FH, $file or die "Cannot open $file: $!";
-
-        $SeenTk = 0;
-        # Line-by-line scanning
-        LINE:
-        while (<FH>) {
-            chomp(my $line = $_);
-            foreach my $pm (scan_line($line)) {
-                last LINE if $pm eq '__END__';
-
-                # Skip Tk hits from Term::ReadLine and Tcl::Tk
-                my $pathsep = qr/\/|\\|::/;
-                if ($pm =~ /^Tk\b/) {
-                  next if $file =~ /(?:^|${pathsep})Term${pathsep}ReadLine\.pm$/;
-                  next if $file =~ /(?:^|${pathsep})Tcl${pathsep}Tk\W/;
-                }
-
-                if ($pm eq '__POD__') {
-                    while (<FH>) { last if (/^=cut/) }
-                    next LINE;
-                }
-
-                $pm = 'CGI/Apache.pm' if $file =~ /^Apache(?:\.pm)$/;
-
-                add_deps(
-                    used_by => $key,
-                    rv      => $args->{rv},
-                    modules => [$pm],
-                    skip    => $args->{skip},
-                    warn_missing => $args->{warn_missing},
-                );
-
-                my $preload = _get_preload($pm) or next;
-
-                add_deps(
-                    used_by => $key,
-                    rv      => $args->{rv},
-                    modules => $preload,
-                    skip    => $args->{skip},
-                    warn_missing => $args->{warn_missing},
-                );
+        my @pm;
+        my $found_in_cache;
+        if ($cache_cb){
+            my $pm_aref;
+            # cache_cb populates \@pm on success
+            $found_in_cache = $cache_cb->(action => 'read',
+                                          key    => $key,
+                                          file   => $file,
+                                          modules => \@pm,
+                                      );
+            unless( $found_in_cache ){
+                @pm = scan_file($file);
+                $cache_cb->(action => 'write',
+                            key    => $key,
+                            file   => $file,
+                            modules => \@pm,
+                        );
             }
-        }
-        close FH;
-
-        # }}}
+        }else{ # no caching callback given
+            @pm = scan_file($file);
+        }
+        
+        foreach my $pm (@pm){
+            add_deps(
+                     used_by => $key,
+                     rv      => $args->{rv},
+                     modules => [$pm],
+                     skip    => $args->{skip},
+                     warn_missing => $args->{warn_missing},
+                 );
+
+            my $preload = _get_preload($pm) or next;
+
+            add_deps(
+                     used_by => $key,
+                     rv      => $args->{rv},
+                     modules => $preload,
+                     skip    => $args->{skip},
+                     warn_missing => $args->{warn_missing},
+                 );
+        }
     }
 
     # Top-level recursion handling {{{
+   
     while ($recurse) {
         my $count = keys %$rv;
         my @files = sort grep -T $_->{file}, values %$rv;
         scan_deps_static({
-            files   => [ map $_->{file}, @files ],
-            keys    => [ map $_->{key},  @files ],
-            rv      => $rv,
-            skip    => $skip,
-            recurse => 0,
-            _skip   => $_skip,
+            files    => [ map $_->{file}, @files ],
+            keys     => [ map $_->{key},  @files ],
+            rv       => $rv,
+            skip     => $skip,
+            recurse  => 0,
+            cache_cb => $cache_cb,
+            _skip    => $_skip,
         }) or ($args->{_deep} and return);
         last if $count == keys %$rv;
     }
@@ -691,6 +712,43 @@
     return ($rv);
 }
 
+sub scan_file{
+    my $file = shift;
+    my %found;
+    my $FH;
+    open $FH, $file or die "Cannot open $file: $!";
+
+    $SeenTk = 0;
+    # Line-by-line scanning
+  LINE:
+    while (<$FH>) {
+        chomp(my $line = $_);
+        foreach my $pm (scan_line($line)) {
+            last LINE if $pm eq '__END__';
+
+            # Skip Tk hits from Term::ReadLine and Tcl::Tk
+            my $pathsep = qr/\/|\\|::/;
+            if ($pm =~ /^Tk\b/) {
+                next if $file =~ /(?:^|${pathsep})Term${pathsep}ReadLine\.pm$/;
+                next if $file =~ /(?:^|${pathsep})Tcl${pathsep}Tk\W/;
+            }
+            if ($pm eq '__POD__') {
+                while (<$FH>) {
+                    last if (/^=cut/);
+                }
+                next LINE;
+            }
+            $SeenTk || do{$SeenTk = 1 if $pm =~ /Tk\.pm$/;};
+            # the following line does not make much sense here ???
+            # $file is an absolute path and will never match
+            #$pm = 'CGI/Apache.pm' if $file =~ /^Apache(?:\.pm)$/;
+            $found{$pm}++;
+        }
+    }
+    close $FH or die "Cannot close $file: $!";
+    return keys %found;
+}
+
 sub scan_line {
     my $line = shift;
     my %found;
@@ -710,7 +768,8 @@
         # use VERSION:
         if (/^\s*(?:use|require)\s+([\d\._]+)/) {
           # include feaure.pm if we have 5.9.5 or better
-          if (version->new($1) >= version->new("5.9.5")) { # seems to catch 5.9, too (but not 5.9.4)
+          if (version->new($1) >= version->new("5.9.5")) {
+              # seems to catch 5.9, too (but not 5.9.4)
             return "feature.pm";
           }
         }
@@ -744,16 +803,21 @@
 sub _typical_module_loader_chunk {
   local $_ = shift;
   my $loader = shift;
+  my $prefix='';
+  if (@_ and $_[0]) {
+    $prefix=$_[0].'::';
+  }
   my $loader_file = $loader;
   $loader_file =~ s/::/\//;
   $loader_file .= ".pm";
   $loader = quotemeta($loader);
 
-  if (/^\s* use \s+ $loader \b \s* (.*)/sx) {
+  if (/^\s* use \s+ $loader(?!\:) \b \s* (.*)/sx) {
     return [
       $loader_file,
-      map { s{::}{/}g; "$_.pm" }
-      grep { length and !/^q[qw]?$/ } split(/[^\w:]+/, $1)
+      map { my $mod="$prefix$_";$mod=~s{::}{/}g; "$mod.pm" }
+      grep { length and !/^q[qw]?$/ and !/-/ } split(/[^\w:-]+/, $1)
+      #should skip any module name that contains '-', not split it in two
     ];
   }
   return();
@@ -768,8 +832,13 @@
 
         # TODO: There's many more of these "loader" type modules on CPAN!
         # scan for the typical module-loader modules
-        foreach my $loader (qw(asa base prefork POE encoding maybe only::matching)) {
+        foreach my $loader (qw(asa base parent prefork POE encoding maybe only::matching)) {
           my $retval = _typical_module_loader_chunk($_, $loader);
+          return $retval if $retval;
+        }
+
+        foreach my $loader (qw(Catalyst)) {
+          my $retval = _typical_module_loader_chunk($_, $loader,'Catalyst::Plugin');
           return $retval if $retval;
         }
 
@@ -925,8 +994,7 @@
             next;
         }
 
-        my $type = 'module';
-        $type = 'data' unless $file =~ /\.p[mh]$/i;
+        my $type = _gettype($file);
         _add_info( rv     => $rv,   module  => $module,
                    file   => $file, used_by => $used_by,
                    type   => $type );
@@ -937,10 +1005,11 @@
             foreach (_glob_in_inc("auto/$path")) {
                 next if $_->{file} =~ m{\bauto/$path/.*/};  # weed out subdirs
                 next if $_->{name} =~ m/(?:^|\/)\.(?:exists|packlist)$/;
-                my $ext = lc($1) if $_->{name} =~ /(\.[^.]+)$/;
+                my ($ext,$type);
+                $ext = lc($1) if $_->{name} =~ /(\.[^.]+)$/;
                 next if $ext eq lc(lib_ext());
-                my $type = 'shared' if $ext eq lc(dl_ext());
-                $type = 'autoload' if $ext eq '.ix' or $ext eq '.al';
+                $type = 'shared' if $ext eq lc(dl_ext());
+                $type = 'autoload' if ($ext eq '.ix' or $ext eq '.al');
                 $type ||= 'data';
 
                 _add_info( rv     => $rv,        module  => "auto/$path/$_->{name}",
@@ -1202,7 +1271,7 @@
     my $name = shift;
     my $dlext = quotemeta(dl_ext());
 
-    return 'autoload' if $name =~ /(?:\.ix|\.al|\.bs)$/i;
+    return 'autoload' if $name =~ /(?:\.ix|\.al)$/i;
     return 'module'   if $name =~ /\.p[mh]$/i;
     return 'shared'   if $name =~ /\.$dlext$/i;
     return 'data';

Modified: trunk/libmodule-scandeps-perl/script/scandeps.pl
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-scandeps-perl/script/scandeps.pl?rev=40188&op=diff
==============================================================================
--- trunk/libmodule-scandeps-perl/script/scandeps.pl (original)
+++ trunk/libmodule-scandeps-perl/script/scandeps.pl Sun Jul 19 17:25:46 2009
@@ -10,7 +10,7 @@
 use subs qw( _name _modtree );
 
 my %opts;
-getopts('BVRxce:', \%opts);
+getopts('BVRxce:C:', \%opts);
 
 my (%map, %skip);
 my $core    = $opts{B};
@@ -26,7 +26,7 @@
     push @ARGV, $filename;
 }
 
-die "Usage: $0 [ -B ] [ -V ] [ -x | -c ] [ -R ] [ -e STRING | FILE ... ]\n" unless @ARGV;
+die "Usage: $0 [ -B ] [ -V ] [ -x | -c ] [ -R ] [-C FILE ] [ -e STRING | FILE ... ]\n" unless @ARGV;
 
 my @files = @ARGV;
 while (<>) {
@@ -40,6 +40,7 @@
     $opts{x} ? ( execute => 1 ) :
     $opts{c} ? ( compile => 1 ) : (),
     $opts{V} ? ( warn_missing => 1 ) : (),
+    $opts{C} ? ( cache_file   => $opts{C}) : (),
 );
 
 
@@ -145,6 +146,7 @@
     % scandeps.pl -B *.pm       # Include core modules
     % scandeps.pl -V *.pm       # Show autoload/shared/data files
     % scandeps.pl -R *.pm       # Don't recurse
+    % scandeps.pl -C CACHEFILE  # use CACHEFILE to cache dependencies
 
 =head1 DESCRIPTION
 
@@ -202,6 +204,11 @@
 dependencies that aren't really dependencies, you have probably found
 false positives.
 
+=item -C CACHEFILE
+
+Use CACHEFILE to speed up the scanning process by caching dependencies.
+Creates CACHEFILE if it does not exist yet.
+
 =back
 
 =head1 SEE ALSO

Modified: trunk/libmodule-scandeps-perl/t/Utils.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/libmodule-scandeps-perl/t/Utils.pm?rev=40188&op=diff
==============================================================================
--- trunk/libmodule-scandeps-perl/t/Utils.pm (original)
+++ trunk/libmodule-scandeps-perl/t/Utils.pm Sun Jul 19 17:25:46 2009
@@ -157,8 +157,6 @@
     }
 }
 
-1;
-
 sub generic_abs_path {
   my $file = shift @_;
   $file = File::Spec->rel2abs($file);
@@ -166,5 +164,7 @@
   return $file;
 }
 
+
+1;
 # Marks the end of any code. Any symbols after this are ignored. Use for documentation
 __END__




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