3 source maint/travis-ci_scripts/common.bash
4 if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then return ; fi
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.metacpan.org/"
11 PERL_CPANM_OPT="$PERL_CPANM_OPT --mirror $CPAN_MIRROR"
12 echo_err "Using $CPAN_MIRROR for the time being"
15 # do not set PERLBREW_CPAN_MIRROR - not all backpan-like mirrors have the perl tarballs
16 export PERL_MM_USE_DEFAULT=1 PERL_MM_NONINTERACTIVE=1 PERL_AUTOINSTALL_PREFER_CPAN=1 HARNESS_TIMER=1 MAKEFLAGS="-j$NUMTHREADS"
18 # try CPAN's latest offering if requested
19 if [[ "$DEVREL_DEPS" == "true" ]] ; then
21 PERL_CPANM_OPT="$PERL_CPANM_OPT --dev"
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"
29 # Fixup CPANM_OPT to behave more like a traditional cpan client
30 export PERL_CPANM_OPT="--verbose --no-interactive --no-man-pages $( echo $PERL_CPANM_OPT | sed 's/--skip-satisfied//' )"
32 if [[ -n "$BREWVER" ]] ; then
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"
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"
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)
47 if [[ "$( perlbrew use | grep -oP '(?<=Currently using ).+' )" != "$BREWVER" ]] ; then
48 echo_err "Unable to switch to $BREWVER - compilation failed...?"
53 # no brewver - this means a travis perl, which means we want to clean up
54 # the presently installed libs
56 # https://github.com/kentfredric/Dist-Zilla-Plugin-Prereqs-MatchInstalled-All/blob/master/maint-travis-ci/sterilize_env.pl
57 elif [[ "$CLEANTEST" == "true" ]] && [[ "$POISON_ENV" != "true" ]] ; then
59 echo_err "$(tstamp) Cleaning precompiled Travis-Perl"
60 perl -MConfig -MFile::Find -e '
62 map { $Config{$_} => 1 }
63 grep { $_ =~ /site(lib|arch)exp$/ }
66 find({ bydepth => 1, no_chdir => 1, follow_fast => 1, wanted => sub {
67 ! $sitedirs->{$_} and ( -d _ ? rmdir : unlink )
68 } }, keys %$sitedirs )
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}'))"
76 # configure CPAN.pm - older versions go into an endless loop
77 # when trying to autoconf themselves
80 require CPAN::FirstTime;
81 *CPAN::FirstTime::conf_sites = sub {};
83 \$CPAN::Config->{urllist} = [qw{ $CPAN_MIRROR }];
84 \$CPAN::Config->{halt_on_failure} = 1;
87 run_or_err "Configuring CPAN.pm" "perl -e '$CPAN_CFG_SCRIPT'"