diff options
Diffstat (limited to 'subr')
-rw-r--r-- | subr/ex_pkg_dispatch.subr | 14 | ||||
-rw-r--r-- | subr/rtl_complex.subr | 7 |
2 files changed, 11 insertions, 10 deletions
diff --git a/subr/ex_pkg_dispatch.subr b/subr/ex_pkg_dispatch.subr index 018970a4..8a31758f 100644 --- a/subr/ex_pkg_dispatch.subr +++ b/subr/ex_pkg_dispatch.subr @@ -61,17 +61,14 @@ 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 _status_percentage=""; + _restart_at="${8}" _workdir="${9}" _pipe_msg="" _pkg_name="" _rc=0 _status_percentage=0; 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_COUNT_CUR+=1)); : $((EXP_PKG_DISPATCH_NJOBS-=1)); EX_PKG_FINISHED="$(rtl_lconcat "${EX_PKG_FINISHED}" "${_pkg_name}")"; - _status_percentage="$(((100 * ${EXP_PKG_DISPATCH_COUNT_CUR} + ${EXP_PKG_DISPATCH_COUNT_MAX} / 2)))"; - if [ "${_status_percentage}" -gt 0 ]; then - _status_percentage="$((${_status_percentage} / ${EXP_PKG_DISPATCH_COUNT_MAX}))"; - fi; + _status_percentage="$(rtl_percentage "${EXP_PKG_DISPATCH_COUNT_CUR}" "${EXP_PKG_DISPATCH_COUNT_MAX}")"; "${_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}")"; @@ -124,11 +121,8 @@ exp_pkg_dispatch_group() { # 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}"\ - _status_percentage="$((100 * ${EXP_PKG_DISPATCH_COUNT_CUR} + (${EXP_PKG_DISPATCH_COUNT_MAX} / 2)))"; - if [ "${_status_percentage}" -gt 0 ]; then - _status_percentage="$((${_status_percentage} / ${EXP_PKG_DISPATCH_COUNT_MAX}))"; - fi; + _group_name="${4}" _pkg_name="${5}" _restart_at="${6}" _workdir="${7}" _status_percentage=0; + _status_percentage="$(rtl_percentage "${EXP_PKG_DISPATCH_COUNT_CUR}" "${EXP_PKG_DISPATCH_COUNT_MAX}")"; 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 \ diff --git a/subr/rtl_complex.subr b/subr/rtl_complex.subr index cb7c90bd..63175bed 100644 --- a/subr/rtl_complex.subr +++ b/subr/rtl_complex.subr @@ -192,6 +192,13 @@ rtl_kill_tree() { fi; }; +rtl_percentage() { + local _in="${1}" _max="${2}" _perc; + _perc="$((100 * ${_in} + ${_max} / 2))"; + _perc="$((${_perc} ? ${_perc} / ${_max} : ${_perc}))"; + printf "%d\n" "${_perc}"; +}; + rtl_prompt() { local _fmt="${1}" _choice=""; shift; printf "${_fmt}? (y|N) " "${@}"; |