Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^3: Automating CPAN Configuration

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


in reply to Re^2: Automating CPAN Configuration
in thread Automating CPAN Configuration

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.


Comment on Re^3: Automating CPAN Configuration
Re^4: Automating CPAN Configuration
by Anonymous Monk on Feb 15, 2008 at 19:17 UTC
    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;

      Update: I've since discovered that I prefer cpanm

      Using your code as a starter, here is what I'm using. I think it's a bit simpler not having to rewrite the FirstTime.pm file:
      ######################################## # Get CPAN::Config.pm initialized export PERL_MM_USE_DEFAULT=1 PERL_MM_NONINTERACTIVE=1 AUTOMATED_TESTIN +G=1 perl <<'EOT' || exit use strict; use Data::Dumper; # 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 { local @ARGV = "$libpath/CPAN/FirstTime.pm"; my @source = <>; $source[72] =~ s/\byes\b/no/ or die "Could not auto configure CPAN"; eval join('', @source) or die "Error executing CPAN::FirstTime: $@"; } CPAN::FirstTime::init("$libpath/CPAN/Config.pm"); delete $CPAN::Config->{links}; $CPAN::Config->{auto_commit} = '0'; $CPAN::Config->{check_sigs} = '0'; $CPAN::Config->{halt_on_failure} = '0'; $CPAN::Config->{make_install_make_command} = '/usr/bin/make'; $CPAN::Config->{mbuild_arg} = ''; $CPAN::Config->{mbuildpl_arg} = ''; $CPAN::Config->{mbuild_install_arg} = ''; $CPAN::Config->{show_upload_date} = ''; $CPAN::Config->{tar_verbosity} = '1'; $CPAN::Config->{trust_test_report_history} = '0'; $CPAN::Config->{use_sqlite} = '0'; $CPAN::Config->{yaml_load_code} = '0'; $CPAN::Config->{urllist} = [q[ftp:...your list.../], q[http://...your list...]]; $CPAN::Config->{connect_to_internet_ok} = '1'; $CPAN::Config->{perl5lib_verbosity} = 'v'; $CPAN::Config->{prefer_installer} = 'MB'; $CPAN::Config->{build_requires_install_policy} = 'no'; $CPAN::Config->{term_ornaments} = '1'; $CPAN::Config->{mbuild_install_build_command} = './Build'; mkdir ".cpan/CPAN" or die "Can't create .cpan/CPAN: $!"; CPAN::Config->commit(".cpan/CPAN/MyConfig.pm"); CPAN::install('Bundle::CPAN'); #CPAN::force('install', ''); CPAN::install('JSON'); CPAN::install('JSON::XS'); exit 0; EOT

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (13)
As of 2014-07-29 15:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (220 votes), past polls