5 TEST_STDERR_LOG=/tmp/dbictest.stderr
6 TIMEOUT_CMD="/usr/bin/timeout --kill-after=9.5m --signal=TERM 9m"
8 echo_err() { echo "$@" 1>&2 ; }
10 if [[ "$TRAVIS" != "true" ]] ; then
11 echo_err "Running this script makes no sense outside of travis-ci"
15 tstamp() { echo -n "[$(date '+%H:%M:%S')]" ; }
18 echo_err -n "$(tstamp) $1 ... "
24 PRMETER_PIDFILE="$(tempfile)_$SECONDS"
25 # the double bash is to hide the job control messages
26 bash -c "bash -c 'echo \$\$ >> $PRMETER_PIDFILE; while true; do sleep 10; echo -n \"\${SECONDS}s ... \"; done' &"
28 LASTOUT=$( eval "$2" 2>&1 ) || LASTEXIT=$?
31 for p in $(cat "$PRMETER_PIDFILE"); do kill $p ; done
33 DELTA_TIME=$(( $SECONDS - $START_TIME ))
35 if [[ "$LASTEXIT" != "0" ]] ; then
36 if [[ -z "$3" ]] ; then
37 echo_err "FAILED !!! (after ${DELTA_TIME}s)"
38 echo_err "Command executed:"
40 echo_err "STDOUT+STDERR:"
46 echo_err "done (took ${DELTA_TIME}s)"
54 # Need to do this at every step, the sources list may very well have changed
55 run_or_err "Updating APT available package list" "sudo apt-get update"
57 run_or_err "Installing Debian APT packages: $pkgs" "sudo apt-get install --allow-unauthenticated --no-install-recommends -y $pkgs"
61 # once --verbose is set, --no-verbose can't disable it
63 local PERL_CPANM_OPT="$( echo $PERL_CPANM_OPT | sed 's/--verbose\s*//' )"
67 COMBINED_OUT="$( { stdout="$(cpanm --quiet --scandeps --format tree "$@")" ; } 2>&1; echo "!!!STDERRSTDOUTSEPARATOR!!!$stdout")" \
70 OUT=${COMBINED_OUT#*!!!STDERRSTDOUTSEPARATOR!!!}
71 ERR=${COMBINED_OUT%!!!STDERRSTDOUTSEPARATOR!!!*}
73 if [[ "$LASTEXIT" != "0" ]] ; then
74 echo_err "Error occured (exit code $LASTEXIT) retrieving dependencies of $@:"
80 # throw away warnings, up-to-date diag, ascii art, convert to modnames
82 s/^.*?is up to date.*$//;
85 s/\-[^\-]+$/ /; # strip version part
89 # throw away what was in $@
91 PQ=$( perl -p -e 's/(?:\s|^)\Q'"$m"'\E(?:\s|$)/ /mg' <<< "$PQ")
98 parallel_installdeps_notest() {
99 if [[ -z "$@" ]] ; then return; fi
101 # one module spec per line
102 MODLIST="$(printf '%s\n' "$@")"
104 # We want to trap the output of each process and serially append them to
105 # each other as opposed to just dumping a jumbled up mass-log that would
106 # need careful unpicking by a human
108 # While cpanm does maintain individual buildlogs in more recent versions,
109 # we are not terribly interested in trying to figure out which log is which
110 # dist. The verbose-output + trap STDIO technique is vastly superior in this
113 # Explanation of inline args:
115 # [09:38] <T> you need a $0
116 # [09:38] <G> hence the _
117 # [09:38] <G> bash -c '...' _
118 # [09:39] <T> I like -- because it's the magic that gnu getopts uses for somethign else
119 # [09:39] <G> or --, yes
120 # [09:39] <T> ribasushi: you could put "giant space monkey penises" instead of "--" and it would work just as well
122 run_or_err "Installing (without testing) $(echo $MODLIST)" \
125 | xargs -d '\\n' -n 1 -P $NUMTHREADS bash -c \\
126 'OUT=\$($TIMEOUT_CMD cpanm --notest \"\$@\" 2>&1 ) || (LASTEXIT=\$?; echo \"\$OUT\"; exit \$LASTEXIT)' \\
127 'giant space monkey penises'
132 if [[ -z "$@" ]] ; then return; fi
134 MODLIST=$(printf "%q " "$@" | perl -pe 's/^\s+|\s+$//g')
136 local -x HARNESS_OPTIONS
138 HARNESS_OPTIONS="j$NUMTHREADS"
140 if ! run_or_err "Attempting install of $# modules under parallel ($HARNESS_OPTIONS) testing ($MODLIST)" "_dep_inst_with_test $MODLIST" quiet_fail ; then
141 local errlog="failed after ${DELTA_TIME}s Exit:$LASTEXIT Log:$(/usr/bin/nopaste -q -s Shadowcat -d "Parallel testfail" <<< "$LASTOUT")"
144 POSTMORTEM="$POSTMORTEM$(
146 echo "Depinstall of $MODLIST under $HARNESS_OPTIONS parallel testing $errlog"
150 run_or_err "Retrying same $# modules without parallel testing" "_dep_inst_with_test $MODLIST"
153 INSTALLDEPS_OUT="${INSTALLDEPS_OUT}${LASTOUT}"
156 _dep_inst_with_test() {
157 if [[ "$DEVREL_DEPS" == "true" ]] ; then
158 # --dev is already part of CPANM_OPT
159 LASTCMD="$TIMEOUT_CMD cpanm $@"
162 LASTCMD="$TIMEOUT_CMD cpan $@"
165 # older perls do not have a CPAN which can exit with error on failed install
170 $ARGV[0] =~ m{ \/ .*? ([^\/]+) $ }x
171 ? do { my @p = split (/\-/, $1); pop @p; join "::", @p }
175 $mod = q{List::Util} if $mod eq q{Scalar::List::Utils};
177 eval qq{require($mod)} or ( print $@ and exit 1)
179 ' "$m" 2> /dev/null ; then
180 echo -e "$m installation seems to have failed"
187 CPAN_is_sane() { perl -MCPAN\ 1.94_56 -e 1 &>/dev/null ; }
189 CPAN_supports_BUILDPL() { perl -MCPAN\ 1.9205 -e1 &>/dev/null; }