[dh-make-perl] 01/03: Utils: new function is_core_perl_package

Damyan Ivanov dmn at moszumanska.debian.org
Tue Mar 21 20:50:46 UTC 2017


This is an automated email from the git hooks/post-receive script.

dmn pushed a commit to branch master
in repository dh-make-perl.

commit a029bcb124c0c4463fd82428f2a4444544f2cdb5
Author: Damyan Ivanov <dmn at debian.org>
Date:   Tue Mar 21 19:54:14 2017 +0000

    Utils: new function is_core_perl_package
    
    returns true if the package is one of perl, perl-base,
    perl-modules[-x.y] and libperlx.y
    
    to be used where code now looks for perl, perl-pase and
    perl-modules[-x.y] (adding libperlx.y)
---
 lib/DhMakePerl/Utils.pm | 21 +++++++++++++++++++++
 t/core-modules.t        | 11 +++++++++--
 2 files changed, 30 insertions(+), 2 deletions(-)

diff --git a/lib/DhMakePerl/Utils.pm b/lib/DhMakePerl/Utils.pm
index 8fea23c..4691182 100644
--- a/lib/DhMakePerl/Utils.pm
+++ b/lib/DhMakePerl/Utils.pm
@@ -22,6 +22,7 @@ our @EXPORT_OK = qw(
     find_core_perl_dependency
     apt_cache
     find_cpan_module find_cpan_distribution
+    is_core_perl_package
     is_core_module
     nice_perl_ver
     split_version_relation
@@ -115,6 +116,26 @@ sub find_cpan_distribution {
         "/\\/$name-[^\\/]+\\.(tar|zip)/" );
 }
 
+=item is_core_perl_package I<package>
+
+Returns true value if the given package is a core Perl package, i.e. one of
+C<perl>, C<perl-base>, C<perl-modules-X.Y> and C<libperlX.Y>.
+
+Having this in a central routine makes it easier to add/remove packages in the
+list.
+=cut
+
+sub is_core_perl_package {
+    my ($pkg) = @_;
+
+    return 1
+      if $pkg eq 'perl-base'
+      or $pkg eq 'perl'
+      or $pkg =~ /^perl-modules(?:-[\d.]+)?$/
+      or $pkg =~ /^libperl[\d.]+$/;
+    return 0;
+}
+
 =item is_core_module I<module>, I<version>
 
 Returns the version of the C<perl> package containing the given I<module> (at
diff --git a/t/core-modules.t b/t/core-modules.t
index 9c7c4f1..3b4cc11 100755
--- a/t/core-modules.t
+++ b/t/core-modules.t
@@ -3,9 +3,9 @@
 use strict;
 use warnings;
 
-use Test::More tests => 7;
+use Test::More tests => 13;
 
-use DhMakePerl::Utils qw(find_core_perl_dependency);
+use DhMakePerl::Utils qw(find_core_perl_dependency is_core_perl_package );
 
 is( find_core_perl_dependency('Module::CoreList') . '',
     'perl (>= 5.10.0)',
@@ -40,3 +40,10 @@ is( find_core_perl_dependency( 'Module::CoreList', '2.19' ), undef ,
 # perl 5.10.1 has M:B 0.340201 which may fool us
 is( find_core_perl_dependency( 'Module::Build', '0.3603' ),
     undef, 'Module::Build 0.3603 is not in Debian\'s perl' );
+
+ok( is_core_perl_package('perl'), 'perl is core' );
+ok( is_core_perl_package('perl-base'), 'perl-base is core' );
+ok( is_core_perl_package('perl-modules'), 'perl-modules is core' );
+ok( is_core_perl_package('perl-modules-5.24'), 'perl-modules-5.24 is core' );
+ok( is_core_perl_package('libperl5.24'), 'libperl5.24 is core' );
+ok( !is_core_perl_package('foo'), 'foo is not core' );

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/dh-make-perl.git



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