#!/usr/bin/env bash # Sage progress indicator # (c) Harald Schilly, harald.schilly@gmail.com, Vienna, Austria # License: GPLv2+ # # use it this way: # watch -n 10 ./sage_progress # TODO assume, script is in SAGE_ROOT (will change!) cd `dirname "$0"` STDLST=".standard.list" INSTLST=".install.list" srcsize=70 pbar () { bar=`echo "$1 / $2 * $srcsize" | bc -l` printf "|" for i in $(seq 1 $bar); do printf "X" 1>&2; done for i in $(seq $bar $(( $srcsize-1 ))); do printf "-" 1>&2; done printf "|" echo } ccstats () { if which ccache >/dev/null; then ccache -s echo "note: clear ccache stats with 'ccache -z'" fi } runtime () { if [ -e .BUILDSTART ]; then sta=`cat .BUILDSTART` cur=`date -u "+%s"` ela=$((cur-sta)) sec=$((ela % 60)) min=$((ela / 60 % 60)) hrs=$((ela / 3600 % 24)) dys=$((ela / 3600 / 24)) echo "elapsed: $dys d $hrs h $min min $sec sec" fi } while true; do find spkg/base/ -maxdepth 1 -type f -iname "*install*" -exec basename {} "-install" \; | tee $STDLST > /dev/null #base=`find spkg/base/ -maxdepth 1 -type f -iname "*install*" | wc -l` base=`wc -l < $STDLST` find spkg/installed/ -type f -exec basename {} \; | sort | tee $INSTLST > /dev/null installed=`wc -l < $INSTLST` find spkg/standard/ -iname "*.spkg" -type f -exec basename {} ".spkg" \; | sort | tee -a $STDLST > /dev/null sort < $STDLST | tee $STDLST > /dev/null standard=`wc -l < $STDLST` if [ $standard = 0 ]; then echo 'ERROR: $standard==0' cat $STDLST continue fi standard=$(($standard+1)) # add +1 since rpy is included in r spkg! both=`join $STDLST $INSTLST | wc -l` both=$(($both+1)) # add +1 since rpy is included in r spkg! clear #clears shell echo "base: $base" echo "installed: $installed" echo "standard: $standard" echo "both: $both" runtime #what's a good method to get the current one? # they don't work: # `ls -1tr spkg/build/ | tail -1` #`find spkg/build/ -maxdepth 1 -mtime +1 -type d ` current=`ls -1 spkg/build/ | grep -v "bzip2" | grep -v "old" | grep -v "prereq"` if [ ! "$current" = "" ]; then echo "currently: $current" else echo "currently: no building in progress, probably building documentation ..." fi #progress=`echo "lenght=5; scale=2; $installed / ($base + $standard) * 100" | bc -l` progress=`echo "lenght=5; scale=2; $both / $standard * 100" | bc -l` echo "progress: $progress %" echo pbar $both $standard pbar $both $standard pbar $both $standard echo ccstats echo "exit with CTRL-C" sleep 10 done