Introduction

It is a common pattern: customers let me develop on hosts that cannot access Internet directly. Opening connectivities takes always a lot of time and sometimes it is against policies, but there is a hope…

The camel replicates!

In this article host.customer.com is that kind of host, and of course it is needed a myhost.example.org that can connect to Internet or at least to a CPAN mirror.

If you want a full featured tool, consider using Pinto or Carton: this article describes just a very simple trick I found to deal with this network limitation.

Requirements

I assume both hosts has same OS and Perl version for simplicity. In particular, different versions of Perl can lead to issues when resolving dependencies on core modules.

Start on myhost.example.org: you need a working cpan client that had at least a first run. It is nice to have A CPAN client that works like a charm.

Implementation

The trick is to realize that ~/.cpan/sources is a mini CPAN mirror with all dependencies needed.

So install everything you need with your cpan client on myhost.example.org. I usually have a Makefile.PL that includes all dependencies information, it is a good idea.

If everything looks ok, I mean stable, then launch

$ cd ~/.cpan/sources
$ tar czf /tmp/cpanSources.tar.gz modules/ authors/

Now, transfer cpanSources.tar.gz to host.customer.com somehow. I usually need to connect opening some VPN, so I do not assume there is a connection between the hosts.

On host.customer.com make sure you have a working cpan client too, then

$ mkdir -p /home/unica/.cpan/sources
$ cd ~/.cpan/sources
$ tar xzf /path/to/cpanSources.tar.gz

and you are done! Your cpan client on host.customer.com will not fetch sources from CPAN mirrors. In fact, by default, cpan uses the ~/.cpan/sources for caching the sources tarballs, and if the distro is already there it will not try to download it. Hence you can install all dependencies needed by your package even in those hosts that are isolated from Internet, those hosts where probably you work to pay your rent :)