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 |
25 | echo_err -e "FAILED !!! (after ${DELTA_TIME}s)\nCommand executed:\n$2\nSTDOUT+STDERR:\n$LASTOUT" |
26 | return $LASTEXIT |
27 | else |
28 | echo_err "done (took ${DELTA_TIME}s)" |
29 | fi |
30 | } |
31 | |
32 | extract_prereqs() { |
71dd2ecc |
33 | # once --verbose is set, --no-verbose can't disable it |
34 | # do this by hand |
35 | ORIG_CPANM_OPT="$PERL_CPANM_OPT" |
36 | PERL_CPANM_OPT="$( echo $PERL_CPANM_OPT | sed 's/--verbose//' )" |
37 | |
b58ecb01 |
38 | # hack-hack-hack |
39 | LASTEXIT=0 |
40 | COMBINED_OUT="$( { stdout="$(cpanm --quiet --scandeps --format tree "$@")" ; } 2>&1; echo "!!!STDERRSTDOUTSEPARATOR!!!$stdout")" \ |
41 | || LASTEXIT=$? |
42 | |
71dd2ecc |
43 | PERL_CPANM_OPT="$ORIG_CPANM_OPT" |
44 | |
b58ecb01 |
45 | OUT=${COMBINED_OUT#*!!!STDERRSTDOUTSEPARATOR!!!} |
46 | ERR=$(grep -v " is up to date." <<< "${COMBINED_OUT%!!!STDERRSTDOUTSEPARATOR!!!*}") |
47 | |
48 | if [[ "$LASTEXIT" != "0" ]] || [[ -n "$ERR" ]] ; then |
49 | echo_err "$(echo -e "Error occured (exit code $LASTEXIT) retrieving dependencies of $@:\n$ERR\n$OUT")" |
50 | exit 1 |
51 | fi |
52 | |
53 | # throw away non-children (what was in $@), throw away ascii art, convert to modnames |
54 | perl -p -e 's/^[a-z].+//i; s/^[^a-z]+//i; s/\-[^\-]+$/ /; s/\-/::/g' <<< "$OUT" |
55 | } |
56 | |
57 | parallel_installdeps_notest() { |
58 | if [[ -z "$@" ]] ; then return; fi |
59 | |
60 | # flatten list into one string |
61 | MODLIST=$(echo "$@") |
62 | |
63 | # The reason we do things so "non-interactively" is that xargs -P will have the |
64 | # latest cpanm instance overwrite the buildlog. There seems to be no way to |
65 | # specify a custom buildlog, hence we just collect the verbose output |
10e248bf |
66 | # and display it in case of "worker" failure |
67 | # |
68 | # Explanation of inline args: |
69 | # |
70 | # [09:38] <T> you need a $0 |
71 | # [09:38] <G> hence the _ |
72 | # [09:38] <G> bash -c '...' _ |
73 | # [09:39] <T> I like -- because it's the magic that gnu getopts uses for somethign else |
74 | # [09:39] <G> or --, yes |
75 | # [09:39] <T> ribasushi: you could put "giant space monkey penises" instead of "--" and it would work just as well |
76 | # |
b58ecb01 |
77 | run_or_err "Installing (without testing) $MODLIST" \ |
10e248bf |
78 | "echo $MODLIST | xargs -n 1 -P $NUMTHREADS bash -c \\ |
79 | 'OUT=\$(cpanm --notest --no-man-pages \"\$@\" 2>&1 ) || (LASTEXIT=\$?; echo \"\$OUT\"; exit \$LASTEXIT)' \\ |
80 | 'giant space monkey penises' |
81 | " |
b58ecb01 |
82 | } |
83 | |
84 | |
85 | CPAN_is_sane() { perl -MCPAN\ 1.94_56 -e 1 &>/dev/null ; } |