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

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?

Replies are listed 'Best First'.
Re^3: Automating CPAN Configuration
by doc_faustroll (Scribe) on May 12, 2006 at 17:48 UTC
    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;

        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