[Catalyst] Local lib bootstrapper and CPAN installer

Matt Pitts mpitts at a3its.com
Wed Dec 3 16:32:02 GMT 2008


I'm hoping some folks find this useful and others who are familiar with
"use CPAN" can help me solve my problem...

As part of my deployment process for a Catalyst app I'm keeping pretty
much the entire dependency stack resident with it in a 'locallib'
directory. As a result I've created the following bootstrapper for the
local libs...

################ BEGIN script/AppBootstrap.pm ####################

package main;

use FindBin;
use Path::Class;

our $PARENT;
our @LIBS;
our @LOCALLIBS;

BEGIN {
    $PARENT = dir($FindBin::Bin)->parent;
    
    push @LIBS, $PARENT->subdir('lib')->stringify;
    push @LIBS, $PARENT->subdir('ext-lib')->stringify;
    
    unless ( $ENV{SKIP_LOCALLIB} ) {
        push @LIBS, $PARENT->subdir('locallib', 'lib', 'perl5',
'site_perl')->stringify;
        push @LOCALLIBS, $PARENT->subdir('locallib')->stringify;
    }
}

use lib(@LIBS);
use local::lib(@LOCALLIBS);

1;

#################### END #####################



It's a little bit system-dependent, but it still works quite well for us
because we run a lot of identical Linux VMs. So, now in all my 'myapp_'
scripts I can just use the following piece of code to bootstrap and call
up the app

###################### BEGIN #################

use FindBin;
use lib("$FindBin::Bin");
use AppBootstrap;

use MyApp;

################# END #######################



I'm to the point, however that I really want a clean way of installing
additional dependencies into my locallib via CPAN - something like
another myapp_cpan.pl script that I can just invoke and get a properly
configured CPAN shell. I've put something together, but it doesn't
really work the way I'd like...

################# BEGIN script/myapp_cpan_locallib.pl ###############

#!perl

use strict;
use warnings;

BEGIN {
    $ENV{CATALYST_DEBUG} = 0;
    $ENV{CATALYST_SCRIPT_GEN} = 31;
}

use FindBin;
use lib("$FindBin::Bin");
use AppBootstrap;

use Path::Class;
use CPAN ();

my $APP_DIR = dir($FindBin::Bin)->parent->stringify;

print "Using APP_DIR: $APP_DIR\n";

$ENV{PERL5LIB} ||= "";
$ENV{PERL5LIB}  
    = join(':', 
        $ENV{PERL5LIB}, 
        "$APP_DIR/locallib/lib/perl5/site_perl", 
        "$APP_DIR/locallib/lib/perl5/"
    );

CPAN::Shell->mkmyconfig('~/.cpan/CPAN/MyConfig.pm');
CPAN::Shell->o('conf', 'makepl_arg', "PREFIX=$APP_DIR/locallib");
CPAN::Shell->o('conf', 'mbuildpl_arg', "--install_base
$APP_DIR/locallib");
CPAN::Shell->o('conf', 'commit', '~/.cpan/CPAN/MyConfig.pm');
CPAN::shell;

############################### END #################################


1st - CPAN wants to run the configuration system each time I run this
even though I'm invoking a commit of MyConfig.pm. This doesn't bother me
too much, because it auto populates the values, but it may be a cause of
my 2nd problem.

2nd - When attempting to install modules via the command line, many of
them fail during the build with the following message...


################### BEGIN ###################################

CPAN.pm: Going to build
L/LB/LBR/Catalyst-Plugin-Session-Store-Cache-0.01.tar.gz

Checking if your kit is complete...
Looks good
Only one of PREFIX or INSTALL_BASE can be given.  Not both.
Warning: No success on command[/usr/bin/perl Makefile.PL
PREFIX=/home/mpitts/dev/MyApp/locallib]
  LBR/Catalyst-Plugin-Session-Store-Cache-0.01.tar.gz
  /usr/bin/perl Makefile.PL PREFIX=/home/mpitts/dev/MyApp/locallib --
NOT OK
Running make test
  Make had some problems, won't test
Running make install
  Make had some problems, won't install
Failed during this command:
 LBR/Catalyst-Plugin-Session-Store-Cache-0.01.tar.gz: writemakefile NO
'/usr/bin/perl Makefile.PL PREFIX=/home/mpitts/dev/MyApp/locallib '
returned status 65280

######################## END ##############################


I've tried in vain to figure out where/how/why INSTALL_BASE is set, but
alas I have failed.

Any assistance on this is much appreciated.

v/r

-matt



More information about the Catalyst mailing list