[PATCH] Updated get_stdmodules to use Module::CoreList.

Paul Fenwick pjf at perltraining.com.au
Tue Nov 25 05:50:05 UTC 2008


Previously get_stdmodules() would manually root around in the directories
listed in @INC.  This could potentially have strange results if @INC
was modified (eg, due to setting PERL5LIB).
---
 debian/control |    2 +-
 dh-make-perl   |   22 ++++++++--------------
 2 files changed, 9 insertions(+), 15 deletions(-)

diff --git a/debian/control b/debian/control
index 26c6985..0fd71c4 100644
--- a/debian/control
+++ b/debian/control
@@ -17,7 +17,7 @@ Package: dh-make-perl
 Architecture: all
 Depends: debhelper (>= 4.0.2), libpod-parser-perl, ${perl:Depends}, make,
  dpkg-dev, fakeroot, ${misc:Depends}, libyaml-perl,  libmodule-depends-perl,
- libwww-mechanize-perl, libemail-date-format-perl
+ libwww-mechanize-perl, libemail-date-format-perl, libmodule-corelist-perl
 Recommends: apt-file (>= 2.1.0), libmodule-build-perl
 Description: Create Debian packages from perl modules
  dh-make-perl will create the files required to build a Debian source
diff --git a/dh-make-perl b/dh-make-perl
index dc0dfdb..21a1dbd 100755
--- a/dh-make-perl
+++ b/dh-make-perl
@@ -11,6 +11,7 @@ use Cwd;
 use CPAN;
 use Module::Depends::Intrusive;
 use Email::Date::Format qw(email_date);
+use Module::CoreList ();
 use strict;
 
 # TODO:
@@ -310,24 +311,17 @@ USAGE
 }
 
 sub get_stdmodules {
-    my ( $base_packages, @modules, $paths );
-    $base_packages = $opts{basepkgs} || 'perl,perl-base,perl-modules';
 
-   # We will check on all the base Perl packages for the modules they provide.
-   # To know which files we care for, we look at @INC - In a format easy to
-   # integrate into a regex
-    $paths = join( '|', @INC );
+    # Module::CoreList already knows our core modules, so we ask it.
+    # $] is our perl version.
 
-    for my $pkg ( split( /,/, $base_packages ) ) {
-        for my $file ( map { chomp; $_ } `dpkg -L $pkg` ) {
-            next unless $file =~ s!^(?:$paths)[\d\.]*/(.*).pm$!$1!x;
+    my @modules = keys %{ $Module::CoreList::version{ $] } };
 
-            $file =~ s!/!::!g;
-            push @modules, $file;
-        }
-    }
+    @modules
+        or die "Internal error: \$Module::CoreList::version{ $] } is empty";
+
+    return @modules;
 
-    return sort @modules;
 }
 
 sub setup_dir {
-- 
1.5.5.GIT


--------------060002040602070908000403--





More information about the pkg-perl-maintainers mailing list