2

我正在创建一个捆绑包,以便轻松安装我的应用程序。我从这里开始:http ://search.cpan.org/dist/CPAN/lib/CPAN.pm#Bundles

我有一个包 Bundle::MyApp ,它看起来像这样:

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

我在我的本地机器上测试它,所以我把包放到我的 cpan 文件夹中,例如:~/.cpan/Bundle/MyApp.pm

现在我可以使用它运行它cpan install Bundle::MyApp并且它可以工作,只是它没有安装我列出的模块所需的依赖项。所以在这个例子中,cpan 首先尝试安装 DateTime 但安装失败,因为首先需要 DateTime::Locale,然后它尝试安装 Image::Size 并且由于需要 deps 而失败。

如果我直接通过 cpan 安装 DateTime 模块,则使用cpan install DateTime它可以正常工作并安装依赖项。

所以我正在寻找一种方法来告诉 CPAN 在从我的包安装时遵循依赖关系。我的包裹里有什么需要放的吗?还是我的用户帐户的 CPAN 配置有问题?

4

1 回答 1

1

模块依赖

在 Makefile.PL 中,您可以列出必备模块。来自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,
         }

还有一个 PREREQ_PRINT 和 PREREQ_FATAL。

捆绑文件格式

CONTENTS 部分中捆绑行的格式需要用空行分隔依赖项。

# @(#)$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<jleffler@informix.com>E<gt>

=head1 THANKS

This bundle was created by ripping off Bundle::libnet created by 
Graham Barr E<lt>F<gbarr@ti.com>E<gt>, and radically simplified
with some information from Jochen Wiedmann E<lt>F<joe@ispsoft.de>E<gt>.

=cut
于 2010-04-13T15:07:45.110 回答