r66457 - in /trunk/dh-make-perl: debian/changelog dh-make-perl lib/DhMakePerl/Command/make.pm lib/DhMakePerl/Utils.pm

dmn at users.alioth.debian.org dmn at users.alioth.debian.org
Sun Dec 26 12:35:24 UTC 2010


Author: dmn
Date: Sun Dec 26 12:35:09 2010
New Revision: 66457

URL: http://svn.debian.org/wsvn/pkg-perl/?sc=1&rev=66457
Log:
Support distribution names as arguments to --cpan (Closes: #607998)

Modified:
    trunk/dh-make-perl/debian/changelog
    trunk/dh-make-perl/dh-make-perl
    trunk/dh-make-perl/lib/DhMakePerl/Command/make.pm
    trunk/dh-make-perl/lib/DhMakePerl/Utils.pm

Modified: trunk/dh-make-perl/debian/changelog
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/debian/changelog?rev=66457&op=diff
==============================================================================
--- trunk/dh-make-perl/debian/changelog (original)
+++ trunk/dh-make-perl/debian/changelog Sun Dec 26 12:35:09 2010
@@ -26,6 +26,7 @@
     (Closes: #589816)
   * Clarify documentation about --cpan argument being module name
     (Closes: 602059)
+  * Support distribution names as arguments to --cpan (Closes: #607998)
 
  -- Peter Pentchev <roam at ringlet.net>  Sun, 19 Dec 2010 20:43:10 +0200
 

Modified: trunk/dh-make-perl/dh-make-perl
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/dh-make-perl?rev=66457&op=diff
==============================================================================
--- trunk/dh-make-perl/dh-make-perl (original)
+++ trunk/dh-make-perl/dh-make-perl Sun Dec 26 12:35:09 2010
@@ -17,7 +17,7 @@
 
 =over
 
-=item dh-make-perl [make] {I<SOURCE_DIR> | --cpan I<MODULE>} I<options...>
+=item dh-make-perl [make] {I<SOURCE_DIR> | --cpan I<MODULE>|I<DIST>} I<options...>
 
 =item dh-make-perl refresh {I<--only ...>} [directory]
 
@@ -29,23 +29,22 @@
 
 =item dh-make-perl help
 
-=item cpan2deb I<DIST> I<options...>
+=item cpan2deb I<MODULE>|I<DIST> I<options...>
 
 =back
 
 =head1 DESCRIPTION
 
 B<dh-make-perl> will create the files required to build
-a debian source package out of a Perl module.
+a debian source package out of a Perl module or CPAN distribution.
 This works for most simple packages and is also useful
 for getting started with packaging Perl modules.
 
-You can specify a module name with the L<--cpan|/cpan_module> switch
-and B<dh-make-perl> will download the module for you from
-a CPAN mirror, or you can specify the directory with the
-already unpacked sources. If neither L<--cpan|/cpan_module> nor a directory
-is given as argument, B<dh-make-perl> tries to create a
-Perl package from the data in the current directory.
+You can specify a module or distribution name with the L<--cpan|/cpan_module>
+switch and B<dh-make-perl> will download it for you from a CPAN mirror, or you
+can specify the directory with the already unpacked sources. If neither
+L<--cpan|/cpan_module> nor a directory is given as argument, B<dh-make-perl>
+tries to create a Perl package from the data in the current directory.
 
 You can build and install the debian package using the L</--build>
 and L</--install> command line switches.
@@ -206,9 +205,10 @@
 your system - if a newer version of a core module breaks the API, all kinds
 of daemons might get upset ;-)
 
-=item B<--cpan> I<MODULE>
-
-Instructs B<dh-make-perl> to fetch and extract the given CPAN module.
+=item B<--cpan> I<MODULE>|I<DIST>
+
+Instructs B<dh-make-perl> to fetch and extract the given CPAN module or
+distribution. Works both with C<Foo::Bar> and C<Foo-Bar>.
 
 =item B<--cpan-mirror> I<MIRROR>
 
@@ -231,7 +231,7 @@
 will figure out the dependencies by itself. If you need to pass B<dh-make-perl>
 dependency information, you must do it using the debian package format. i.e.
 
-    dh-make-perl --depends libtest-more-perl 
+    dh-make-perl --depends libtest-more-perl
 
 =item B<--desc> I<SHORT DESCRIPTION>
 

Modified: trunk/dh-make-perl/lib/DhMakePerl/Command/make.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/lib/DhMakePerl/Command/make.pm?rev=66457&op=diff
==============================================================================
--- trunk/dh-make-perl/lib/DhMakePerl/Command/make.pm (original)
+++ trunk/dh-make-perl/lib/DhMakePerl/Command/make.pm Sun Dec 26 12:35:09 2010
@@ -44,7 +44,9 @@
 use Debian::Dependencies      ();
 use Debian::Dependency        ();
 use Debian::WNPP::Query;
-use DhMakePerl::Utils qw( find_cpan_module is_core_module );
+use DhMakePerl::Utils qw(
+    find_cpan_module find_cpan_distribution
+    is_core_module );
 use Email::Date::Format qw(email_date);
 use File::Basename qw( basename dirname );
 use File::Copy qw( copy move );
@@ -213,9 +215,9 @@
 sub setup_dir {
     my ($self) = @_;
 
-    my ( $dist, $mod, $tarball );
+    my ( $tarball );
     if ( $self->cfg->cpan ) {
-        my ($new_maindir, $orig_pwd);
+        my ( $new_maindir, $orig_pwd, $mod, $dist );
 
         # CPAN::Distribution::get() sets $ENV{'PWD'} to $CPAN::Config->{build_dir}
         # so we have to save it here
@@ -230,16 +232,32 @@
 
         $self->configure_cpan;
 
-        $mod = find_cpan_module( $self->cfg->cpan )
-            or die "Can't find '" . $self->cfg->cpan . "' module on CPAN\n";
-        $self->mod_cpan_version( $mod->cpan_version );
+        if ( $mod = find_cpan_module( $self->cfg->cpan ) ) {
+            $self->mod_cpan_version( $mod->cpan_version );
+
+            $dist = $CPAN::META->instance( 'CPAN::Distribution',
+                $mod->cpan_file );
+        }
+        elsif ( $dist = find_cpan_distribution( $self->cfg->cpan ) ) {
+            my $ver;
+            if ( $dist->base_id =~ /-(\d[\d._]*)\./ ) {
+                $self->mod_cpan_version($1);
+            }
+            else {
+                die "Unable to determine the version of "
+                    . $dist->base_id . "\n";
+            }
+        }
+        else {
+            die "Can't find '"
+                . $self->cfg->cpan
+                . "' module or distribution on CPAN\n";
+        }
 
         $tarball = $CPAN::Config->{'keep_source_where'} . "/authors/id/";
 
-        $dist = $CPAN::META->instance( 'CPAN::Distribution',
-            $mod->cpan_file );
-        $dist->get || die "Cannot get ", $mod->cpan_file, "\n"; # <- here $ENV{'PWD'} gets set to $HOME/.cpan/build
-        $tarball .= $mod->cpan_file;
+        $dist->get || die "Cannot get ", $dist->pretty_id, "\n"; # <- here $ENV{'PWD'} gets set to $HOME/.cpan/build
+        $tarball .= $dist->pretty_id;
         $self->main_dir( $dist->dir );
 
         copy( $tarball, $orig_pwd );

Modified: trunk/dh-make-perl/lib/DhMakePerl/Utils.pm
URL: http://svn.debian.org/wsvn/pkg-perl/trunk/dh-make-perl/lib/DhMakePerl/Utils.pm?rev=66457&op=diff
==============================================================================
--- trunk/dh-make-perl/lib/DhMakePerl/Utils.pm (original)
+++ trunk/dh-make-perl/lib/DhMakePerl/Utils.pm Sun Dec 26 12:35:09 2010
@@ -15,7 +15,7 @@
 
 our @EXPORT_OK = qw(
     find_core_perl_dependency
-    find_cpan_module
+    find_cpan_module find_cpan_distribution
     is_core_module
     nice_perl_ver
     split_version_relation
@@ -39,8 +39,8 @@
 Returns CPAN::Module object that corresponds to the supplied argument. Returns
 undef if no module is found by CPAN.
 
-If CPAN module needs to be configured in some way, that should be done before
-calling this function.
+If the CPAN module needs to be configured in some way, that should be done
+before calling this function.
 
 =cut
 
@@ -70,6 +70,25 @@
     $mod = shift @mod unless ($mod);
 
     return $mod;
+}
+
+=item find_cpan_distribution
+
+Returns CPAN::Distribution object that corresponds to the supplied argument.
+Returns undef if no distribution is found by CPAN.
+
+If the CPAN module needs to be configured in some way, that should be done
+before calling this function.
+
+=cut
+
+sub find_cpan_distribution {
+    my( $name ) = @_;
+
+    $name =~ s/::/-/g;
+
+    return CPAN::Shell->expand( 'Distribution',
+        "/\\/$name-[^\\/]+\\.(tar|zip)/" );
 }
 
 =item is_core_module I<module>, I<version>




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