6cc1a4901489d102690a6df7aff097eb411dd7b9
[dbsrgits/DBIx-Class.git] / maint / travis-ci_scripts / 20_install.bash
1 #!/bin/bash
2
3 source maint/travis-ci_scripts/common.bash
4 if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then return ; fi
5
6 CPAN_MIRROR=$(echo "$PERL_CPANM_OPT" | grep -oP -- '--mirror\s+\S+' | head -n 1 | cut -d ' ' -f 2)
7 if ! [[ "$CPAN_MIRROR" =~ "http://" ]] ; then
8   echo_err "Unable to extract primary cpan mirror from PERL_CPANM_OPT - something is wrong"
9   echo_err "PERL_CPANM_OPT: $PERL_CPANM_OPT"
10   CPAN_MIRROR="http://cpan.develooper.com/"
11   echo_err "Using $CPAN_MIRROR for the time being"
12 fi
13
14 export PERL_MM_USE_DEFAULT=1 PERL_MM_NONINTERACTIVE=1 PERL_AUTOINSTALL_PREFER_CPAN=1 PERLBREW_CPAN_MIRROR="$CPAN_MIRROR"
15
16 # Fixup CPANM_OPT to behave more like a traditional cpan client
17 export PERL_CPANM_OPT="--verbose --no-interactive $( echo $PERL_CPANM_OPT | sed 's/--skip-satisfied//' )"
18
19 if [[ -n "$BREWVER" ]] ; then
20   run_or_err "Compiling/installing Perl $BREWVER (without testing, may take up to 5 minutes)" \
21     "perlbrew install --as $BREWVER --notest --verbose $BREWOPTS -j 2  $BREWVER"
22
23   # can not do 'perlbrew uss' in the run_or_err subshell above
24   perlbrew use $BREWVER || \
25     ( echo_err -e "Unable to switch to $BREWVER - compillation failed?\n$LASTOUT"; exit 1 )
26 fi
27
28 # configure CPAN.pm - older versions go into an endless loop
29 # when trying to autoconf themselves
30 CPAN_CFG_SCRIPT="
31   require CPAN;
32   require CPAN::FirstTime;
33   *CPAN::FirstTime::conf_sites = sub {};
34   CPAN::Config->load;
35   \$CPAN::Config->{urllist} = [qw{ $CPAN_MIRROR }];
36   \$CPAN::Config->{halt_on_failure} = 1;
37   CPAN::Config->commit;
38 "
39 run_or_err "Configuring CPAN.pm" "perl -e '$CPAN_CFG_SCRIPT'"