From: Peter Rabbitson Date: Sat, 13 Jul 2013 02:25:29 +0000 (+0200) Subject: Turns out Travis CPAN mirror is not local, add a fallback X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b24356300accc7c0f1236ad78ad5bb68a681a856;p=dbsrgits%2FDBIx-Class-Historic.git Turns out Travis CPAN mirror is not local, add a fallback See https://github.com/travis-ci/travis-cookbooks/commit/143a57d2ecee#diff-1 Sideffect of an empty PERL_CPANM_OPT was tickling this bug: https://github.com/miyagawa/cpanminus/issues/288 --- diff --git a/maint/travis-ci_scripts/20_install.bash b/maint/travis-ci_scripts/20_install.bash index 5a0ffdf..6cc1a49 100755 --- a/maint/travis-ci_scripts/20_install.bash +++ b/maint/travis-ci_scripts/20_install.bash @@ -3,17 +3,18 @@ source maint/travis-ci_scripts/common.bash if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then return ; fi -TRAVIS_CPAN_MIRROR=$(echo "$PERL_CPANM_OPT" | grep -oP -- '--mirror\s+\S+' | head -n 1 | cut -d ' ' -f 2) -if ! [[ "$TRAVIS_CPAN_MIRROR" =~ "http://" ]] ; then +CPAN_MIRROR=$(echo "$PERL_CPANM_OPT" | grep -oP -- '--mirror\s+\S+' | head -n 1 | cut -d ' ' -f 2) +if ! [[ "$CPAN_MIRROR" =~ "http://" ]] ; then echo_err "Unable to extract primary cpan mirror from PERL_CPANM_OPT - something is wrong" echo_err "PERL_CPANM_OPT: $PERL_CPANM_OPT" - exit 1 + CPAN_MIRROR="http://cpan.develooper.com/" + echo_err "Using $CPAN_MIRROR for the time being" fi -export PERL_MM_USE_DEFAULT=1 PERL_MM_NONINTERACTIVE=1 PERL_AUTOINSTALL_PREFER_CPAN=1 PERLBREW_CPAN_MIRROR="$TRAVIS_CPAN_MIRROR" +export PERL_MM_USE_DEFAULT=1 PERL_MM_NONINTERACTIVE=1 PERL_AUTOINSTALL_PREFER_CPAN=1 PERLBREW_CPAN_MIRROR="$CPAN_MIRROR" # Fixup CPANM_OPT to behave more like a traditional cpan client -export PERL_CPANM_OPT="$( echo $PERL_CPANM_OPT | sed 's/--skip-satisfied//' ) --verbose --no-interactive" +export PERL_CPANM_OPT="--verbose --no-interactive $( echo $PERL_CPANM_OPT | sed 's/--skip-satisfied//' )" if [[ -n "$BREWVER" ]] ; then run_or_err "Compiling/installing Perl $BREWVER (without testing, may take up to 5 minutes)" \ @@ -31,7 +32,7 @@ CPAN_CFG_SCRIPT=" require CPAN::FirstTime; *CPAN::FirstTime::conf_sites = sub {}; CPAN::Config->load; - \$CPAN::Config->{urllist} = [qw{ $TRAVIS_CPAN_MIRROR }]; + \$CPAN::Config->{urllist} = [qw{ $CPAN_MIRROR }]; \$CPAN::Config->{halt_on_failure} = 1; CPAN::Config->commit; " diff --git a/maint/travis-ci_scripts/common.bash b/maint/travis-ci_scripts/common.bash index ee8fa00..9ee3e0a 100755 --- a/maint/travis-ci_scripts/common.bash +++ b/maint/travis-ci_scripts/common.bash @@ -32,16 +32,13 @@ run_or_err() { extract_prereqs() { # once --verbose is set, --no-verbose can't disable it # do this by hand - ORIG_CPANM_OPT="$PERL_CPANM_OPT" - PERL_CPANM_OPT="$( echo $PERL_CPANM_OPT | sed 's/--verbose//' )" + local PERL_CPANM_OPT="$( echo $PERL_CPANM_OPT | sed 's/--verbose\s*//' )" # hack-hack-hack LASTEXIT=0 COMBINED_OUT="$( { stdout="$(cpanm --quiet --scandeps --format tree "$@")" ; } 2>&1; echo "!!!STDERRSTDOUTSEPARATOR!!!$stdout")" \ || LASTEXIT=$? - PERL_CPANM_OPT="$ORIG_CPANM_OPT" - OUT=${COMBINED_OUT#*!!!STDERRSTDOUTSEPARATOR!!!} ERR=$(grep -v " is up to date." <<< "${COMBINED_OUT%!!!STDERRSTDOUTSEPARATOR!!!*}")