(travis) Sorry metacpan, your mirror is simply shit >:(
[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"
86370cc7 10 CPAN_MIRROR="http://cpan.shadowcatprojects.net/"
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
86370cc7 15# do not set PERLBREW_CPAN_MIRROR - the canonical backpan.perl.org does not have the perl tarballs
16export PERL_MM_USE_DEFAULT=1 PERL_MM_NONINTERACTIVE=1 PERL_AUTOINSTALL_PREFER_CPAN=1 HARNESS_TIMER=1 MAKEFLAGS="-j$NUMTHREADS"
b58ecb01 17
2f51deb1 18# try CPAN's latest offering if requested
19if [[ "$DEVREL_DEPS" == "true" ]] ; then
20
2f51deb1 21 PERL_CPANM_OPT="$PERL_CPANM_OPT --dev"
22
8cddfc1b 23 # FIXME inline-upgrade cpanm, work around https://github.com/travis-ci/travis-ci/issues/1477
24 cpanm_loc="$(which cpanm)"
25 run_or_err "Upgrading cpanm ($cpanm_loc) to latest stable" \
26 "wget -q -O $cpanm_loc cpanmin.us && chmod a+x $cpanm_loc"
2f51deb1 27fi
28
b58ecb01 29# Fixup CPANM_OPT to behave more like a traditional cpan client
a1f6d93c 30export PERL_CPANM_OPT="--verbose --no-interactive --no-man-pages $( echo $PERL_CPANM_OPT | sed 's/--skip-satisfied//' )"
b58ecb01 31
32if [[ -n "$BREWVER" ]] ; then
4bbabf15 33 # since perl 5.14 a perl can safely be built concurrently with -j$large
34 # (according to brute force testing and my power bill)
35 if [[ "$BREWVER" == "blead" ]] || perl -Mversion -e "exit !!(version->new(q($BREWVER)) < 5.014)" ; then
36 perlbrew_jopt="$NUMTHREADS"
37 fi
38
39 run_or_err "Compiling/installing Perl $BREWVER (without testing, using ${perlbrew_jopt:-1} threads, may take up to 5 minutes)" \
40 "perlbrew install --as $BREWVER --notest --noman --verbose $BREWOPTS -j${perlbrew_jopt:-1} $BREWVER"
b58ecb01 41
d2b1fee9 42 # can not do 'perlbrew uss' in the run_or_err subshell above, or a $()
43 # furthermore `perlbrew use` returns 0 regardless of whether the perl is
44 # found (won't be there unless compilation suceeded, wich *ALSO* returns 0)
45 perlbrew use $BREWVER
46
47 if [[ "$( perlbrew use | grep -oP '(?<=Currently using ).+' )" != "$BREWVER" ]] ; then
48 echo_err "Unable to switch to $BREWVER - compilation failed...?"
49 echo_err "$LASTOUT"
50 exit 1
51 fi
52
2c754d14 53# no brewver - this means a travis perl, which means we want to clean up
54# the presently installed libs
55# Idea stolen from
56# https://github.com/kentfredric/Dist-Zilla-Plugin-Prereqs-MatchInstalled-All/blob/master/maint-travis-ci/sterilize_env.pl
57elif [[ "$CLEANTEST" == "true" ]] && [[ "$POISON_ENV" != "true" ]] ; then
58
59 echo_err "$(tstamp) Cleaning precompiled Travis-Perl"
60 perl -MConfig -MFile::Find -e '
61 my $sitedirs = {
62 map { $Config{$_} => 1 }
63 grep { $_ =~ /site(lib|arch)exp$/ }
64 keys %Config
65 };
66 find({ bydepth => 1, no_chdir => 1, follow_fast => 1, wanted => sub {
67 ! $sitedirs->{$_} and ( -d _ ? rmdir : unlink )
68 } }, keys %$sitedirs )
69 '
70
71 echo_err "Post-cleanup contents of sitelib of the pre-compiled Travis-Perl $TRAVIS_PERL_VERSION:"
72 echo_err "$(tree $(perl -MConfig -e 'print $Config{sitelib_stem}'))"
73 echo_err
b58ecb01 74fi
75
76# configure CPAN.pm - older versions go into an endless loop
77# when trying to autoconf themselves
78CPAN_CFG_SCRIPT="
79 require CPAN;
80 require CPAN::FirstTime;
81 *CPAN::FirstTime::conf_sites = sub {};
82 CPAN::Config->load;
b2435630 83 \$CPAN::Config->{urllist} = [qw{ $CPAN_MIRROR }];
b58ecb01 84 \$CPAN::Config->{halt_on_failure} = 1;
85 CPAN::Config->commit;
86"
87run_or_err "Configuring CPAN.pm" "perl -e '$CPAN_CFG_SCRIPT'"