cpanm: Is it possible to install a localized version of cpanm for one-shot use?

[email protected] (James E Keenan)
Newsgroups perl.cpan.workers
Message-ID <[email protected]>
Q. Why would you want to do this?

A. Because I am trying to adapt/modularize a program written by another 
developer which installs cpanm to a previously-cpanm-free environment 
for use in testing.  I want to be able to use this program in 
environments where cpanm is already installed.

Q. Can you be more specific?  What's the program you're trying to 
modularize?

A. It's a program I call 'khwdebug.sh'; sanitized version attached.  It 
was written by Karl Williamson, an important contributor to the Perl 5 
core distribution and to the Perl 5 Porters mailing list, to address 
particular bug reports filed on rt.perl.org.

Q. Which bug reports?

A. Long-time Perl contributor Andreas Koenig tests CPAN modules against 
Perl 5 blead.  When a CPAN distribution known to work on a released 
version of Perl 5 suddenly starts to fail tests when run against blead, 
a 'perlbug' process generates an RT ticket.  The author of the CPAN 
distribution gets notified.

But it's often useful for people other than Andreas to try to confirm 
the test failure report.  Karl Williamson (khw) wrote a program to do 
that.  It is set up to run on the Perl 5 development server known as 
'dromedary' which is donated to us by booking.com.  I've started to run 
'khwdebug.sh' on dromedary as well.

Q. What good will modularizing this program do?

A. It will enable people who do not have access to the dromedary server 
to test CPAN distributions against blead more easily than they can do 
now.  And it will enable us to determine whether tests are failing on 
platforms other than the Linux/x86_64 found on dromedary.

Q. Where does 'cpanm' come into all this?

A. khwdebug.sh builds Perl 5 blead and installs it into a user-specified 
testing directory.  Example:

dir=/home/jkeenan/testing/blead

./Configure -des -Dusedevel -Uversiononly -Dprefix=$dir -Dman1dir=none 
-Dman3dir=none

make -j$test_jobs install

khwdebug.sh then downloads the fatpacked version of cpanm from the 
network and builds and installs it into the same directory as the blead 
'perl' executable.

wget --no-check-certificate -O- -q http://bit.ly/cpanm |$dir/bin/perl - 
-v App::cpanminus

Remember:  This is happening on a machine where 'cpanm' is not installed 
by default.

khwdebug.sh then uses that version of 'cpanm' to download a CPAN distro 
from a mirror and prepare all its dependencies.

module=Text::CSV::Hashify
$dir/bin/cpanm --installdeps $module

khwdebug.sh then makes use of the nifty '--look' option to cpanm to open 
a sub-shell, change to the directory where the CPAN distro has been 
unpacked, and prompt the user to run 'perl Makefile.PL' where the 'perl' 
in question is the recently installed blead:

echo "About to cd a work space directory" >&2
echo "From there, run '$dir/bin/perl Makefile.PL'" >&2
echo "And then, probably 'make test'" >&2

$dir/bin/cpanm --look $module

The user then creates a Makefile and runs 'make test' (or similarly if 
the distro uses Module::Build).  The user can then confirm the test 
failure report and perform local debugging.  The more confirmations we 
get from more platforms, the more we can be sure that we have a real 
problem.

Q. Alright, so what's the problem with 'cpanm'?

A. When you try to do a bootstrapped installation of the fatpacked 
version of 'cpanm', it, not surprisingly, asks if App::cpanminus is 
already installed.  If cpanm is already installed, then no additional 
version is installed into $dir/bin/.  But at a certain point, 
khwdebug.sh expects to be able to find and use $dir/bin/cpanm.  When 
that expectation is not meant, khwdebug.sh cannot proceed.

Thank you very much.
Jim Keenan
sanitized_khwdebug.sh (application/x-shellscript, 1.3 KB)
# Set up to debug a CPAN module using a development Perl, such as blead.
# Run this shell script while cd'd to the directory containing the Perl source

set -x
PERL5OPT=       # In case you have this set, it shouldn't be for these purposes
test_jobs=8    # Set to a suitable number for parallelism on your system
dir=/home/user/testing/blead    # Set to a suitable directory where you want the
                            # devel perl installed, for the purpose of testing

# Add whatever other Configure options you need.  To use gdb, I like to have
# -DDEBUGGING=both
# or "-DDEBUGGING=-g" if the problem doesn't happen on a DEBUGGING build.
# -A'optimize=-O0' 
./Configure -des -Dusedevel -Uversiononly -Dprefix=$dir -Dman1dir=none -Dman3dir=none

make -j$test_jobs install

# Get cpanm
wget --no-check-certificate -O- -q http://bit.ly/cpanm |$dir/bin/perl - -v App::cpanminus

# $module is the module being tested.  I like to just add ones to the end, to
# keep a record of what I've worked on.
# Note: Issues with these modules have not necessarily been resolved.
#module=CDB_File
module=Text::CSV::Hashify

# Get it and its dependencies
$dir/bin/cpanm --installdeps $module

set +x

echo "About to cd a work space directory" >&2
echo "From there, run '$dir/bin/perl Makefile.PL'" >&2
echo "And then, probably 'make test'" >&2

$dir/bin/cpanm --look $module
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.