From fc9bdbdb604ff5e140f6682115e097f49631fae6 Mon Sep 17 00:00:00 2001 From: Lucio Andrés Illanes Albornoz Date: Feb 12 2020 01:23:14 +0000 Subject: {build.sh,subr/ex_pkg_dispatch.subr}: prepend {disabled,skipped,start}_pkg messages w/ {current,maximum} count of packages in build group. --- diff --git a/build.sh b/build.sh index 24dd75c..1b4cee4 100755 --- a/build.sh +++ b/build.sh @@ -54,23 +54,23 @@ buildp_dispatch() { finish_group) ex_rtl_log_msg suc2 "Finished \`${_group_name}' build group."; ;; # Package build - start_pkg) ex_rtl_log_msg info "Starting \`${_pkg_name}' build..."; ;; + start_pkg) ex_rtl_log_msg info "$(printf "[%03d/%03d] Starting \`%s' build..." "${4}" "${5}" "${_pkg_name}")"; ;; finish_pkg) : $((BUILD_NFINI+=1)); if [ "${ARG_VERBOSE:-0}" -ge 2 ]; then cat "${BUILD_WORKDIR}/${_pkg_name}_stderrout.log"; fi; - ex_rtl_log_msg succ "Finished \`${_pkg_name}' build."; ;; + ex_rtl_log_msg succ "$(printf "Finished \`%s' build." "${_pkg_name}")"; ;; fail_pkg) : $((BUILD_NFAIL+=1)); BUILD_PKGS_FAILED="${BUILD_PKGS_FAILED:+${BUILD_PKGS_FAILED} }${_pkg_name}"; if [ "${ARG_RELAXED:-0}" -eq 1 ]; then - ex_rtl_log_msg fail "Build failed in \`${_pkg_name}', check \`${BUILD_WORKDIR}/${_pkg_name}_stderrout.log' for details."; + ex_rtl_log_msg fail "$(printf "Build failed in \`%s', check \`%s' for details." "${_pkg_name}" "${BUILD_WORKDIR}/${_pkg_name}_stderrout.log")"; else ex_rtl_log_msg fail "${BUILD_WORKDIR}/${_pkg_name}_stderrout.log:"; cat "${BUILD_WORKDIR}/${_pkg_name}_stderrout.log"; if [ -n "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}" ]; then echo "${_pkg_name}" > "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}"; fi; - ex_rtl_log_msg fail "Build failed in \`${_pkg_name}'."; + ex_rtl_log_msg fail "$(printf "Build failed in \`%s'." "${_pkg_name}")"; if [ "${ARG_PARALLEL:-0}" -eq 1 ]; then ex_rtl_log_msg fail "Terminating pending builds..."; pkill -P "${$}"; @@ -78,10 +78,10 @@ buildp_dispatch() { exit 1; fi; ;; disabled_pkg) : $((BUILD_NSKIP+=1)); - ex_rtl_log_msg vnfo "Skipping disabled package \`${_pkg_name}.'"; ;; + ex_rtl_log_msg vnfo "$(printf "[%03d/%03d] Skipping disabled package \`%s.'" "${4}" "${5}" "${_pkg_name}")"; ;; skipped_pkg) : $((BUILD_NSKIP+=1)); - ex_rtl_log_msg vnfo "Skipping finished package \`${_pkg_name}.'"; ;; - step_pkg) ex_rtl_log_msg vucc "Finished build step ${4} of package \`${_pkg_name}'."; ;; + ex_rtl_log_msg vnfo "$(printf "[%03d/%03d] Skipping finished package \`%s.'" "${4}" "${5}" "${_pkg_name}")"; ;; + step_pkg) ex_rtl_log_msg vucc "$(printf "Finished build step %s of package \`%s'." "${4}" "${_pkg_name}")"; ;; # Child process exec_finish) ;; @@ -100,4 +100,4 @@ buildp_dispatch() { for __ in $(find subr -name *.subr); do . "${__}"; done; buildp_dispatch start_build "${@}"; -# vim:filetype=sh +# vim:filetype=sh textwidth=0 diff --git a/subr/ex_pkg_dispatch.subr b/subr/ex_pkg_dispatch.subr index e2707ae..2a40e16 100644 --- a/subr/ex_pkg_dispatch.subr +++ b/subr/ex_pkg_dispatch.subr @@ -43,18 +43,20 @@ exp_pkg_dispatch_package() { _stderrout_path="${5}" _pipe_path="${6}" _pkg_name_uc="" _rc=0; _pkg_name_uc="$(ex_rtl_toupper "${_pkg_name}")"; if [ -n "$(ex_rtl_get_var_unsafe PKG_${_pkg_name_uc}_DISABLED)" ]; then - _pkgs_complete="${_pkgs_complete:+${_pkgs_complete} }${_pkg_name}"; _rc=1; + _pkgs_complete="${_pkgs_complete:+${_pkgs_complete} }${_pkg_name}"; _pkg_names="$(ex_rtl_lfilter "${_pkg_names}" "${_pkg_name}")"; - "${_dispatch_fn}" disabled_pkg "${_group_name}" "${_pkg_name}"; + : $((_pkgs_count+=1)); _rc=1; + "${_dispatch_fn}" disabled_pkg "${_group_name}" "${_pkg_name}" "${_pkgs_count}" "${_pkgs_count_max}"; elif ex_pkg_state_test "${_pkg_name}" finish\ && [ -z "${_restart_at}" ]; then - _pkgs_complete="${_pkgs_complete:+${_pkgs_complete} }${_pkg_name}"; _rc=1; + _pkgs_complete="${_pkgs_complete:+${_pkgs_complete} }${_pkg_name}"; _pkg_names="$(ex_rtl_lfilter "${_pkg_names}" "${_pkg_name}")"; - "${_dispatch_fn}" skipped_pkg "${_group_name}" "${_pkg_name}"; + : $((_pkgs_count+=1)); _rc=1; + "${_dispatch_fn}" skipped_pkg "${_group_name}" "${_pkg_name}" "${_pkgs_count}" "${_pkgs_count_max}"; else - _pkgs_wait="${_pkgs_wait:+${_pkgs_wait} }${_pkg_name}"; + : $((_pkgs_count+=1)); _pkgs_wait="${_pkgs_wait:+${_pkgs_wait} }${_pkg_name}"; _stderrout_path="${BUILD_WORKDIR}/${_pkg_name}_stderrout.log"; - "${_dispatch_fn}" start_pkg "${_group_name}" "${_pkg_name}"; + "${_dispatch_fn}" start_pkg "${_group_name}" "${_pkg_name}" "${_pkgs_count}" "${_pkgs_count_max}"; (set -o errexit -o noglob; BUILD_IS_PARENT=0; ex_pkg_env "${_group_name}" "${_pkg_name}" "${_restart_at}"; ex_pkg_exec "${_group_name}" "${_pkg_name}" "${_restart_at}" \ @@ -95,11 +97,14 @@ exp_pkg_get_packages() { ex_pkg_dispatch() { local _group_name="${1}" _restart="${2}" _restart_at="${3}" _dispatch_fn="${4}" _pkgs_found_vname="${5}" \ _njob="" _njobs=0 _njobs_max=1 _pipe_msg="" _pipe_path="${BUILD_WORKDIR}/build.fifo" \ - _pkg_name="" _pkg_names="" _pkgs_complete="" _pkgs_found="" _pkgs_found_new="" _pkgs_wait="" \ - _script_rc=0 _stderrout_path=""; + _pkg_name="" _pkg_names="" _pkgs_complete="" _pkgs_count=0 _pkgs_count_max=0 _pkgs_found="" \ + _pkgs_found_new="" _pkgs_wait="" _script_rc=0 _stderrout_path=""; "${_dispatch_fn}" start_group "${_group_name}" ""; ex_rtl_fileop mkdir "${BUILD_WORKDIR}"; if exp_pkg_get_packages "${_dispatch_fn}" "${_group_name}" "${_restart}"\ && [ -n "${_pkg_names}" ]; then + for _pkg_name in ${_pkg_names}; do + : $((_pkgs_count_max+=1)); + done; if [ "${ARG_PARALLEL:-0}" -gt 1 ]\ && ! [ "$(ex_rtl_get_var_unsafe "$(ex_rtl_toupper "${_group_name}")"_IN_ORDER)" = 1 ]; then _njobs_max="${DEFAULT_BUILD_CPUS}"; @@ -108,7 +113,8 @@ ex_pkg_dispatch() { while [ "${_njobs:-0}" -gt 0 ]; do while read _pipe_msg; do case "${_pipe_msg%% *}" in - done) "${_dispatch_fn}" finish_pkg ${_pipe_msg#done }; _pkg_name="${_pipe_msg#done * }"; : $((_njobs-=1)); + done) "${_dispatch_fn}" finish_pkg ${_pipe_msg#done }; + : $((_njobs-=1)); _pkg_name="${_pipe_msg#done * }"; _pkgs_complete="${_pkgs_complete:+${_pkgs_complete} }${_pkg_name}"; _pkg_names="$(ex_rtl_lfilter "${_pkg_names}" "${_pkg_name}")"; _pkgs_wait="$(ex_rtl_lfilter "${_pkgs_wait}" "${_pkg_name}")"; @@ -119,8 +125,7 @@ ex_pkg_dispatch() { && [ -z "${_pkg_names}" ]; then break; fi; ;; - fail) _script_rc=1; - "${_dispatch_fn}" fail_pkg ${_pipe_msg#fail }; + fail) _script_rc=1; "${_dispatch_fn}" fail_pkg ${_pipe_msg#fail }; [ $((_njobs-=1)) -eq 0 ] && break; ;; step) "${_dispatch_fn}" step_pkg ${_pipe_msg#step }; ;; esac; done <>"${_pipe_path}";