Commit | Line | Data |
b58ecb01 |
1 | #!/bin/bash |
2 | |
9040c43a |
3 | if [[ "${BASH_SOURCE[0]}" == "${0}" ]] ; then |
4 | echo "This script can not be executed standalone - it can only be source()d" 1>&2 |
5 | exit 1 |
6 | fi |
7 | |
b58ecb01 |
8 | if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then return ; fi |
9 | |
61fbcea7 |
10 | # we need a mirror that both has the standard index and a backpan version rolled |
11 | # into one, due to MDV testing |
d699fb20 |
12 | export CPAN_MIRROR="http://cpan.metacpan.org/" |
61fbcea7 |
13 | |
14 | PERL_CPANM_OPT="$PERL_CPANM_OPT --mirror $CPAN_MIRROR" |
b58ecb01 |
15 | |
07292953 |
16 | # do not set PERLBREW_CPAN_MIRROR - not all backpan-like mirrors have the perl tarballs |
5ac4a96d |
17 | export PERL_MM_USE_DEFAULT=1 PERL_MM_NONINTERACTIVE=1 PERL_AUTOINSTALL_PREFER_CPAN=1 HARNESS_TIMER=1 MAKEFLAGS="-j$VCPU_USE" |
b58ecb01 |
18 | |
2f51deb1 |
19 | # try CPAN's latest offering if requested |
20 | if [[ "$DEVREL_DEPS" == "true" ]] ; then |
21 | |
2f51deb1 |
22 | PERL_CPANM_OPT="$PERL_CPANM_OPT --dev" |
23 | |
2f51deb1 |
24 | fi |
25 | |
b58ecb01 |
26 | # Fixup CPANM_OPT to behave more like a traditional cpan client |
a1f6d93c |
27 | export PERL_CPANM_OPT="--verbose --no-interactive --no-man-pages $( echo $PERL_CPANM_OPT | sed 's/--skip-satisfied//' )" |
b58ecb01 |
28 | |
29 | if [[ -n "$BREWVER" ]] ; then |
62f2092b |
30 | |
4bbabf15 |
31 | # since perl 5.14 a perl can safely be built concurrently with -j$large |
32 | # (according to brute force testing and my power bill) |
62f2092b |
33 | if [[ "$BREWVER" =~ [A-Za-z] ]] || perl -Mversion -e "exit !!(version->new(q($BREWVER)) < 5.014)" ; then |
5ac4a96d |
34 | perlbrew_jopt="$VCPU_USE" |
4bbabf15 |
35 | fi |
36 | |
62f2092b |
37 | BREWSRC="$BREWVER" |
38 | |
64d48e19 |
39 | if is_cperl; then |
e66f0ee0 |
40 | if [[ "$BREWVER" == "cperl-master" ]] ; then |
41 | git clone --single-branch --depth=1 --branch=master https://github.com/perl11/cperl /tmp/cperl-master |
42 | BREWSRC="/tmp/cperl-master" |
43 | else |
44 | # FFS perlbrew ( see http://wollmers-perl.blogspot.de/2015/10/install-cperl-with-perlbrew.html ) |
45 | wget -qO- https://github.com/perl11/cperl/archive/$BREWVER.tar.gz > /tmp/cperl-$BREWVER.tar.gz |
46 | BREWSRC="/tmp/cperl-$BREWVER.tar.gz" |
47 | fi |
64d48e19 |
48 | elif [[ "$BREWVER" == "schmorp_stableperl" ]] ; then |
62f2092b |
49 | BREWSRC="http://stableperl.schmorp.de/dist/stableperl-5.22.0-1.001.tar.gz" |
50 | fi |
51 | |
4bbabf15 |
52 | run_or_err "Compiling/installing Perl $BREWVER (without testing, using ${perlbrew_jopt:-1} threads, may take up to 5 minutes)" \ |
62f2092b |
53 | "perlbrew install --as $BREWVER --notest --noman --verbose $BREWOPTS -j${perlbrew_jopt:-1} $BREWSRC" |
b58ecb01 |
54 | |
d699fb20 |
55 | # FIXME work around https://github.com/perl11/cperl/issues/144 |
e66f0ee0 |
56 | # (still affecting 5.22.3) |
d699fb20 |
57 | if is_cperl && ! [[ -f ~/perl5/perlbrew/perls/$BREWVER/bin/perl ]] ; then |
65f6f753 |
58 | ln -s ~/perl5/perlbrew/perls/$BREWVER/bin/cperl ~/perl5/perlbrew/perls/$BREWVER/bin/perl || /bin/true |
d699fb20 |
59 | fi |
60 | |
3071c14a |
61 | # can not do 'perlbrew use' in the run_or_err subshell above, or a $() |
62 | # furthermore some versions of `perlbrew use` return 0 regardless of whether |
63 | # the perl is found (won't be there unless compilation suceeded, wich *ALSO* returns 0) |
64 | perlbrew use $BREWVER || /bin/true |
d2b1fee9 |
65 | |
65f6f753 |
66 | if \ |
67 | ! [[ -x ~/perl5/perlbrew/perls/$BREWVER/bin/perl ]] \ |
68 | || [[ "$( perlbrew use | grep -oP '(?<=Currently using ).+' )" != "$BREWVER" ]] |
69 | then |
d2b1fee9 |
70 | echo_err "Unable to switch to $BREWVER - compilation failed...?" |
71 | echo_err "$LASTOUT" |
72 | exit 1 |
73 | fi |
74 | |
2c754d14 |
75 | # no brewver - this means a travis perl, which means we want to clean up |
76 | # the presently installed libs |
fb954d9d |
77 | elif [[ "$CLEANTEST" == "true" ]] && [[ "$POISON_ENV" != "true" ]] ; then |
78 | purge_sitelib |
b58ecb01 |
79 | fi |
80 | |
2ff02982 |
81 | if [[ "$POISON_ENV" = "true" ]] ; then |
82 | # create a perlbrew-specific local lib |
83 | perlbrew lib create travis-local |
84 | perlbrew use "$( perlbrew use | grep -oP '(?<=Currently using ).+' )@travis-local" |
85 | echo_err "POISON_ENV active - adding a local lib: $(perlbrew use)" |
86 | fi |
87 | |
b58ecb01 |
88 | # configure CPAN.pm - older versions go into an endless loop |
89 | # when trying to autoconf themselves |
90 | CPAN_CFG_SCRIPT=" |
91 | require CPAN; |
92 | require CPAN::FirstTime; |
93 | *CPAN::FirstTime::conf_sites = sub {}; |
94 | CPAN::Config->load; |
b2435630 |
95 | \$CPAN::Config->{urllist} = [qw{ $CPAN_MIRROR }]; |
cc7e6017 |
96 | \$CPAN::Config->{halt_on_failure} = $( is_cperl && echo -n 0 || echo -n 1 ); |
b58ecb01 |
97 | CPAN::Config->commit; |
98 | " |
99 | run_or_err "Configuring CPAN.pm" "perl -e '$CPAN_CFG_SCRIPT'" |
afeb40d2 |
100 | |
db83437e |
101 | |
102 | # These envvars are always set, more *maybe* below |
103 | export DBIC_SHUFFLE_UNORDERED_RESULTSETS=1 |
104 | |
105 | # bogus nonexisting DBI_* |
106 | export DBI_DSN="dbi:ODBC:server=NonexistentServerAddress" |
107 | export DBI_DRIVER="ADO" |
108 | |
109 | # some people do in fact set this - boggle!!! |
110 | # it of course won't work before 5.8.4 |
111 | if perl -M5.008004 -e 1 &>/dev/null ; then |
112 | export PERL_STRICTURES_EXTRA=1 |
113 | fi |
114 | |
115 | |
afeb40d2 |
116 | # poison the environment |
117 | if [[ "$POISON_ENV" = "true" ]] ; then |
118 | |
179566f3 |
119 | toggle_vars=( MVDT ) |
120 | |
121 | [[ "$CLEANTEST" == "true" ]] && toggle_vars+=( BREAK_CC ) |
122 | |
123 | for var in "${toggle_vars[@]}" ; do |
124 | if [[ -z "${!var}" ]] ; then |
125 | export $var=true |
126 | echo "POISON_ENV: setting $var to 'true'" |
127 | fi |
128 | done |
129 | |
0ba0c34f |
130 | # look through lib, find all mentioned DBIC* ENVvars and set them to true and see if anything explodes |
db83437e |
131 | toggle_booleans=( $( grep -ohP '\bDBIC_[0-9_A-Z]+' -r lib/ --exclude-dir Optional | sort -u | grep -vP '^(DBIC_TRACE(_PROFILE)?|DBIC_.+_DEBUG)$' ) ) |
0ba0c34f |
132 | |
133 | # some extra pollutants |
134 | toggle_booleans+=( \ |
ddcc02d1 |
135 | DBICTEST_ASSERT_NO_SPURIOUS_EXCEPTION_ACTION \ |
ee573365 |
136 | DBICTEST_SQLITE_USE_FILE \ |
c26b30de |
137 | DBICTEST_RUN_ALL_TESTS \ |
afeb40d2 |
138 | DBICTEST_SQLITE_REVERSE_DEFAULT_ORDER \ |
0ba0c34f |
139 | ) |
afeb40d2 |
140 | |
8b60b921 |
141 | # if we have Moose - try to run everything under replicated |
142 | # FIXME - when switching to Moo kill this |
143 | if [[ "$CLEANTEST" != "true" ]] && perl -M5.008003 -e 1 &>/dev/null ; then |
0ba0c34f |
144 | toggle_booleans+=( DBICTEST_VIA_REPLICATED ) |
8b60b921 |
145 | fi |
146 | |
0ba0c34f |
147 | for var in "${toggle_booleans[@]}" |
148 | do |
149 | if [[ -z "${!var}" ]] ; then |
150 | export $var=1 |
151 | echo "POISON_ENV: setting $var to 1" |
152 | fi |
153 | done |
154 | |
32871272 |
155 | echo "POISON_ENV: setting PERL_UNICODE=SAD" |
156 | export PERL_UNICODE=SAD |
157 | |
23f25dde |
158 | |
159 | ### emulate a local::lib-like env |
afeb40d2 |
160 | |
e66f0ee0 |
161 | # trick cpanm into executing true as shell - we just need the find+unpack |
162 | run_or_err "Downloading latest stable DBIC from CPAN" \ |
163 | "SHELL=/bin/true cpanm --look DBIx::Class" |
afeb40d2 |
164 | |
e66f0ee0 |
165 | # move it somewhere as following cpanm will clobber it |
166 | run_or_err "Moving latest stable DBIC from CPAN to /tmp" "mv ~/.cpanm/latest-build/DBIx-Class-*/lib /tmp/stable_dbic_lib" |
d699fb20 |
167 | |
e66f0ee0 |
168 | export PERL5LIB="/tmp/stable_dbic_lib:$PERL5LIB" |
afeb40d2 |
169 | |
e66f0ee0 |
170 | # perldoc -l <mod> searches $(pwd)/lib in addition to PERL5LIB etc, hence the cd / |
171 | echo_err "Latest stable DBIC (without deps) locatable via \$PERL5LIB at $(cd / && perldoc -l DBIx::Class)" |
afeb40d2 |
172 | fi |
173 | |
174 | if [[ "$CLEANTEST" != "true" ]] ; then |
175 | # using SQLT if will be available |
176 | # not doing later because we will be running in a subshell |
177 | export DBICTEST_SQLT_DEPLOY=1 |
178 | |
179 | fi |
ab314234 |
180 | |
181 | # FIXME - work around https://github.com/miyagawa/cpanminus/issues/462 |
182 | # seriously... |
183 | perl -p -i -e 's/\blocal\$self->\{notest\}=1;//' $(which cpanm) |