|
| 1 | +#!/usr/bin/env bash |
| 2 | + |
| 3 | +set -o nounset |
| 4 | +set -o errexit |
| 5 | + |
| 6 | +declare -r build_status="$(mktemp)" |
| 7 | +declare -r otp_name='OTP_R16B02_basho10' |
| 8 | +declare -r otp_build_log_dir="$HOME/.kerl/builds/$otp_name" |
| 9 | +declare -r otp_install_dir="$HOME/otp-basho" |
| 10 | +declare -r kerl_activate="$otp_install_dir/activate" |
| 11 | + |
| 12 | +function onexit |
| 13 | +{ |
| 14 | + rm -f "$build_status" |
| 15 | +} |
| 16 | + |
| 17 | +trap onexit EXIT |
| 18 | + |
| 19 | +function build_ticker |
| 20 | +{ |
| 21 | + local status="$(< $build_status)" |
| 22 | + while [[ $status == 'true' ]] |
| 23 | + do |
| 24 | + echo '------------------------------------------------------------------------------------------------------------------------------------------------' |
| 25 | + echo "$(date) building $otp_name ..." |
| 26 | + if ls $otp_build_log_dir/otp_build*.log > /dev/null |
| 27 | + then |
| 28 | + tail $otp_build_log_dir/otp_build*.log |
| 29 | + fi |
| 30 | + sleep 10 |
| 31 | + status="$(< $build_status)" |
| 32 | + done |
| 33 | + echo '.' |
| 34 | +} |
| 35 | + |
| 36 | + |
| 37 | +function build_otp |
| 38 | +{ |
| 39 | + if [[ -f $otp_install_dir/activate ]] |
| 40 | + then |
| 41 | + echo "Found $otp_name installation at $otp_install_dir" |
| 42 | + else |
| 43 | + export KERL_CONFIGURE_OPTIONS='--enable-hipe --enable-smp-support --enable-threads --enable-kernel-poll --without-odbc' |
| 44 | + rm -rf "$otp_install_dir" |
| 45 | + mkdir -p "$otp_install_dir" |
| 46 | + |
| 47 | + echo -n 'true' > "$build_status" |
| 48 | + build_ticker & |
| 49 | + kerl build git https://github.com/basho/otp.git "$otp_name" "$otp_name" |
| 50 | + echo -n 'false' > "$build_status" |
| 51 | + wait |
| 52 | + |
| 53 | + kerl install "$otp_name" "$otp_install_dir" |
| 54 | + fi |
| 55 | + |
| 56 | + exit 0 |
| 57 | +} |
| 58 | + |
| 59 | +function do_tests |
| 60 | +{ |
| 61 | + if ! hash escript |
| 62 | + then |
| 63 | + if [[ -f $kerl_activate ]] |
| 64 | + then |
| 65 | + set +o nounset |
| 66 | + set +o errexit |
| 67 | + source "$kerl_activate" |
| 68 | + set -o nounset |
| 69 | + set -o errexit |
| 70 | + else |
| 71 | + echo "Did not find $kerl_activate, exiting" 1>&2 |
| 72 | + exit 1 |
| 73 | + fi |
| 74 | + fi |
| 75 | + |
| 76 | + make |
| 77 | + make test |
| 78 | +} |
| 79 | + |
| 80 | +if [[ $1 == 'build' ]] |
| 81 | +then |
| 82 | + build_otp |
| 83 | +elif [[ $1 == 'test' ]] |
| 84 | +then |
| 85 | + do_tests |
| 86 | +else |
| 87 | + echo 'script argument must be "build" or "test"' 1>&2 |
| 88 | + exit 1 |
| 89 | +fi |
0 commit comments