source: common/progress_bar.sh@ 1330ebc

2.3 2.3.x 2.4 ablfs ablfs-more legacy new_features trunk
Last change on this file since 1330ebc was 1330ebc, checked in by Manuel Canales Esparcia <manuel@…>, 18 years ago

Fixed chroot environment to be more closed to the one expected by the books.
Need be full tested.

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