Use the same mirror for cpanm as we use for CPAN
[dbsrgits/DBIx-Class.git] / maint / travis-ci_scripts / 20_install.bash
CommitLineData
b58ecb01 1#!/bin/bash
2
3source maint/travis-ci_scripts/common.bash
4if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then return ; fi
5
b2435630 6CPAN_MIRROR=$(echo "$PERL_CPANM_OPT" | grep -oP -- '--mirror\s+\S+' | head -n 1 | cut -d ' ' -f 2)
7if ! [[ "$CPAN_MIRROR" =~ "http://" ]] ; then
b58ecb01 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"
b2435630 10 CPAN_MIRROR="http://cpan.develooper.com/"
d71417ff 11 PERL_CPANM_OPT="$PERL_CPANM_OPT --mirror $CPAN_MIRROR"
b2435630 12 echo_err "Using $CPAN_MIRROR for the time being"
b58ecb01 13fi
14
b2435630 15export PERL_MM_USE_DEFAULT=1 PERL_MM_NONINTERACTIVE=1 PERL_AUTOINSTALL_PREFER_CPAN=1 PERLBREW_CPAN_MIRROR="$CPAN_MIRROR"
b58ecb01 16
17# Fixup CPANM_OPT to behave more like a traditional cpan client
b2435630 18export PERL_CPANM_OPT="--verbose --no-interactive $( echo $PERL_CPANM_OPT | sed 's/--skip-satisfied//' )"
b58ecb01 19
20if [[ -n "$BREWVER" ]] ; then
21 run_or_err "Compiling/installing Perl $BREWVER (without testing, may take up to 5 minutes)" \
03d379e5 22 "perlbrew install --as $BREWVER --notest --verbose $BREWOPTS -j 2 $BREWVER"
b58ecb01 23
d2b1fee9 24 # can not do 'perlbrew uss' in the run_or_err subshell above, or a $()
25 # furthermore `perlbrew use` returns 0 regardless of whether the perl is
26 # found (won't be there unless compilation suceeded, wich *ALSO* returns 0)
27 perlbrew use $BREWVER
28
29 if [[ "$( perlbrew use | grep -oP '(?<=Currently using ).+' )" != "$BREWVER" ]] ; then
30 echo_err "Unable to switch to $BREWVER - compilation failed...?"
31 echo_err "$LASTOUT"
32 exit 1
33 fi
34
b58ecb01 35fi
36
37# configure CPAN.pm - older versions go into an endless loop
38# when trying to autoconf themselves
39CPAN_CFG_SCRIPT="
40 require CPAN;
41 require CPAN::FirstTime;
42 *CPAN::FirstTime::conf_sites = sub {};
43 CPAN::Config->load;
b2435630 44 \$CPAN::Config->{urllist} = [qw{ $CPAN_MIRROR }];
b58ecb01 45 \$CPAN::Config->{halt_on_failure} = 1;
46 CPAN::Config->commit;
47"
48run_or_err "Configuring CPAN.pm" "perl -e '$CPAN_CFG_SCRIPT'"