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 ... "
23 PRMETER_PIDFILE="$(tempfile)_$SECONDS"
24 # the double bash is to hide the job control messages
25 bash -c "bash -c 'echo \$\$ >> $PRMETER_PIDFILE; while true; do sleep 10; echo -n \"\${SECONDS}s ... \"; done' &"
27 # the tee is a handy debugging tool when stumpage is exceedingly strong
28 #LASTOUT=$( bash -c "$2" 2>&1 | tee /dev/stderr) || LASTEXIT=$?
29 LASTOUT=$( bash -c "$2" 2>&1 ) || LASTEXIT=$?
32 for p in $(cat "$PRMETER_PIDFILE"); do kill $p ; done
34 DELTA_TIME=$(( $SECONDS - $START_TIME ))
36 if [[ "$LASTEXIT" != "0" ]] ; then
37 echo_err "FAILED !!! (after ${DELTA_TIME}s)"
38 echo_err "Command executed:"
40 echo_err "STDOUT+STDERR:"
45 echo_err "done (took ${DELTA_TIME}s)"
53 # Need to do this at every step, the sources list may very well have changed
54 run_or_err "Updating APT available package list" "sudo apt-get update"
56 run_or_err "Installing Debian APT packages: $pkgs" "sudo apt-get install --allow-unauthenticated --no-install-recommends -y $pkgs"
60 # once --verbose is set, --no-verbose can't disable it
62 local PERL_CPANM_OPT="$( echo $PERL_CPANM_OPT | sed 's/--verbose\s*//' )"
66 COMBINED_OUT="$( { stdout="$(cpanm --quiet --scandeps --format tree "$@")" ; } 2>&1; echo "!!!STDERRSTDOUTSEPARATOR!!!$stdout")" \
69 OUT=${COMBINED_OUT#*!!!STDERRSTDOUTSEPARATOR!!!}
70 ERR=${COMBINED_OUT%!!!STDERRSTDOUTSEPARATOR!!!*}
72 if [[ "$LASTEXIT" != "0" ]] ; then
73 echo_err "Error occured (exit code $LASTEXIT) retrieving dependencies of $@:"
79 # throw away warnings, up-to-date diag, ascii art, convert to modnames
81 s/^.*?is up to date.*$//;
84 s/\-[^\-]+$/ /; # strip version part
88 # throw away what was in $@
90 PQ=$( perl -p -e 's/(?:\s|^)\Q'"$m"'\E(?:\s|$)/ /mg' <<< "$PQ")
97 parallel_installdeps_notest() {
98 if [[ -z "$@" ]] ; then return; fi
100 # one module spec per line
101 MODLIST="$(printf '%s\n' "$@")"
103 # We want to trap the output of each process and serially append them to
104 # each other as opposed to just dumping a jumbled up mass-log that would
105 # need careful unpicking by a human
107 # While cpanm does maintain individual buildlogs in more recent versions,
108 # we are not terribly interested in trying to figure out which log is which
109 # dist. The verbose-output + trap STDIO technique is vastly superior in this
112 # Explanation of inline args:
114 # [09:38] <T> you need a $0
115 # [09:38] <G> hence the _
116 # [09:38] <G> bash -c '...' _
117 # [09:39] <T> I like -- because it's the magic that gnu getopts uses for somethign else
118 # [09:39] <G> or --, yes
119 # [09:39] <T> ribasushi: you could put "giant space monkey penises" instead of "--" and it would work just as well
121 run_or_err "Installing (without testing) $(echo $MODLIST)" \
124 | xargs -d '\\n' -n 1 -P $NUMTHREADS bash -c \\
125 'OUT=\$($TIMEOUT_CMD cpanm --notest \"\$@\" 2>&1 ) || (LASTEXIT=\$?; echo \"\$OUT\"; exit \$LASTEXIT)' \\
126 'giant space monkey penises'
131 if [[ -z "$@" ]] ; then return; fi
133 echo_err "$(tstamp) Processing dependencies: $@"
135 local -x HARNESS_OPTIONS
137 HARNESS_OPTIONS="j$NUMTHREADS"
139 echo_err -n "Attempting install of $# modules under parallel ($HARNESS_OPTIONS) testing ... "
143 LASTOUT=$( _dep_inst_with_test "$@" ) || LASTEXIT=$?
144 DELTA_TIME=$(( $SECONDS - $START_TIME ))
146 if [[ "$LASTEXIT" = "0" ]] ; then
147 echo_err "done (took ${DELTA_TIME}s)"
149 local errlog="after ${DELTA_TIME}s Exit:$LASTEXIT Log:$(/usr/bin/nopaste -q -s Shadowcat -d "Parallel testfail" <<< "$LASTOUT")"
150 echo_err -n "failed ($errlog) retrying with sequential testing ... "
151 POSTMORTEM="$POSTMORTEM$(
153 echo "Depinstall under $HARNESS_OPTIONS parallel testing failed $errlog"
154 echo "============================================================="
155 echo "Attempted installation of: $@"
156 echo "============================================================="
162 LASTOUT=$( _dep_inst_with_test "$@" ) || LASTEXIT=$?
163 DELTA_TIME=$(( $SECONDS - $START_TIME ))
165 if [[ "$LASTEXIT" = "0" ]] ; then
166 echo_err "done (took ${DELTA_TIME}s)"
168 echo_err "FAILED !!! (after ${DELTA_TIME}s)"
169 echo_err "STDOUT+STDERR:"
175 INSTALLDEPS_OUT="${INSTALLDEPS_OUT}${LASTOUT}"
178 _dep_inst_with_test() {
179 if [[ "$DEVREL_DEPS" == "true" ]] ; then
180 # --dev is already part of CPANM_OPT
181 $TIMEOUT_CMD cpanm "$@" 2>&1
183 $TIMEOUT_CMD cpan "$@" 2>&1
185 # older perls do not have a CPAN which can exit with error on failed install
190 $ARGV[0] =~ m{ \/ .*? ([^\/]+) $ }x
191 ? do { my @p = split (/\-/, $1); pop @p; join "::", @p }
195 $mod = q{List::Util} if $mod eq q{Scalar::List::Utils};
197 eval qq{require($mod)} or ( print $@ and exit 1)
199 ' "$m" 2> /dev/null ; then
200 echo -e "$m installation seems to have failed"
207 CPAN_is_sane() { perl -MCPAN\ 1.94_56 -e 1 &>/dev/null ; }
209 CPAN_supports_BUILDPL() { perl -MCPAN\ 1.9205 -e1 &>/dev/null; }