scripts/functions
changeset 96 aa1a9fbd6eb8
parent 88 f67b52e42fd1
child 97 63a30dd47eb8
     1.1 --- a/scripts/functions	Sun May 13 19:03:49 2007 +0000
     1.2 +++ b/scripts/functions	Thu May 17 16:22:51 2007 +0000
     1.3 @@ -13,6 +13,8 @@
     1.4          CT_DoLog ERROR "      called from \"${BASH_SOURCE[${depth}]}\" at line # ${BASH_LINENO[${depth}-1]} in function \"${FUNCNAME[${depth}]}\""
     1.5      done
     1.6      CT_DoLog ERROR "Look at \"${CT_ACTUAL_LOG_FILE}\" for more info on this error."
     1.7 +    CT_STEP_COUNT=1
     1.8 +    CT_DoEnd ERROR
     1.9      exit $ret
    1.10  }
    1.11  trap CT_OnError ERR
    1.12 @@ -28,25 +30,6 @@
    1.13  CT_LOG_LEVEL_DEBUG=4
    1.14  CT_LOG_LEVEL_ALL=5
    1.15  
    1.16 -# Attributes
    1.17 -_A_NOR="\\033[0m"
    1.18 -_A_BRI="\\033[1m"
    1.19 -_A_DIM="\\033[2m"
    1.20 -_A_UND="\\033[4m"
    1.21 -_A_BRB="\\033[5m"
    1.22 -_A_REV="\\033[7m"
    1.23 -_A_HID="\\033[8m"
    1.24 -
    1.25 -# Fore colors
    1.26 -_F_BLK="\\033[30m"
    1.27 -_F_RED="\\033[31m"
    1.28 -_F_GRN="\\033[32m"
    1.29 -_F_YEL="\\033[33m"
    1.30 -_F_BLU="\\033[34m"
    1.31 -_F_MAG="\\033[35m"
    1.32 -_F_CYA="\\033[36m"
    1.33 -_F_WHI="\\033[37m"
    1.34 -
    1.35  # A function to log what is happening
    1.36  # Different log level are available:
    1.37  #   - ERROR:   A serious, fatal error occurred
    1.38 @@ -84,10 +67,8 @@
    1.39                l="`printf \"[%-5s]%*s%s%s\" \"${cur_L}\" \"${indent}\" \" \" \"${line}\"`"
    1.40                # There will always be a log file, be it /dev/null
    1.41                echo -e "${l}" >>"${CT_ACTUAL_LOG_FILE}"
    1.42 -              color="CT_${cur_L}_COLOR"
    1.43 -              normal="CT_NORMAL_COLOR"
    1.44                if [ ${cur_l} -le ${max_level} ]; then
    1.45 -                  echo -e "\r${!color}${l}${!normal}"
    1.46 +                  echo -e "\r${l}"
    1.47                fi
    1.48                if [ "${CT_LOG_PROGRESS_BAR}" = "y" ]; then
    1.49                    str=`CT_DoDate +%s`
    1.50 @@ -105,7 +86,21 @@
    1.51      return 0
    1.52  }
    1.53  
    1.54 -# Abort the execution with a error message
    1.55 +# Tail message to be logged whatever happens
    1.56 +# Usage: CT_DoEnd <level>
    1.57 +CT_DoEnd()
    1.58 +{
    1.59 +    CT_STOP_DATE=`CT_DoDate +%s%N`
    1.60 +    CT_STOP_DATE_HUMAN=`CT_DoDate +%Y%m%d.%H%M%S`
    1.61 +    CT_DoLog INFO "Build completed at ${CT_STOP_DATE_HUMAN}"
    1.62 +    elapsed=$((CT_STOP_DATE-CT_STAR_DATE))
    1.63 +    elapsed_min=$((elapsed/(60*1000*1000*1000)))
    1.64 +    elapsed_sec=`printf "%02d" $(((elapsed%(60*1000*1000*1000))/(1000*1000*1000)))`
    1.65 +    elapsed_csec=`printf "%02d" $(((elapsed%(1000*1000*1000))/(10*1000*1000)))`
    1.66 +    CT_DoLog INFO "(elapsed: ${elapsed_min}:${elapsed_sec}.${elapsed_csec})"
    1.67 +}
    1.68 +
    1.69 +# Abort the execution with an error message
    1.70  # Usage: CT_Abort <message>
    1.71  CT_Abort() {
    1.72      CT_DoLog ERROR "$1" >&2