开发者

How can I install several CPAN distributions at once?

I have recently started some Perl development and use CPAN to install all my packages. I was wondering if there are some "best practices" to manage required packages for a script or application. So far, I'm doing it the inelegant and cumbersome way. I have a script which looks like this :

inst开发者_如何学JAVAall Foo::Bar
install Zulu::Car
...

and then I do

$perl -MCPAN -e shell < mycpan.foo


Even if you won't be uploading it, build your application like a CPAN module.

That basically means you have a Makefile.PL that describes the dependencies formally, and your application is in the script/ directory as myapplication (assuming it's a command line/desktop app).

Then, someone can use the CPAN client to install your module and it's dependencies directly, but untarring the tarball and then running

cpan .

Alternatively, the pip tool will let people install your application from a remote URL directly.

pip http://someserver.com/Your-Application-0.01.tar.gz


This is why Task::* distributions exist. You list all the distributions that you want to install as dependencies in your Task:: distribution. The Task distro itself doesn't supply anything.

If you are inside the directory where you have set up your Task:

 $ cpan .

If you have you Task in a MiniCPAN or DPAN, then you can install it by name:

 $ cpan Task::WhateverYouCalledIt

Once CPAN.pm gets ahold of it, it will automatically install all of the dependencies.


I wouldn't be happy if I downloaded your script and it automatically installed some CPAN packages. The normal thing to do is to simply list the dependencies in the documentation, and let the user install them himself in whatever manner he prefers.

If you're creating a CPAN module yourself, there is a standard way of denoting dependencies in your CPAN installation script, which is created for you with your distribution maker (e.g. ExtUtils::MakeMaker or Module::Install).


I've found that for large-scale production systems relying on a third-party code source such as CPAN for production deployments is impractical. Therefore I have always used a system such as apt, rpm, or GNU stow to build packages for all of a system's dependencies, and then a deployment script which uses the package manager to deploy all necessary packages to production servers.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜