views:

200

answers:

1

I'm creating a bundle to make it easy to install my app. I started here: http://search.cpan.org/dist/CPAN/lib/CPAN.pm#Bundles

I have a package Bundle::MyApp which looks like this:

package Bundle::MyApp;

$VERSION = '0.01';

1;

__END__

=head1 NAME

Bundle::MyApp - modules needed by my app

=head1 SYNOPSIS

cpan install Bundle::MyApp

=head1 CONTENTS

DateTime
Image::Size

I'm testing it on my local machine, so I put the package into my cpan folder, eg: ~/.cpan/Bundle/MyApp.pm

Now I can run it using cpan install Bundle::MyApp and it works, except that it doesn't install the dependencies required by the modules I have listed. So in this example, cpan first tries to install DateTime but the install fails because DateTime::Locale is needed first, then it tries to install Image::Size and that fails too beacuse there are deps needed.

If I install the DateTime module directly via cpan using cpan install DateTime it works fine and dependencies are installed.

So I'm looking for a way to tell CPAN to follow dependencies when its installing from my bundle. Is there something I need to put in my package? or maybe it's an issue with the CPAN config for my user account?

+1  A: 

Module dependencies

In Makefile.PL, you can list pre-requisite modules. From perldoc ExtUtils::MakeMaker:

   PREREQ_PM
     A hash of modules that are needed to run your module.  The keys are
     the module names ie. Test::More, and the minimum version is the
     value. If the required version number is 0 any version will do.

     This will go into the "requires" field of your META.yml.

         PREREQ_PM => {
             # Require Test::More at least 0.47
             "Test::More" => "0.47",

             # Require any version of Acme::Buffy
             "Acme::Buffy" => 0,
         }

There is also a PREREQ_PRINT and PREREQ_FATAL.

Bundle file format

The format for the bundle lines in the CONTENTS section requires blank lines separating the dependencies.

# @(#)$Id: Informix.pm,v 95.1 1999/11/18 22:10:59 jleffler Exp $

package Bundle::DBD::Informix;

$VERSION = '0.95';

1;

__END__

=head1 NAME

Bundle::DBD::Informix - A bundle to install all DBD::Informix related modules

=head1 SYNOPSIS

C<perl -MCPAN -e 'install Bundle::DBD::Informix'>

=head1 CONTENTS

Digest::MD5  - Perl interface to the MD5 Algorithm by GAAS (Gisle Aas)

Bundle::DBI  - Bundle for DBI by TIMB (Tim Bunce)

DBD::Informix  - DBD::Informix by JOHNL (Jonathan Leffler)

=head1 DESCRIPTION

This bundle includes all the modules used by the Perl Database
Interface (DBI) driver for Informix (DBD::Informix), assuming the
use of DBI version 1.02, created by Tim Bunce.

If you've not previously used the CPAN module to install any
bundles, you will be interrogated during its setup phase.
But when you've done it once, it remembers what you told it.
You could start by running:

    C<perl -MCPAN -e 'install Bundle::CPAN'>

Note that DBD::Informix does not directly use Digest::MD5.  However, if
Informix R&D or Tech Support takes over DBD::Informix (which, as of
1999-11-17, they have not agreed to do), then you will be required to
demonstrate that the MD5 checksums of the code you've got match the
original, or you'll be required to provide the diffs between the original
and what you are using.  The shell script md5.verify and Perl script
md5.check will be used to do this.

=head1 SEE ALSO

Bundle::DBI

=head1 AUTHOR

Jonathan Leffler E<lt>F<[email protected]>E<gt>

=head1 THANKS

This bundle was created by ripping off Bundle::libnet created by 
Graham Barr E<lt>F<[email protected]>E<gt>, and radically simplified
with some information from Jochen Wiedmann E<lt>F<[email protected]>E<gt>.

=cut
Jonathan Leffler
Cheers, but I've tried with and without the blank lines and the results were identical.
nick
I don't think PREREQ_PM helps in this situation (?). It wouldn't be practical to list long dependency chains in Makefile.PL especially as the deps could change if modules are updated in future.
nick
You only need to list the modules you directly depend upon in PREREQ_PM in your Makefile.PL; CPAN will take care of the rest.Bundles are best used to group together related modules into a logical "meta-module" so that you can ask to install, but you appear to be attempting to use a bundle to declare your dependencies.
David Precious
David, this bundle is simply to aid installation of a large app by getting many of the relevent modules installed (the app itself doesn't have an installer as such, and I can't change that right now). If there is a better way I'm open to it. When you say "CPAN will take care of the rest"... that's exactly my problem: it doesn't in this instance, and I don't understand why, or how to resolve it.
nick