From 763157f89f9332cee928ded934643529b541d2ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lucio=20Andr=C3=A9s=20Illanes=20Albornoz?= Date: Tue, 25 Feb 2020 21:16:30 +0000 Subject: subr/ex_pkg_dispatch.subr:exp_pkg_check_depends(): apply ex_rtl_uniq() to expanded package list. subr/ex_{pkg_dispatch,rtl_list}.subr: splits ex_rtl_lunfold_depends(). --- subr/ex_pkg_dispatch.subr | 25 +++---------------------- subr/ex_rtl_list.subr | 13 +++++++++++++ 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/subr/ex_pkg_dispatch.subr b/subr/ex_pkg_dispatch.subr index 0a2a80ff..d3053c47 100644 --- a/subr/ex_pkg_dispatch.subr +++ b/subr/ex_pkg_dispatch.subr @@ -14,10 +14,10 @@ exp_pkg_check_depends() { local _pkg_complete="${1}" _pkg_name="${2}" _pkg_wait="${3}" _restart_recursive="${4}" \ _pkg_depends="" _pkg_name_depend="" _dependfl=0; - if _pkg_depends="$(exp_pkg_expand_depends $(ex_rtl_get_var_unsafe -u "PKG_"${_pkg_name}"_DEPENDS"))"\ + if _pkg_depends="$(ex_rtl_lunfold_depends 'PKG_${_name}_DEPENDS' $(ex_rtl_get_var_unsafe -u "PKG_"${_pkg_name}"_DEPENDS"))"\ && [ -n "${_pkg_depends}" ]\ && ! [ -n "${_restart}" ] || [ "${_restart_recursive:-0}" -ge 1 ]; then - for _pkg_name_depend in ${_pkg_depends}; do + for _pkg_name_depend in $(ex_rtl_uniq ${_pkg_depends}); do if ! ex_rtl_lmatch "${_pkg_complete}" "${_pkg_name_depend}"\ || ex_rtl_lmatch "${_pkg_wait}" "${_pkg_name_depend}"; then _dependfl=1; break; @@ -78,25 +78,6 @@ exp_pkg_dispatch_packages() { done; }; -# -# exp_pkg_expand_depends() - expand list of package names to amended and ordered list according to dependency constraints -# @${@}: list of package names -# -# Return: zero (0) on success, non-zero (>0) on failure, list of packages on stdout -# -exp_pkg_expand_depends() { - local _pkg_depends="" _pkg_name="" _pkg_names=""; - for _pkg_name in "${@}"; do - if _pkg_depends="$(ex_rtl_get_var_unsafe -u "PKG_${_pkg_name}_DEPENDS")"\ - && [ -n "${_pkg_depends}" ]; then - _pkg_depends="$(exp_pkg_expand_depends ${_pkg_depends})"; - _pkg_names="$(ex_rtl_lconcat "${_pkg_names}" "${_pkg_depends}")"; - fi; - _pkg_names="$(ex_rtl_lconcat "${_pkg_names}" "${_pkg_name}")"; - done; - echo "${_pkg_names}"; -}; - # # exp_pkg_expand_packages() - expand build group name to list of packages ordered and filtered according to dependency and restart constraints # @_group_name: build group name @@ -113,7 +94,7 @@ exp_pkg_expand_packages() { _pkg_names="$(ex_rtl_lsearch "${_pkg_names}" "${_restart}")"; fi; if ! [ -n "${_restart}" ] || [ "${_restart_recursive:-0}" -ge 1 ]; then - _pkg_names="$(ex_rtl_uniq $(exp_pkg_expand_depends ${_pkg_names}))"; + _pkg_names="$(ex_rtl_uniq $(ex_rtl_lunfold_depends 'PKG_${_name}_DEPENDS' ${_pkg_names}))"; fi; for _pkg_name in ${_pkg_names}; do if [ -n "$(ex_rtl_get_var_unsafe -u "PKG_${_pkg_name}_DISABLED")" ]; then diff --git a/subr/ex_rtl_list.subr b/subr/ex_rtl_list.subr index 45a641c6..fb2bde72 100644 --- a/subr/ex_rtl_list.subr +++ b/subr/ex_rtl_list.subr @@ -59,4 +59,17 @@ ex_rtl_lsearch() { echo "${_lnew}"; }; +ex_rtl_lunfold_depends() { + local _vname_template="${1}" _depends="" _name="" _names=""; shift; + for _name in "${@}"; do + if _depends="$(ex_rtl_get_var_unsafe -u "$(eval printf \"%s\" \""${_vname_template}"\")")"\ + && [ -n "${_depends}" ]; then + _depends="$(ex_rtl_lunfold_depends "${_vname_template}" ${_depends})"; + _names="$(ex_rtl_lconcat "${_names}" "${_depends}")"; + fi; + _names="$(ex_rtl_lconcat "${_names}" "${_name}")"; + done; + echo "${_names}"; +}; + # vim:filetype=sh -- cgit v1.2.3