Installing modules from CPAN *and* your own DarkPAN

I currently maintain several DarkPAN's. A DarkPAN, as some of you might already know, is a CPAN-like repository but which is not CPAN. The "dark" term refers to the fact that it is not being published on the Internet, but usually behind a corporate firewall. The most common use-case is for companies creating their code as Perl distributions and wanting to use the CPAN toolchain to deploy modules. In my case, some of the DarkPANs are not actually "dark" because I publish them on the Internet.

There are two general ways to create a DarkPAN. First, you start with an existing CPAN mirror and then "inject" additional modules (you can use CPAN::Mini::Inject for this). Second, you start empty and create the CPAN-like structure using modules like CPAN::Faker and OrePAN.

The inject way is not really proper (akin to monkey-patching) but works with the old standard CPAN client. The latter is supported by cpanminus using multiple --mirror options. For example:

% cpanm --mirror http://first-darkpan --mirror http://second-darkpan --mirror http://cpan-mirror --mirror-only Foo::Bar

Foo::Bar is first searched at http://first-darkpan. If it is not found, cpanm then falls back to the second mirror http://second-darkpan, and finally the last mirror is your nearest CPAN mirror. This way, you can conveniently install your dark modules which have dependencies to CPAN modules. The only inconvenience at the moment is the error messages cpanm spews after it fails finding each module on each mirror.

Before somebody mentions Pinto, I am aware of it and haven't used it yet. I assume it will make it possible to mix and match CPAN modules and your own dark modules too.

1 Comment

Pinto... I assume it will make it possible to mix and match CPAN modules and your own dark modules too

That's correct. And the nice thing is (IMHO) that the repository is stable, so you'll always get the same version of the CPAN libraries, until you decide to change them.

Leave a comment

About Steven Haryanto

user-pic A programmer (mostly Perl 5 nowadays). My CPAN ID: SHARYANTO. I'm sedusedan on perlmonks. My twitter is stevenharyanto (but I don't tweet much). Follow me on github: sharyanto.