Is there a way to save off the binary artifacts from a cpanm installed module for distribution to like systems?

163 views Asked by At

I am creating an image in wsl with scripting starting from a base Amazon Linux2 import. The following is some of the scripting. The {{THIRDPARTYCACHE}} label is replaced with a path to persistent storage, persistent in that it survives through distribution unregistration (image destroy) :

    sudo yum -y --setopt=cachedir={{THIRDPARTYCACHE}}/yum/cache install \
dejavu-sans-fonts.noarch \
freetds \
mailx \
moreutils \
nmon \
perl-Archive-Zip \
perl-Class-Accessor \
perl-DateTime \
perl-DateTime-Format-Strptime \
perl-DBD-MySQL \
perl-DBI \
perl-Digest-SHA \
perl-GD \
perl-JSON \
perl-libwww-perl \
perl-Log-Log4perl \
perl-LWP-Protocol-https \
perl-parent \
perl-XML-Parser \
pigz \
rng-tools \
ruby \
smem \
sysstat \
tree \
nmap-ncat \
git \
git-lfs \
xorg-x11-server-Xvfb \
wget \
openssl11 \
"perl(Data::Dump)" \
libXtst \
which \
perl-Coro \
perl-AnyEvent-AIO \
perl-PadWalker \
perl-App-cpanminus \
net-tools \
nss-tools 

sudo yum -y --setopt=cachedir={{THIRDPARTYCACHE}}/yum/cache group install "development tools"
sudo cpanm --no-test Perl::LanguageServer

The last two lines take a significant amount of time and successfully achieve the desired result of the installing the perl module Perl::LanguageServer. The final message from cpanm is: Successfully installed Perl-LanguageServer-v2.5.0 48 distributions installed

I'm looking for a way that I could cache the Perl::LanguageServer (along with all it's dependencies) allowing the ability to potentially skip the development tools group install and the compile/build of the module and all it's dependencies.

1

There are 1 answers

6
brian d foy On

@ikegami's suggestion of making packages of the complete Perl module installation is a good one. That also lets you stabilize the installation since the major CPAN tools prefer to upgrade whenever possible;they install the latest version when asked and not told otherwise. If you can make packages, do that. In some separate directory, install a perl for your project, install all the modules in it, and wrap up that directory into your package.

Emil Perhinschi reminded my on Twitter that DhMakePerl exists. The Debian people have very good tools for making Perl packages. I know you say you are on Amazon Linux (RedHat or Fedora based I think), but other people might find those tools handy. I don't know much about packaging.

But, aside from deploying a package, you can speed up the installation with cpan or cpanm by not testing the modules. You'll want to know if they work, but you only need to do that once:

 % cpan -T ...
 % cpanm --notest ...

Using cpanm over cpan means you can skip downloading very large data file, but cpanm means more network connections.

If you want to host all of the modules yourself (say, in an MiniCPAN, you can cut down on the time to download modules.

And last, there's a balance between the number of third-party modules you want to use and the ease of your deployment. Different people have different tolerances for that. Consider if you really need some of the modules you use and if that causes too much pain in the sysadmin side. Using one module might come with tens of other distributions as dependencies (and this is especially true with Test::* modules). MetaCPAN shows dependencies. For example, if you want just the current year, do you really need DateTime?