diff options
-rw-r--r-- | subr/build_init.subr | 4 | ||||
-rw-r--r-- | subr/ex_pkg_dispatch.subr | 2 | ||||
-rw-r--r-- | subr/ex_rtl_log.subr | 41 |
3 files changed, 31 insertions, 16 deletions
diff --git a/subr/build_init.subr b/subr/build_init.subr index 8b3e6181..3ae592e0 100644 --- a/subr/build_init.subr +++ b/subr/build_init.subr @@ -49,8 +49,10 @@ build_init() { touch "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}"; fi; if [ -e "${DEFAULT_BUILD_LOG_FNAME}" ]; then - mv -- "${DEFAULT_BUILD_LOG_FNAME} ${DEFAULT_BUILD_LOG_LAST_FNAME}"; + ex_rtl_fileop mv "${DEFAULT_BUILD_LOG_FNAME} ${DEFAULT_BUILD_LOG_LAST_FNAME}"; fi; + ex_rtl_fileop touch "${DEFAULT_BUILD_LOG_FNAME}"; + BUILD_IS_PARENT=1; BUILD_DATE_START="$(ex_rtl_date %Y-%m-%d-%H-%M-%S)"; BUILD_NFINI="${BUILD_NSKIP:=${BUILD_NFAIL:=${BUILD_NBUILT:=0}}}"; BUILD_TIMES_SECS="$(ex_rtl_date %s)"; diff --git a/subr/ex_pkg_dispatch.subr b/subr/ex_pkg_dispatch.subr index 92890ba6..771b2afe 100644 --- a/subr/ex_pkg_dispatch.subr +++ b/subr/ex_pkg_dispatch.subr @@ -19,7 +19,7 @@ exp_pkg_dispatch() { else _stderrout_path="${BUILD_WORKDIR}/${_pkg_name}_stderrout.log"; "${_dispatch_fn}" start_pkg "${_pkg_name}" "${_tgt_name}"; - (set -o errexit -o noglob; + (set -o errexit -o noglob; BUILD_IS_PARENT=0; ex_pkg_env "${_pkg_name}" "${_tgt_name}" "${_restart_at}"; trap "if [ \${?} -eq 0 ]; then \ echo \"done ${_pkg_name} ${_tgt_name}\" >&3; \ diff --git a/subr/ex_rtl_log.subr b/subr/ex_rtl_log.subr index 45dbc8df..05653c79 100644 --- a/subr/ex_rtl_log.subr +++ b/subr/ex_rtl_log.subr @@ -2,6 +2,14 @@ # set -o noglob is assumed. # +exp_rtl_log_printf() { + local _attrs="${1}" _msg; shift; _msg="$(printf "${@}")"; + if [ "${BUILD_IS_PARENT:-0}" -eq 1 ]; then + printf "%s\n" "${_msg}" >> "${DEFAULT_BUILD_LOG_FNAME}"; + fi; + printf "\033[0m\033[${_attr}m%s\033[0m\n" "${_msg}"; +}; + ex_rtl_log_env_vars() { local _nvar=1 _arg _arg_len_max=0; ex_rtl_log_msg info "Variables for this ${1:-build}:"; shift; @@ -25,7 +33,7 @@ ex_rtl_log_set_vnfo_lvl() { }; ex_rtl_log_msg() { - local _lvl="${1}"; shift; + local _lvl="${1}" _attr; shift; if [ "${_lvl}" = vnfo ]\ || [ "${_lvl}" = vucc ]\ && [ "${EXP_RTL_LOG_VNFO_LVL:-0}" -lt 1 ]; then @@ -38,22 +46,27 @@ ex_rtl_log_msg() { return; fi; case "${_lvl}" in - failexit) printf "\033[0m\033[${DEFAULT_LOG_MSG_FAIL_COLOUR}m"; ;; - fail) printf "\033[0m\033[${DEFAULT_LOG_MSG_FAIL_COLOUR}m"; ;; - info) printf "\033[0m\033[${DEFAULT_LOG_MSG_INFO_COLOUR}m"; ;; - inf2) printf "\033[0m\033[${DEFAULT_LOG_MSG_INF2_COLOUR}m"; ;; - vnfo) printf "\033[0m\033[${DEFAULT_LOG_MSG_VNFO_COLOUR}m"; ;; - vvfo) printf "\033[0m\033[${DEFAULT_LOG_MSG_VVFO_COLOUR}m"; ;; - vvvo) printf "\033[0m\033[${DEFAULT_LOG_MSG_VVVO_COLOUR}m"; ;; - succ) printf "\033[0m\033[${DEFAULT_LOG_MSG_SUCC_COLOUR}m"; ;; - suc2) printf "\033[0m\033[${DEFAULT_LOG_MSG_SUC2_COLOUR}m"; ;; - vucc) printf "\033[0m\033[${DEFAULT_LOG_MSG_VUCC_COLOUR}m"; ;; + failexit) _attr="${DEFAULT_LOG_MSG_FAIL_COLOUR}"; ;; + fail) _attr="${DEFAULT_LOG_MSG_FAIL_COLOUR}"; ;; + info) _attr="${DEFAULT_LOG_MSG_INFO_COLOUR}"; ;; + inf2) _attr="${DEFAULT_LOG_MSG_INF2_COLOUR}"; ;; + vnfo) _attr="${DEFAULT_LOG_MSG_VNFO_COLOUR}"; ;; + vvfo) _attr="${DEFAULT_LOG_MSG_VVFO_COLOUR}"; ;; + vvvo) _attr="${DEFAULT_LOG_MSG_VVVO_COLOUR}"; ;; + succ) _attr="${DEFAULT_LOG_MSG_SUCC_COLOUR}"; ;; + suc2) _attr="${DEFAULT_LOG_MSG_SUC2_COLOUR}"; ;; + vucc) _attr="${DEFAULT_LOG_MSG_VUCC_COLOUR}"; ;; esac; if [ ${#} -gt 1 ]; then - printf "==> %s %s %s\033[0m\n" "$(ex_rtl_date)" "${1}" "$*"; + exp_rtl_log_printf "${_attrs}" "==> %s %s %s" "$(ex_rtl_date)" "${1}" "$*"; else - printf "==> %s %s\033[0m\n" "$(ex_rtl_date)" "${1}"; - fi; [ ${_lvl} = failexit ] && exit 1 || return 0; + exp_rtl_log_printf "${_attrs}" "==> %s %s" "$(ex_rtl_date)" "${1}"; + fi; + if [ ${_lvl} = failexit ]; then + exit 1; + else + return 0; + fi; }; # vim:filetype=sh |