Changeset 843c479


Ignore:
Timestamp:
06/08/2006 09:05:03 PM (18 years ago)
Author:
Manuel Canales Esparcia <manuel@…>
Branches:
1.0, 2.3, 2.3.x, 2.4, ablfs, ablfs-more, legacy, new_features, trunk
Children:
7dd28ea
Parents:
cee9568
Message:

Now the progress bar is a pretty time counter.

Location:
common
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • common/makefile-functions

    rcee9568 r843c479  
    88BLUE= "[1;34m"
    99WHITE= "[00m"
     10CURSOR_ON= "[?25h"
    1011
    1112define echo_message
     
    7374  @echo $(BOLD)
    7475  @echo --------------------------------------------------------------------------------
    75   @echo -e \\t\\t$(GREEN)Have a nice day $(ORANGE):-\)$(BOLD)
     76  @echo -e \\t\\t$(GREEN)Have a nice day $(ORANGE):-\)$(BOLD)$(CURSOR_ON)
    7677  @echo --------------------------------------------------------------------------------$(WHITE)
    7778endef
     
    9899  @echo  The build process should resume. Follow any instructions that appear.
    99100  @echo --------------------------------------------------------------------------------
    100   @echo -e \\t\\t$(GREEN)Have a nice day $(ORANGE):-\)$(BOLD)
     101  @echo -e \\t\\t$(GREEN)Have a nice day $(ORANGE):-\)$(BOLD)$(CURSOR_ON)
    101102  @echo --------------------------------------------------------------------------------$(WHITE)
    102103endef
  • common/progress_bar.sh

    rcee9568 r843c479  
    55set -e
    66
     7# Be sure that we know the taget name
    78[[ -z $1 ]] && exit
     9TARGET=$1  # Remember the target build we are looking for
    810
    9 if [ ! -f $1 ] ; then
    10   while fuser -v . 2>&1 | grep make >/dev/null ; do
    11     echo -n "."
    12     sleep 1
    13     [[ -f $1 ]] && exit
     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'
     18declare -a  RESET_LINE=${CURSOR_OFF}${ERASE_LINE}${FRAME_OPEN}${FRAME_CLOSE}
     19
     20declare -a  GRAPHIC_STR="| / - \\ + "
     21declare -i  MIN=0  # Start value for minutes
     22declare -i  SEC=0  # Seconds accumulator
     23declare -i  POS=0  # Start value for seconds/cursor position
     24
     25write_or_exit() {
     26    # make has been killed or failed, leave
     27  if ! fuser -v . 2>&1 | grep make >/dev/null ; then
     28     echo -n "${CURSOR_ON}" && exit
     29  fi
     30    # Target build complete, leave. If we are here, make is alive and a new
     31    # package target may has been started. Close this instance of the script.
     32    # The cursor will be restored by echo-finished in makefile-functions.
     33  [[ -f ${TARGET} ]] && exit
     34    # It is safe to write to the screen
     35  echo -n "$1"
     36}
     37
     38  # This will loop forever.. or overflow, which ever comes forst :)
     39for ((MIN=0; MIN >= 0; MIN++)); do
     40  write_or_exit "${RESET_LINE}${TS_POSITION}${MIN} min. 0 sec. "
     41  # Count the seconds
     42  for ((SEC=1, POS=3; SEC <= 60; SEC++, POS++)); do
     43    for GRAPHIC_CHAR in ${GRAPHIC_STR} ; do
     44      write_or_exit "${CSI}${POS}G${GRAPHIC_CHAR}"
     45      sleep .2
     46    done
     47      # Display then accumlated time.
     48    write_or_exit "${TS_POSITION}${MIN} min. ${SEC} sec. "
    1449  done
    15 fi
     50done
     51exit
     52
Note: See TracChangeset for help on using the changeset viewer.