views:

1408

answers:

7

What do I need to setup and maintain a local CPAN mirror? What scripts and best practices should I be aware of?

+2  A: 

Try CPAN::Mini http://search.cpan.org/~rjbs/CPAN-Mini-0.571/

mopoke
Or, if that link disappears because it's tied to a particulr version, try <a href="http://search.cpan.org/dist/CPAN-Mini">CPAN::Mini</A>. See <a href="http://stackoverflow.com/questions/43758">How to link to CPAN modules in answers</a> for the discussion of timeless linking. :)
brian d foy
+6  A: 

This could be useful: http://www.cpan.org/misc/cpan-faq.html#How_mirror_CPAN

LeaChim
+2  A: 

Randal Schwartz wrote an article about mirroring The CPAN that I've found quite useful: http://www.stonehenge.com/merlyn/LinuxMag/col43.html

zigdon
+14  A: 

CPAN::Mini is the way to go. Once you've mirrored CPAN locally, you'll want to set your mirror URL in CPAN.pm or CPANPLUS to the local directory using a "file:" URL like this:

file:///path/to/my/cpan/mirror

If you'd like your mirror to have copies of development versions of CPAN distribution, you can use CPAN::Mini::Devel.

Update:

The "What do I need to mirror CPAN?" FAQ given in another answer is for mirroring all of CPAN, usually to provide another public mirror. That includes old, outdated versions of distributions. CPAN::Mini just mirrors the latest versions. This is much smaller and for most users is generally what people would use for local or disconnected (laptop) access to CPAN.

xdg
+4  A: 

CPAN::Mini is fine. By default it keeps only the latest version of a distribution, not every version as CPAN does.

You can also install CPAN::Mini::Webserver, which provides you with a web interface to your local cpan mirror - very handy if you are offline and still want to work with perl.

moritz
+1  A: 

The most likely scenario for running a CPAN mirror is so that your network of 50 machines can all be updated from it locally, instead of hitting the network 50 times.

I'd argue that using CPAN in the traditional manner is a poor way to keep a network of servers up to date.

I run a network of RedHat machines. I package all CPAN modules intended for use in production into RPMs (mostly using the cpanflute2 tool from RPM::Specfile) and deploy them that way, thereby ensuring proper dependency tracking which you don't really get from CPAN itself in any sane way.

Jon Topper
And I hope you don't use RedHat's vendor perl? it's full of problematic "fixes" that the perl developers shake their heads about.If we receive a bug report from a RedHat user, the first step is always to verify that it's a problem with perl, not with RedHat. Most of the time it *is* RedHat.
moritz
+1  A: 
brian d foy