f8beaefd863c888b283ef9013219b9ee926734e0
[dbsrgits/DBIx-Class-Schema-Loader.git] / maint / travis-ci_scripts / 20_install.bash
1 #!/bin/bash
2
3 if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then return ; fi
4
5 # we need a mirror that both has the standard index and a backpan version rolled
6 # into one, due to MDV testing
7 CPAN_MIRROR="http://cpan.metacpan.org/"
8
9 PERL_CPANM_OPT="$PERL_CPANM_OPT --mirror $CPAN_MIRROR"
10
11 export PERL_MM_USE_DEFAULT=1 PERL_MM_NONINTERACTIVE=1 PERL_AUTOINSTALL_PREFER_CPAN=1 PERLBREW_CPAN_MIRROR="$CPAN_MIRROR" HARNESS_TIMER=1 MAKEFLAGS="-j$NUMTHREADS"
12
13 # try CPAN's latest offering if requested
14 if [[ "$DEVREL_DEPS" == "true" ]] ; then
15
16   PERL_CPANM_OPT="$PERL_CPANM_OPT --dev"
17
18 fi
19
20 # Fixup CPANM_OPT to behave more like a traditional cpan client
21 export PERL_CPANM_OPT="--verify --verbose --no-interactive --no-man-pages $( echo $PERL_CPANM_OPT | sed 's/--skip-satisfied//' )"
22
23 if [[ -n "$BREWVER" ]] ; then
24   # since perl 5.14 a perl can safely be built concurrently with -j$large
25   # (according to brute force testing and my power bill)
26   if [[ "$BREWVER" == "blead" ]] || perl -Mversion -e "exit !!(version->new(q($BREWVER)) < 5.014)" ; then
27     perlbrew_jopt="$NUMTHREADS"
28   fi
29
30   run_or_err "Compiling/installing Perl $BREWVER (without testing, using ${perlbrew_jopt:-1} threads, may take up to 5 minutes)" \
31     "perlbrew install --as $BREWVER --notest --noman --verbose $BREWOPTS -j${perlbrew_jopt:-1}  $BREWVER"
32
33   # can not do 'perlbrew uss' in the run_or_err subshell above, or a $()
34   # furthermore `perlbrew use` returns 0 regardless of whether the perl is
35   # found (won't be there unless compilation suceeded, wich *ALSO* returns 0)
36   perlbrew use $BREWVER
37
38   if [[ "$( perlbrew use | grep -oP '(?<=Currently using ).+' )" != "$BREWVER" ]] ; then
39     echo_err "Unable to switch to $BREWVER - compilation failed...?"
40     echo_err "$LASTOUT"
41     exit 1
42   fi
43
44 # no brewver - this means a travis perl, which means we want to clean up
45 # the presently installed libs
46 # Idea stolen from
47 # https://github.com/kentfredric/Dist-Zilla-Plugin-Prereqs-MatchInstalled-All/blob/master/maint-travis-ci/sterilize_env.pl
48 elif [[ "$CLEANTEST" == "true" ]] && [[ "$POISON_ENV" != "true" ]] ; then
49
50   echo_err "$(tstamp) Cleaning precompiled Travis-Perl"
51   perl -MConfig -MFile::Find -e '
52     my $sitedirs = {
53       map { $Config{$_} => 1 }
54         grep { $_ =~ /site(lib|arch)exp$/ }
55           keys %Config
56     };
57     find({ bydepth => 1, no_chdir => 1, follow_fast => 1, wanted => sub {
58       ! $sitedirs->{$_} and ( -d _ ? rmdir : unlink )
59     } }, keys %$sitedirs )
60   '
61
62   echo_err "Post-cleanup contents of sitelib of the pre-compiled Travis-Perl $TRAVIS_PERL_VERSION:"
63   echo_err "$(tree $(perl -MConfig -e 'print $Config{sitelib_stem}'))"
64   echo_err
65 fi
66
67 # configure CPAN.pm - older versions go into an endless loop
68 # when trying to autoconf themselves
69 CPAN_CFG_SCRIPT="
70   require CPAN;
71   require CPAN::FirstTime;
72   *CPAN::FirstTime::conf_sites = sub {};
73   CPAN::Config->load;
74   \$CPAN::Config->{urllist} = [qw{ $CPAN_MIRROR }];
75   \$CPAN::Config->{halt_on_failure} = 1;
76   CPAN::Config->commit;
77 "
78 run_or_err "Configuring CPAN.pm" "perl -e '$CPAN_CFG_SCRIPT'"