source: common/progress_bar.sh@ 496f8f3

experimental
Last change on this file since 496f8f3 was 50fb011, checked in by George Boudreau <georgeb@…>, 18 years ago

First commit of changes to makefile generation. Makefile now does recursive calls to itself for the different phases..SETUP,LUSER,CHROOT,ROOT

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