Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Automating CPAN Configuration

by doc_faustroll (Scribe)
on May 12, 2006 at 01:48 UTC ( #548881=note: print w/ replies, xml ) Need Help??


in reply to Automating CPAN Configuration

I was doing some automation and auto bootstrapping of CPAN, but since I was creating configure and enviro bootstrap scripts to set up an environment for a Java application on n hosts, I elected to use PAR to bundle the scripts into executables that can be deployed to hosts fully formed with modules installed and a standardized version of Perl included, if need be.

What in particular is the application or script or suite of scripts that needs these modules installed? Is automation of CPAN install really desirable when you don't know the version of Perl on these hosts? In the case of that kind of heterogeneity, I would go with PAR. Unless, of course there is some compelling reason to work with CPAN auto install.


Comment on Re: Automating CPAN Configuration
Re^2: Automating CPAN Configuration
by dsheroh (Parson) on May 12, 2006 at 15:31 UTC
    What in particular is the application or script or suite of scripts that needs these modules installed?

    I'm currently supposed to be a hired gun helping out this company's sysadmin team, but they quickly noticed that I have a strong Perlish bent and decided they'd rather have me making tools to help the admins out instead of actually doing admin work. (Spend my time writing code instead of answering calls from users? Sounds good to me!)

    The particular apps/scripts/suite, then, is the few bits of what I've been doing which need to be run locally on each host rather than from a central location. So not a lot there that's likely to be dependent on specific versions of either perl or any modules. I suppose there's the possibility that a module could be incompatible with a certain version of perl, but none of the versions in use here are that old - it's mostly 5.6.1 with a bit of 5.8.0 and 5.8.5 mixed in here and there.

    I'd be interested to hear more about PAR, though - I've never run across it before. Can you recommend any links?

      the pp packager from the PAR distribution works quite well, although you must thoroughly test the packaged executable on a sample of target machines. I have noticed that an occasional dependency is not picked up.

      A recent client was extremely frustrated when an executable did not work on one of their target machines even though it passed all tests on mock target machines. I added an additional runtime check -c to the pp call and that fixed the problem.

      you can install PAR via cpan. pp will be a part of the install.

      I myself would like to see a list of issues or problems that people have had with pp. I'm using it in a similar admin centric tool dev way that I anticipate you could be using it and it is working well for me. You should explicitly declare your use of modules at the top of your script, especially if you are using dbd modules rather than just load them within DBI.

        After several Days of working this out, I finally got it to work. The finished result is below. Thanks for Perl Monks for the ideas from this thread. Wouldn't have been able to do it without you!
        #!/usr/bin/perl -w use strict; # get the path to the library use Config; my $libpath = $Config{privlib}; # force CPAN::FirstTime to not default to manual # setup, since initial CPAN setup needs to be automated system("perl -pi -e\'\$. == 73 and s/yes/no/\' $libpath/CPAN/FirstTime +.pm"); # initialize the Config.pm file use Env; $ENV{PERL_MM_USE_DEFAULT} = 1; require CPAN; require CPAN::FirstTime; CPAN::FirstTime::init("$libpath/CPAN/Config.pm"); delete $ENV{PERL_MM_USE_DEFAULT}; # undo the change system("perl -pi -e\'\$. == 73 and s/no/yes/\' $libpath/CPAN/FirstTime +.pm"); # read in the Config.pm file open(CONFIGFILE,"<","$libpath/CPAN/Config.pm"); my @lines = <CONFIGFILE>; close CONFIGFILE; # ..delete it unlink "$libpath/CPAN/Config.pm"; # ..and then write it back out, replacing the line with the empty arra +y urllist with a filled in array open(NEWFILE,">","$libpath/CPAN/Config.pm"); foreach(@lines){ if($_ =~ m/urllist/){ print NEWFILE " \'urllist\' => [\'http://ppm.activestate.com/ +CPAN\', \'http://cpan.perl.org\'],\n";} else{ print NEWFILE $_;}} close NEWFILE; # install the packages CPAN::install('SOAP::Lite'); CPAN::install('XML::Simple'); 1;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://548881]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (12)
As of 2014-11-26 19:13 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My preferred Perl binaries come from:














    Results (172 votes), past polls