diff options
Diffstat (limited to 'subr')
-rw-r--r-- | subr/ex_pkg_dispatch.subr | 30 |
1 files changed, 19 insertions, 11 deletions
diff --git a/subr/ex_pkg_dispatch.subr b/subr/ex_pkg_dispatch.subr index 4d4574d2..3145ab2f 100644 --- a/subr/ex_pkg_dispatch.subr +++ b/subr/ex_pkg_dispatch.subr @@ -61,14 +61,18 @@ exp_pkg_dispatch_expand_packages() { exp_pkg_dispatch_group() { local _build_steps_default="${1}" _build_vars_default="${2}" _checkfl="${3}" \ _dispatch_fn="${4}" _group_name="${5}" _njobs_max="${6}" _pipe_path="${7}" \ - _restart_at="${8}" _workdir="${9}" _pipe_msg="" _pkg_name="" _rc=0; + _restart_at="${8}" _workdir="${9}" _pipe_msg="" _pkg_name="" _rc=0 _status_percentage=""; rtl_fileop mkfifo "${_pipe_path}"; while true; do while [ "${EXP_PKG_DISPATCH_NJOBS:-0}" -gt 0 ] && read _pipe_msg; do case "${_pipe_msg%% *}" in done) _pkg_name="${_pipe_msg#done * }"; : $((EXP_PKG_DISPATCH_NJOBS-=1)); EX_PKG_FINISHED="$(rtl_lconcat "${EX_PKG_FINISHED}" "${_pkg_name}")"; - "${_dispatch_fn}" finish_pkg ${_pipe_msg#done }; + _status_percentage="$(((100 * ${EXP_PKG_DISPATCH_COUNT} + ${EXP_PKG_DISPATCH_COUNT_MAX} / 2)))"; + if [ "${_status_percentage}" -gt 0 ]; then + _status_percentage="$((${_status_percentage} / ${EXP_PKG_DISPATCH_COUNT_MAX}))"; + fi; + "${_dispatch_fn}" finish_pkg ${_pipe_msg#done } "${EXP_PKG_DISPATCH_COUNT_MAX}" "${_status_percentage}"; EX_PKG_NAMES="$(rtl_lfilter "${EX_PKG_NAMES}" "${_pkg_name}")"; EX_PKG_DISPATCH_WAIT="$(rtl_lfilter "${EX_PKG_DISPATCH_WAIT}" "${_pkg_name}")"; if [ -n "${EX_PKG_NAMES}" ] && [ "${_rc}" -eq 0 ]; then @@ -84,7 +88,7 @@ exp_pkg_dispatch_group() { break; fi; ;; fail) : $((EXP_PKG_DISPATCH_NJOBS-=1)); _rc=1; - "${_dispatch_fn}" fail_pkg ${_pipe_msg#fail }; ;; + "${_dispatch_fn}" fail_pkg ${_pipe_msg#fail } "${EXP_PKG_DISPATCH_COUNT_MAX}"; ;; msg_pkg) "${_dispatch_fn}" msg_pkg ${_pipe_msg#msg_pkg }; ;; step) "${_dispatch_fn}" step_pkg ${_pipe_msg#step }; ;; @@ -119,15 +123,19 @@ exp_pkg_dispatch_group() { # Return: zero (0) on success, non-zero (>0) on failure, ${EXP_PKG_DISPATCH_NJOBS}, ${EXP_PKG_DISPATCH_COUNT}, ${EX_PKG_NAMES}, and ${EX_PKG_DISPATCH_WAIT} may be mutated post-return. # exp_pkg_dispatch_package() { - local _build_steps_default="${1}" _build_vars_default="${2}" _dispatch_fn="${3}" \ - _group_name="${4}" _pkg_name="${5}" _restart_at="${6}" _workdir="${7}"; - if "${_dispatch_fn}" start_pkg "${_group_name}" "${_pkg_name}" "$((${EXP_PKG_DISPATCH_COUNT}+1))" "${EXP_PKG_DISPATCH_COUNT_MAX}"; then + local _build_steps_default="${1}" _build_vars_default="${2}" _dispatch_fn="${3}"\ + _group_name="${4}" _pkg_name="${5}" _restart_at="${6}" _workdir="${7}"\ + _status_percentage="$((100 * ${EXP_PKG_DISPATCH_COUNT} + (${EXP_PKG_DISPATCH_COUNT_MAX} / 2)))"; + if [ "${_status_percentage}" -gt 0 ]; then + _status_percentage="$((${_status_percentage} / ${EXP_PKG_DISPATCH_COUNT_MAX}))"; + fi; + if "${_dispatch_fn}" start_pkg "${_group_name}" "${_pkg_name}" "$((${EXP_PKG_DISPATCH_COUNT}+1))" "${EXP_PKG_DISPATCH_COUNT_MAX}" "${_status_percentage}"; then : $((EXP_PKG_DISPATCH_NJOBS+=1)); : $((EXP_PKG_DISPATCH_COUNT+=1)); EX_PKG_DISPATCH_WAIT="$(rtl_lconcat "${EX_PKG_DISPATCH_WAIT}" "${_pkg_name}")"; - (trap "if [ \${?} -eq 0 ]; then \ - printf \"done %s %s\n\" \"${_group_name}\" \"${_pkg_name}\" >&3; \ - else \ - printf \"fail %s %s\n\" \"${_group_name}\" \"${_pkg_name}\" >&3; \ - pkill -U "${$}"; \ + (trap "if [ \${?} -eq 0 ]; then \ + printf \"done %s %s %d\n\" \"${_group_name}\" \"${_pkg_name}\" \"${EXP_PKG_DISPATCH_COUNT}\" >&3; \ + else \ + printf \"fail %s %s %d\n\" \"${_group_name}\" \"${_pkg_name}\" \"${EXP_PKG_DISPATCH_COUNT}\" >&3; \ + pkill -U "${$}"; \ fi;" EXIT HUP INT TERM USR1 USR2; set +o errexit -o noglob -o nounset; BUILD_IS_PARENT=0; rtl_log_set_fname ""; rtl_log_set_no_attr 1; if ex_pkg_env "${_build_steps_default}" "${_build_vars_default}" \ |