Commit | Line | Data |
b58ecb01 |
1 | #!/bin/bash |
2 | |
3 | set -e |
4 | |
b9970637 |
5 | TEST_STDERR_LOG=/tmp/dbictest.stderr |
6 | |
b58ecb01 |
7 | echo_err() { echo "$@" 1>&2 ; } |
8 | |
9 | if [[ "$TRAVIS" != "true" ]] ; then |
10 | echo_err "Running this script makes no sense outside of travis-ci" |
11 | exit 1 |
12 | fi |
13 | |
14 | tstamp() { echo -n "[$(date '+%H:%M:%S')]" ; } |
15 | |
16 | run_or_err() { |
17 | echo_err -n "$(tstamp) $1 ... " |
18 | |
19 | LASTEXIT=0 |
20 | START_TIME=$SECONDS |
21 | LASTOUT=$( bash -c "$2" 2>&1 ) || LASTEXIT=$? |
22 | DELTA_TIME=$(( $SECONDS - $START_TIME )) |
23 | |
24 | if [[ "$LASTEXIT" != "0" ]] ; then |
4242985f |
25 | echo_err "FAILED !!! (after ${DELTA_TIME}s)" |
26 | echo_err "Command executed:" |
27 | echo_err "$2" |
28 | echo_err "STDOUT+STDERR:" |
29 | echo_err "$LASTOUT" |
30 | |
b58ecb01 |
31 | return $LASTEXIT |
32 | else |
33 | echo_err "done (took ${DELTA_TIME}s)" |
34 | fi |
35 | } |
36 | |
37 | extract_prereqs() { |
71dd2ecc |
38 | # once --verbose is set, --no-verbose can't disable it |
39 | # do this by hand |
b2435630 |
40 | local PERL_CPANM_OPT="$( echo $PERL_CPANM_OPT | sed 's/--verbose\s*//' )" |
71dd2ecc |
41 | |
b58ecb01 |
42 | # hack-hack-hack |
43 | LASTEXIT=0 |
44 | COMBINED_OUT="$( { stdout="$(cpanm --quiet --scandeps --format tree "$@")" ; } 2>&1; echo "!!!STDERRSTDOUTSEPARATOR!!!$stdout")" \ |
45 | || LASTEXIT=$? |
46 | |
47 | OUT=${COMBINED_OUT#*!!!STDERRSTDOUTSEPARATOR!!!} |
48 | ERR=$(grep -v " is up to date." <<< "${COMBINED_OUT%!!!STDERRSTDOUTSEPARATOR!!!*}") |
49 | |
50 | if [[ "$LASTEXIT" != "0" ]] || [[ -n "$ERR" ]] ; then |
4242985f |
51 | echo_err "Error occured (exit code $LASTEXIT) retrieving dependencies of $@:" |
52 | echo_err "$ERR" |
53 | echo_err "$OUT" |
b58ecb01 |
54 | exit 1 |
55 | fi |
56 | |
57 | # throw away non-children (what was in $@), throw away ascii art, convert to modnames |
58 | perl -p -e 's/^[a-z].+//i; s/^[^a-z]+//i; s/\-[^\-]+$/ /; s/\-/::/g' <<< "$OUT" |
59 | } |
60 | |
61 | parallel_installdeps_notest() { |
62 | if [[ -z "$@" ]] ; then return; fi |
63 | |
4242985f |
64 | # one module spec per line |
65 | MODLIST="$(printf '%s\n' "$@")" |
b58ecb01 |
66 | |
67 | # The reason we do things so "non-interactively" is that xargs -P will have the |
68 | # latest cpanm instance overwrite the buildlog. There seems to be no way to |
69 | # specify a custom buildlog, hence we just collect the verbose output |
10e248bf |
70 | # and display it in case of "worker" failure |
71 | # |
72 | # Explanation of inline args: |
73 | # |
74 | # [09:38] <T> you need a $0 |
75 | # [09:38] <G> hence the _ |
76 | # [09:38] <G> bash -c '...' _ |
77 | # [09:39] <T> I like -- because it's the magic that gnu getopts uses for somethign else |
78 | # [09:39] <G> or --, yes |
79 | # [09:39] <T> ribasushi: you could put "giant space monkey penises" instead of "--" and it would work just as well |
80 | # |
4242985f |
81 | run_or_err "Installing (without testing) $(echo $MODLIST)" \ |
82 | "echo \\ |
83 | \"$MODLIST\" \\ |
84 | | xargs -d '\\n' -n 1 -P $NUMTHREADS bash -c \\ |
85 | 'OUT=\$(cpanm --notest --no-man-pages \"\$@\" 2>&1 ) || (LASTEXIT=\$?; echo \"\$OUT\"; exit \$LASTEXIT)' \\ |
86 | 'giant space monkey penises' |
10e248bf |
87 | " |
b58ecb01 |
88 | } |
89 | |
90 | |
91 | CPAN_is_sane() { perl -MCPAN\ 1.94_56 -e 1 &>/dev/null ; } |