[a858a78] | 1 |
|
---|
| 2 | # $Id$
|
---|
| 3 |
|
---|
| 4 | set -e
|
---|
| 5 |
|
---|
[6b26852] | 6 | # Be sure that we know the target name
|
---|
[a36805d] | 7 | [[ -z $1 ]] && exit
|
---|
[843c479] | 8 | TARGET=$1 # Remember the target build we are looking for
|
---|
[d44206f] | 9 | MAKE_PPID=$2
|
---|
[a36805d] | 10 |
|
---|
[843c479] | 11 | declare -r CSI=$'\e[' # DEC terminology, Control Sequence Introducer
|
---|
| 12 | declare -r CURSOR_OFF=${CSI}$'?25l'
|
---|
| 13 | declare -r CURSOR_ON=${CSI}$'?25h'
|
---|
| 14 | declare -r ERASE_LINE=${CSI}$'2K'
|
---|
| 15 | declare -r FRAME_OPEN=${CSI}$'2G['
|
---|
| 16 | declare -r FRAME_CLOSE=${CSI}$'63G]'
|
---|
| 17 | declare -r TS_POSITION=${CSI}$'65G'
|
---|
[6f75d64] | 18 | declare -r LINE_WRAP_OFF=${CSI}$'?7l'
|
---|
| 19 | declare -r LINE_WRAP_ON=${CSI}$'?7h'
|
---|
[843c479] | 20 | declare -a RESET_LINE=${CURSOR_OFF}${ERASE_LINE}${FRAME_OPEN}${FRAME_CLOSE}
|
---|
| 21 |
|
---|
| 22 | declare -a GRAPHIC_STR="| / - \\ + "
|
---|
| 23 | declare -i SEC=0 # Seconds accumulator
|
---|
[ddf5f77] | 24 | declare -i PREV_SEC=0
|
---|
| 25 |
|
---|
[b0ba1f0] | 26 | # Prevent segfault on stripping phases
|
---|
[c180dec] | 27 | if [[ "$BASHBIN" = "/tools/bin/bash" ]] ; then
|
---|
[b0ba1f0] | 28 | SLEEP=/tools/bin/sleep
|
---|
[6b26852] | 29 | elif [ -x /bin/sleep ] ; then
|
---|
[c180dec] | 30 | SLEEP=/bin/sleep
|
---|
[6b26852] | 31 | else
|
---|
| 32 | SLEEP=/usr/bin/sleep
|
---|
[b0ba1f0] | 33 | fi
|
---|
| 34 |
|
---|
[843c479] | 35 | write_or_exit() {
|
---|
[7dd28ea] | 36 | # make has been killed or failed or run to completion, leave
|
---|
[d44206f] | 37 | [[ ! -e /proc/${MAKE_PPID} ]] && echo -n "${CURSOR_ON}" && exit
|
---|
[041f2ed] | 38 |
|
---|
[e2ef100] | 39 | # Target build complete, leave.
|
---|
| 40 | [[ -f ${TARGET} ]] && echo -n "${CURSOR_ON}" && exit
|
---|
[041f2ed] | 41 |
|
---|
[843c479] | 42 | # It is safe to write to the screen
|
---|
| 43 | echo -n "$1"
|
---|
| 44 | }
|
---|
| 45 |
|
---|
[ddf5f77] | 46 | # initialize screen
|
---|
[045b2dc] | 47 | write_or_exit "${RESET_LINE}${TS_POSITION}0 min. 0 sec"
|
---|
[ddf5f77] | 48 |
|
---|
| 49 | # loop forever..
|
---|
| 50 | while true ; do
|
---|
| 51 |
|
---|
| 52 | # Loop through the animation string
|
---|
[843c479] | 53 | for GRAPHIC_CHAR in ${GRAPHIC_STR} ; do
|
---|
[ddf5f77] | 54 | write_or_exit "${CSI}$((SEC + 3))G${GRAPHIC_CHAR}"
|
---|
[b0ba1f0] | 55 | $SLEEP .12 # This value MUST be less than .2 seconds.
|
---|
[843c479] | 56 | done
|
---|
[ddf5f77] | 57 |
|
---|
| 58 | # A BASH internal variable, the number of seconds the script
|
---|
| 59 | # has been running. modulo convert to 0-59
|
---|
| 60 | SEC=$(($SECONDS % 60))
|
---|
| 61 |
|
---|
| 62 | # Detect rollover of the seconds.
|
---|
| 63 | (( PREV_SEC > SEC )) && write_or_exit "${RESET_LINE}"
|
---|
[7072e1f] | 64 | PREV_SEC=$SEC
|
---|
[ddf5f77] | 65 |
|
---|
| 66 | # Display the accumulated time. div minutes.. modulo seconds.
|
---|
[6f75d64] | 67 | write_or_exit "${TS_POSITION}$(($SECONDS / 60)) min. $SEC sec"
|
---|
[843c479] | 68 | done
|
---|
| 69 |
|
---|
[ddf5f77] | 70 | exit
|
---|