Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

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.

Replies are listed 'Best First'.
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"); # initialize the file use Env; $ENV{PERL_MM_USE_DEFAULT} = 1; require CPAN; require CPAN::FirstTime; CPAN::FirstTime::init("$libpath/CPAN/"); delete $ENV{PERL_MM_USE_DEFAULT}; # undo the change system("perl -pi -e\'\$. == 73 and s/no/yes/\' $libpath/CPAN/FirstTime"); # read in the file open(CONFIGFILE,"<","$libpath/CPAN/"); my @lines = <CONFIGFILE>; close CONFIGFILE; # ..delete it unlink "$libpath/CPAN/"; # ..and then write it back out, replacing the line with the empty arra +y urllist with a filled in array open(NEWFILE,">","$libpath/CPAN/"); foreach(@lines){ if($_ =~ m/urllist/){ print NEWFILE " \'urllist\' => [\' +CPAN\', \'\'],\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 file:
      ######################################## # Get 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/"; 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/"); 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/"); CPAN::install('Bundle::CPAN'); #CPAN::force('install', ''); CPAN::install('JSON'); CPAN::install('JSON::XS'); exit 0; EOT

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://549073]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2018-05-27 02:10 GMT
Find Nodes?
    Voting Booth?