(travis) Make sure everything works even when we are SAD
[dbsrgits/DBIx-Class.git] / maint / travis-ci_scripts / 20_install.bash
old mode 100755 (executable)
new mode 100644 (file)
index 3a4ff7b..1a4968f
@@ -1,5 +1,10 @@
 #!/bin/bash
 
+if [[ "${BASH_SOURCE[0]}" == "${0}" ]] ; then
+  echo "This script can not be executed standalone - it can only be source()d" 1>&2
+  exit 1
+fi
+
 if [[ -n "$SHORT_CIRCUIT_SMOKE" ]] ; then return ; fi
 
 # we need a mirror that both has the standard index and a backpan version rolled
@@ -50,7 +55,7 @@ if [[ -n "$BREWVER" ]] ; then
   # FIXME work around https://github.com/perl11/cperl/issues/144
   # (still affecting 5.22.3)
   if is_cperl && ! [[ -f ~/perl5/perlbrew/perls/$BREWVER/bin/perl ]] ; then
-    ln -s ~/perl5/perlbrew/perls/$BREWVER/bin/cperl ~/perl5/perlbrew/perls/$BREWVER/bin/perl
+    ln -s ~/perl5/perlbrew/perls/$BREWVER/bin/cperl ~/perl5/perlbrew/perls/$BREWVER/bin/perl || /bin/true
   fi
 
   # can not do 'perlbrew use' in the run_or_err subshell above, or a $()
@@ -58,7 +63,10 @@ if [[ -n "$BREWVER" ]] ; then
   # the perl is found (won't be there unless compilation suceeded, wich *ALSO* returns 0)
   perlbrew use $BREWVER || /bin/true
 
-  if [[ "$( perlbrew use | grep -oP '(?<=Currently using ).+' )" != "$BREWVER" ]] ; then
+  if \
+    ! [[ -x ~/perl5/perlbrew/perls/$BREWVER/bin/perl ]] \
+  ||  [[ "$( perlbrew use | grep -oP '(?<=Currently using ).+' )" != "$BREWVER" ]]
+  then
     echo_err "Unable to switch to $BREWVER - compilation failed...?"
     echo_err "$LASTOUT"
     exit 1
@@ -144,6 +152,9 @@ if [[ "$POISON_ENV" = "true" ]] ; then
     fi
   done
 
+  echo "POISON_ENV: setting PERL_UNICODE=SAD"
+  export PERL_UNICODE=SAD
+
 
 ### emulate a local::lib-like env