Blob Blame History Raw
From 1a5147fadcccb2892b16f740a3630007d6304255 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Petr=20P=C3=ADsa=C5=99?= <ppisar@redhat.com>
Date: Wed, 29 Nov 2017 17:51:13 +0100
Subject: [PATCH] Bundle Module::ScanDeps::_glob_in_inc_1()
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

These are Module::ScanDeps 1.24 functions required for Par::Packer 1.041
but missing from Module::ScanDeps 1.10.

Module::ScanDeps versions referred by Par-Packer commits:

1.21 used by commit 955a64db0bbd3   _glob_in_inc_1()
1.19 used by commit 64f3238b83340   obsoleted
1.19 used by commit 21340edcd       no code
1.15 used by commit 0e437ce304      no code

Signed-off-by: Petr Písař <ppisar@redhat.com>
---
 MANIFEST                         |  1 +
 lib/PAR/BundledModuleScanDeps.pm | 91 ++++++++++++++++++++++++++++++++++++++++
 lib/PAR/Packer.pm                |  1 +
 3 files changed, 93 insertions(+)
 create mode 100644 lib/PAR/BundledModuleScanDeps.pm

diff --git a/MANIFEST b/MANIFEST
index 00b441b..97cc114 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -18,6 +18,7 @@ contrib/procedural_pp/pp_old
 contrib/stdio/Stdio.pm
 contrib/stdio/Stdio_readme.txt
 lib/App/Packer/PAR.pm
+lib/PAR/BundledModuleScanDeps.pm
 lib/PAR/Filter.pm
 lib/PAR/Filter/Bleach.pm
 lib/PAR/Filter/Bytecode.pm
diff --git a/lib/PAR/BundledModuleScanDeps.pm b/lib/PAR/BundledModuleScanDeps.pm
new file mode 100644
index 0000000..d885166
--- /dev/null
+++ b/lib/PAR/BundledModuleScanDeps.pm
@@ -0,0 +1,91 @@
+package # Hide from scanner
+    Module::ScanDeps;
+use 5.008001;
+use strict;
+use warnings;
+
+=head1 NAME
+
+BundledModuleScanDeps - Recent Module::ScanDeps functions
+
+=head1 SYNOPIS
+
+    use Module::ScanDeps ();
+    use PAR::BundledModuleScanDeps ();
+
+=head1 DESCRIPTION
+
+These are L<Module::ScanDeps> 1.24 functions required for L<Par::Packer> 1.041
+but missing from L<Module::ScanDeps> 1.10.
+
+=cut
+
+# like _glob_in_inc, but looks only at the first level
+# (i.e. the children of $subdir)
+# NOTE: File::Find has no public notion of the depth of the traversal
+# in its "wanted" callback, so it's not helpful 
+sub _glob_in_inc_1 {
+    my $subdir  = shift;
+    my $pm_only = shift;
+    my @files;
+
+    $subdir =~ s/\$CurrentPackage/$CurrentPackage/;
+
+    foreach my $inc (grep !/\bBSDPAN\b/, @INC, @IncludeLibs) {
+        my $dir = "$inc/$subdir";
+        next unless -d $dir;
+
+        opendir my $dh, $dir or next; 
+        my @names = map { "$subdir/$_" } grep { -f "$dir/$_" } readdir $dh;
+        closedir $dh;
+
+        push @files, $pm_only
+            ? ( grep { /\.p[mh]$/i } @names )
+            : ( map { { file => "$inc/$_", name => $_ } } @names );
+    }
+
+    return @files;
+}
+
+1;
+__END__
+
+=head1 AUTHORS
+
+Audrey Tang E<lt>cpan@audreyt.orgE<gt>
+
+To a lesser degree: Steffen Mueller E<lt>smueller@cpan.orgE<gt>
+
+Parts of heuristics were deduced from:
+
+=over 4
+
+=item *
+
+B<PerlApp> by ActiveState Tools Corp L<http://www.activestate.com/>
+
+=item *
+
+B<Perl2Exe> by IndigoStar, Inc L<http://www.indigostar.com/>
+
+=back
+
+The B<scan_deps_runtime> function is contributed by Edward S. Peschko.
+
+You can write to the mailing list at E<lt>par@perl.orgE<gt>, or send an empty
+mail to E<lt>par-subscribe@perl.orgE<gt> to participate in the discussion.
+
+Please submit bug reports to E<lt>bug-Module-ScanDeps@rt.cpan.orgE<gt>.
+
+=head1 COPYRIGHT
+
+Copyright 2002-2008 by
+Audrey Tang E<lt>cpan@audreyt.orgE<gt>;
+2005-2010 by Steffen Mueller E<lt>smueller@cpan.orgE<gt>.
+
+This program is free software; you can redistribute it and/or modify it
+under the same terms as Perl itself.
+
+See L<http://www.perl.com/perl/misc/Artistic.html>
+
+=cut
diff --git a/lib/PAR/Packer.pm b/lib/PAR/Packer.pm
index b06a7db..eb4b2f2 100644
--- a/lib/PAR/Packer.pm
+++ b/lib/PAR/Packer.pm
@@ -33,6 +33,7 @@ use File::Find ();
 use File::Spec::Functions qw( :ALL );
 use File::Temp qw( tempfile );
 use Module::ScanDeps ();
+use PAR::BundledModuleScanDeps ();
 use PAR ();
 use PAR::Filter ();
 
-- 
2.13.6