Blame subr/ex_pkg_dispatch.subr

Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
#
Lucio Andrés Illanes Albornoz e1d469
# set +o errexit -o noglob -o nounset is assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
#
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz c6d6e0
# exp_pkg_dispatch_complete() - XXX
Lucio Andrés Illanes Albornoz c6d6e0
# @_dispatch_fn:	top-level dispatch function name
Lucio Andrés Illanes Albornoz c6d6e0
# @_group_names:	build group name(s)
Lucio Andrés Illanes Albornoz c6d6e0
# @_pkg_disabled:	list of disabled packages
Lucio Andrés Illanes Albornoz c6d6e0
# @_pkg_finished:	list of finished packages
Lucio Andrés Illanes Albornoz c6d6e0
#
Lucio Andrés Illanes Albornoz c6d6e0
# Return:		zero (0) on success, non-zero (>0) on failure.
Lucio Andrés Illanes Albornoz c6d6e0
#
Lucio Andrés Illanes Albornoz c6d6e0
exp_pkg_dispatch_complete() {
Lucio Andrés Illanes Albornoz c6d6e0
	local _dispatch_fn="${1}" _group_name="${2}" _pkg_disabled="${3}" _pkg_finished="${4}" _pkg_name="";
Lucio Andrés Illanes Albornoz c6d6e0
	for _pkg_name in ${_pkg_disabled}; do
Lucio Andrés Illanes Albornoz c6d6e0
		"${_dispatch_fn}" disabled_pkg "${_group_name}" "${_pkg_name}";
Lucio Andrés Illanes Albornoz c6d6e0
	done;
Lucio Andrés Illanes Albornoz c6d6e0
	for _pkg_name in ${_pkg_finished}; do
Lucio Andrés Illanes Albornoz c6d6e0
		"${_dispatch_fn}" skipped_pkg "${_group_name}" "${_pkg_name}";
Lucio Andrés Illanes Albornoz c6d6e0
	done;
Lucio Andrés Illanes Albornoz c6d6e0
};
Lucio Andrés Illanes Albornoz c6d6e0
Lucio Andrés Illanes Albornoz c6d6e0
#
Lucio Andrés Illanes Albornoz 60fba6
# exp_pkg_dispatch_expand_packages() - expand build group name to list of packages ordered and filtered according to dependency and restart constraints
Lucio Andrés Illanes Albornoz b6a9a1
# @_checkfl:		enable (1) or inhibit (0) dependency expansion
Lucio Andrés Illanes Albornoz b6a9a1
# @_forcefl:		enable (1) or inhibit (0) forcibly rebuilding finished packages
Lucio Andrés Illanes Albornoz 60fba6
# @_group_name:		build group name
Lucio Andrés Illanes Albornoz 60fba6
# @_restart:		optional whitespace-separated list of package names to rebuild
Lucio Andrés Illanes Albornoz b6a9a1
# @_reversefl:		unfold reverse dependencies (1) or dependencies (0)
Lucio Andrés Illanes Albornoz 60fba6
#
Lucio Andrés Illanes Albornoz 60fba6
# Return:		zero (0) on success, non-zero (>0) on failure, ${EX_PKG_DISABLED}, ${EX_PKG_FINISHED}, and ${EX_PKG_NAMES} set post-return.
Lucio Andrés Illanes Albornoz 60fba6
#
Lucio Andrés Illanes Albornoz 60fba6
exp_pkg_dispatch_expand_packages() {
Lucio Andrés Illanes Albornoz b6a9a1
	local	_checkfl="${1}" _forcefl="${2}" _group_name="${3}" _restart="${4}" _reversefl="${5}"\
Lucio Andrés Illanes Albornoz b6a9a1
		_pkg_names=""; EX_PKG_DISABLED=""; EX_PKG_FINISHED=""; EX_PKG_NAMES="";
Lucio Andrés Illanes Albornoz 60fba6
	if _pkg_names="$(rtl_get_var_unsafe -u "${_group_name}_PACKAGES")"\
Lucio Andrés Illanes Albornoz 60fba6
	&& [ -n "${_pkg_names}" ]; then
Lucio Andrés Illanes Albornoz b6a9a1
		if [ "${_reversefl:-0}" -eq 0 ]; then
Lucio Andrés Illanes Albornoz b6a9a1
			ex_pkg_unfold_depends "${_checkfl}" "${_forcefl}" "${_group_name}" "${_pkg_names}" "${_restart}" 1;
Lucio Andrés Illanes Albornoz 60fba6
		else	ex_pkg_unfold_rdepends "${_group_name}" "${_pkg_names}" "${_restart}" 1;
Lucio Andrés Illanes Albornoz 60fba6
		fi;
Lucio Andrés Illanes Albornoz 60fba6
	fi;
Lucio Andrés Illanes Albornoz 60fba6
	return 0;
Lucio Andrés Illanes Albornoz 60fba6
};
Lucio Andrés Illanes Albornoz 60fba6
Lucio Andrés Illanes Albornoz 60fba6
#
Lucio Andrés Illanes Albornoz c6d6e0
# exp_pkg_dispatch_group() - dispatch a single build group
Lucio Andrés Illanes Albornoz c6d6e0
# @_build_steps_default:	list of default build steps
Lucio Andrés Illanes Albornoz c6d6e0
# @_build_vars_default:		list of default build variables
Lucio Andrés Illanes Albornoz b6a9a1
# @_checkfl:			enable (1) or inhibit (0) dependency expansion
Lucio Andrés Illanes Albornoz c6d6e0
# @_dispatch_fn:		top-level dispatch function name
Lucio Andrés Illanes Albornoz c6d6e0
# @_group_name:			build group name
Lucio Andrés Illanes Albornoz c6d6e0
# @_njobs_max:			maximum count of simultaneous jobs
Lucio Andrés Illanes Albornoz c6d6e0
# @_pipe_path:			pathname to build FIFO
Lucio Andrés Illanes Albornoz c6d6e0
# @_restart_at:			optional comma-separated list of build steps at which to rebuild or ALL
Lucio Andrés Illanes Albornoz c6d6e0
# @_workdir:			pathname to build-specific temporary directory
Lucio Andrés Illanes Albornoz c6d6e0
#
Lucio Andrés Illanes Albornoz 3382d9
# Return:			zero (0) on success, non-zero (>0) on failure, ${EXP_PKG_DISPATCH_COUNT_CUR} may be mutated post-return.
Lucio Andrés Illanes Albornoz c6d6e0
#
Lucio Andrés Illanes Albornoz c6d6e0
exp_pkg_dispatch_group() {
Lucio Andrés Illanes Albornoz 3382d9
	local	_build_steps_default="${1}" _build_vars_default="${2}" _checkfl="${3}"\
Lucio Andrés Illanes Albornoz 3382d9
		_dispatch_fn="${4}" _group_name="${5}" _njobs_max="${6}" _pipe_path="${7}"\
Lucio Andrés Illanes Albornoz 71825c
		_restart_at="${8}" _workdir="${9}" _perc_group=0 _perc_pkg=0 _pipe_msg=""\
Lucio Andrés Illanes Albornoz 71825c
		_pkg_name="" _rc=0;
Lucio Andrés Illanes Albornoz c6d6e0
	rtl_fileop mkfifo "${_pipe_path}";
Lucio Andrés Illanes Albornoz c6d6e0
	while true; do
Lucio Andrés Illanes Albornoz c6d6e0
		while [ "${EXP_PKG_DISPATCH_NJOBS:-0}" -gt 0 ] && read _pipe_msg; do
Lucio Andrés Illanes Albornoz c6d6e0
		case "${_pipe_msg%% *}" in
Lucio Andrés Illanes Albornoz 3382d9
		done)	_pkg_name="${_pipe_msg#done * }"; : $((EXP_PKG_DISPATCH_COUNT_CUR+=1)); : $((EXP_PKG_DISPATCH_NJOBS-=1));
Lucio Andrés Illanes Albornoz 60fba6
			EX_PKG_FINISHED="$(rtl_lconcat "${EX_PKG_FINISHED}" "${_pkg_name}")";
Lucio Andrés Illanes Albornoz 71825c
			_perc_group="$(rtl_percentage "${EXP_PKG_DISPATCH_GROUP_CUR}" "${EXP_PKG_DISPATCH_GROUP_MAX}")";
Lucio Andrés Illanes Albornoz 71825c
			_perc_pkg="$(rtl_percentage "${EXP_PKG_DISPATCH_COUNT_CUR}" "${EXP_PKG_DISPATCH_COUNT_MAX}")";
Lucio Andrés Illanes Albornoz 71825c
			"${_dispatch_fn}" finish_pkg ${_pipe_msg#done } "${EXP_PKG_DISPATCH_COUNT_MAX}" "${_perc_group}" "${_perc_pkg}";
Lucio Andrés Illanes Albornoz 60fba6
			EX_PKG_NAMES="$(rtl_lfilter "${EX_PKG_NAMES}" "${_pkg_name}")";
Lucio Andrés Illanes Albornoz 725770
			EX_PKG_DISPATCH_WAIT="$(rtl_lfilter "${EX_PKG_DISPATCH_WAIT}" "${_pkg_name}")";
Lucio Andrés Illanes Albornoz 60fba6
			if [ -n "${EX_PKG_NAMES}" ] && [ "${_rc}" -eq 0 ]; then
Lucio Andrés Illanes Albornoz c6d6e0
				if [ "${EXP_PKG_DISPATCH_NJOBS}" -ne "${_njobs_max}" ]; then
Lucio Andrés Illanes Albornoz c6d6e0
					exp_pkg_dispatch_packages "${_build_steps_default}"	\
Lucio Andrés Illanes Albornoz b6a9a1
						"${_build_vars_default}" "${_checkfl}"		\
Lucio Andrés Illanes Albornoz b6a9a1
						"${_dispatch_fn}" "${_group_name}"		\
Lucio Andrés Illanes Albornoz b6a9a1
						"${_njobs_max}" "${_pipe_path}"			\
Lucio Andrés Illanes Albornoz b6a9a1
						"${EX_PKG_DISABLED}" "${EX_PKG_FINISHED}"	\
Lucio Andrés Illanes Albornoz b6a9a1
						"${_restart_at}" "${_workdir}";
Lucio Andrés Illanes Albornoz c6d6e0
				fi;
Lucio Andrés Illanes Albornoz c6d6e0
			elif [ "${EXP_PKG_DISPATCH_NJOBS:-0}" -eq 0 ]; then
Lucio Andrés Illanes Albornoz c6d6e0
				break;
Lucio Andrés Illanes Albornoz c6d6e0
			fi; ;;
Lucio Andrés Illanes Albornoz c6d6e0
		fail)	: $((EXP_PKG_DISPATCH_NJOBS-=1)); _rc=1;
Lucio Andrés Illanes Albornoz 9d57f8
			"${_dispatch_fn}" fail_pkg ${_pipe_msg#fail } "${EXP_PKG_DISPATCH_COUNT_MAX}"; ;;
Lucio Andrés Illanes Albornoz 2960a4
		msg_pkg)
Lucio Andrés Illanes Albornoz 2960a4
			"${_dispatch_fn}" msg_pkg ${_pipe_msg#msg_pkg }; ;;
Lucio Andrés Illanes Albornoz c6d6e0
		step)	"${_dispatch_fn}" step_pkg ${_pipe_msg#step }; ;;
Lucio Andrés Illanes Albornoz c6d6e0
		esac; done <>"${_pipe_path}";
Lucio Andrés Illanes Albornoz 60fba6
		if [ -n "${EX_PKG_NAMES}" ] && [ "${_rc}" -eq 0 ]; then
Lucio Andrés Illanes Albornoz c6d6e0
			if [ "${EXP_PKG_DISPATCH_NJOBS}" -ne "${_njobs_max}" ]; then
Lucio Andrés Illanes Albornoz c6d6e0
				exp_pkg_dispatch_packages "${_build_steps_default}"		\
Lucio Andrés Illanes Albornoz b6a9a1
					"${_build_vars_default}" "${_checkfl}"			\
Lucio Andrés Illanes Albornoz b6a9a1
					"${_dispatch_fn}" "${_group_name}"			\
Lucio Andrés Illanes Albornoz b6a9a1
					"${_njobs_max}" "${_pipe_path}"				\
Lucio Andrés Illanes Albornoz 60fba6
					"${EX_PKG_DISABLED}" "${EX_PKG_FINISHED}"		\
Lucio Andrés Illanes Albornoz b6a9a1
					"${_restart_at}" "${_workdir}";
Lucio Andrés Illanes Albornoz e310d7
			fi;
Lucio Andrés Illanes Albornoz c6d6e0
		elif [ "${EXP_PKG_DISPATCH_NJOBS:-0}" -eq 0 ]; then
Lucio Andrés Illanes Albornoz c6d6e0
			break;
Lucio Andrés Illanes Albornoz c6d6e0
		fi;
Lucio Andrés Illanes Albornoz c6d6e0
	done;
Lucio Andrés Illanes Albornoz c6d6e0
	rtl_fileop rm "${_pipe_path}";
Lucio Andrés Illanes Albornoz c6d6e0
	return "${_rc}";
Lucio Andrés Illanes Albornoz 8a04de
};
Lucio Andrés Illanes Albornoz 8a04de
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz 2b85d0
# exp_pkg_dispatch_package() - dispatch single named packages
Lucio Andrés Illanes Albornoz c6d6e0
# @_build_steps_default:	list of default build steps
Lucio Andrés Illanes Albornoz c6d6e0
# @_build_vars_default:		list of default build variables
Lucio Andrés Illanes Albornoz c6d6e0
# @_dispatch_fn:		top-level dispatch function name
Lucio Andrés Illanes Albornoz c6d6e0
# @_group_name:			build group name
Lucio Andrés Illanes Albornoz c6d6e0
# @_pkg_name:			single package name
Lucio Andrés Illanes Albornoz c6d6e0
# @_restart_at:			optional comma-separated list of build steps at which to rebuild or ALL
Lucio Andrés Illanes Albornoz c6d6e0
# @_workdir:			pathname to build-specific temporary directory
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz 60fba6
# 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.
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz 8a04de
exp_pkg_dispatch_package() {
Lucio Andrés Illanes Albornoz 9d57f8
	local	_build_steps_default="${1}" _build_vars_default="${2}" _dispatch_fn="${3}"\
Lucio Andrés Illanes Albornoz 71825c
		_group_name="${4}" _pkg_name="${5}" _restart_at="${6}" _workdir="${7}"\
Lucio Andrés Illanes Albornoz 71825c
		_perc_group=0 _perc_pkg=0;
Lucio Andrés Illanes Albornoz 71825c
	_perc_group="$(rtl_percentage "${EXP_PKG_DISPATCH_GROUP_CUR}" "${EXP_PKG_DISPATCH_GROUP_MAX}")";
Lucio Andrés Illanes Albornoz 71825c
	_perc_pkg="$(rtl_percentage "${EXP_PKG_DISPATCH_COUNT_CUR}" "${EXP_PKG_DISPATCH_COUNT_MAX}")";
Lucio Andrés Illanes Albornoz 71825c
	if "${_dispatch_fn}" start_pkg "${_group_name}" "${_pkg_name}" "$((${EXP_PKG_DISPATCH_COUNT}+1))" "${EXP_PKG_DISPATCH_COUNT_MAX}" "${_perc_group}" "${_perc_pkg}"; then
Lucio Andrés Illanes Albornoz 725770
		: $((EXP_PKG_DISPATCH_NJOBS+=1)); : $((EXP_PKG_DISPATCH_COUNT+=1)); EX_PKG_DISPATCH_WAIT="$(rtl_lconcat "${EX_PKG_DISPATCH_WAIT}" "${_pkg_name}")";
Lucio Andrés Illanes Albornoz 9d57f8
		(trap "if [ \${?} -eq 0 ]; then											\
Lucio Andrés Illanes Albornoz 9d57f8
			printf \"done %s %s %d\n\" \"${_group_name}\" \"${_pkg_name}\" \"${EXP_PKG_DISPATCH_COUNT}\" >&3;	\
Lucio Andrés Illanes Albornoz 9d57f8
		      else													\
Lucio Andrés Illanes Albornoz 9d57f8
			printf \"fail %s %s %d\n\" \"${_group_name}\" \"${_pkg_name}\" \"${EXP_PKG_DISPATCH_COUNT}\" >&3;	\
Lucio Andrés Illanes Albornoz 9d57f8
			pkill -U "${$}";											\
Lucio Andrés Illanes Albornoz b6a9a1
		      fi;" EXIT HUP INT TERM USR1 USR2;
Lucio Andrés Illanes Albornoz e1d469
		set +o errexit -o noglob -o nounset; BUILD_IS_PARENT=0; rtl_log_set_fname ""; rtl_log_set_no_attr 1;
Lucio Andrés Illanes Albornoz bf9edf
		if ex_pkg_env "${_build_steps_default}" "${_build_vars_default}"		\
Lucio Andrés Illanes Albornoz 60fba6
				"${_group_name}" 0 "${_pkg_name}" "${_restart_at}" "${_workdir}"; then
Lucio Andrés Illanes Albornoz 2b85d0
			ex_pkg_exec "${_dispatch_fn}" "${_group_name}" "${_pkg_name}" "${_restart_at}";
Lucio Andrés Illanes Albornoz 2b85d0
		else
Lucio Andrés Illanes Albornoz bf9edf
			return 1;
Lucio Andrés Illanes Albornoz c6d6e0
		fi;) 1>"${_workdir}/${_pkg_name}_stderrout.log" 2>&1 3>"${_pipe_path}" &
Lucio Andrés Illanes Albornoz (arab, vxp) 7a258a
	else
Lucio Andrés Illanes Albornoz bf9edf
		return 1;
Lucio Andrés Illanes Albornoz (arab, vxp) 7a258a
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 7a258a
};
Lucio Andrés Illanes Albornoz (arab, vxp) 7a258a
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz 2b85d0
# exp_pkg_dispatch_packages() - dispatch set of packages
Lucio Andrés Illanes Albornoz c6d6e0
# @_build_steps_default:	list of default build steps
Lucio Andrés Illanes Albornoz c6d6e0
# @_build_vars_default:		list of default build variables
Lucio Andrés Illanes Albornoz b6a9a1
# @_checkfl:			enable (1) or inhibit (0) dependency expansion
Lucio Andrés Illanes Albornoz c6d6e0
# @_dispatch_fn:		top-level dispatch function name
Lucio Andrés Illanes Albornoz c6d6e0
# @_group_name:			build group name
Lucio Andrés Illanes Albornoz c6d6e0
# @_njobs_max:			maximum count of simultaneous jobs
Lucio Andrés Illanes Albornoz c6d6e0
# @_pipe_path:			pathname to parent-child process FIFO
Lucio Andrés Illanes Albornoz 60fba6
# @_pkg_disabled:		list of disabled packages
Lucio Andrés Illanes Albornoz 60fba6
# @_pkg_finished:		list of finished packages
Lucio Andrés Illanes Albornoz c6d6e0
# @_restart_at:			optional comma-separated list of build steps at which to rebuild or ALL
Lucio Andrés Illanes Albornoz c6d6e0
# @_workdir:			pathname to build-specific temporary directory
Lucio Andrés Illanes Albornoz c6d6e0
#
Lucio Andrés Illanes Albornoz 60fba6
# 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.
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz 2b85d0
exp_pkg_dispatch_packages() {
Lucio Andrés Illanes Albornoz 7510de
	local	_build_steps_default="${1}" _build_vars_default="${2}" _checkfl="${3}"\
Lucio Andrés Illanes Albornoz 7510de
		_dispatch_fn="${4}" _group_name="${5}" _njobs_max="${6}" _pipe_path="${7}"\
Lucio Andrés Illanes Albornoz 7510de
		_pkg_disabled="${8}" _pkg_finished="${9}" _restart_at="${10}" _workdir="${11}"\
Lucio Andrés Illanes Albornoz 0d1c4f
		_foundfl=0 _njob=0 _pkg_depends="" _pkg_name="";
Lucio Andrés Illanes Albornoz 0d1c4f
	while [ "${EXP_PKG_DISPATCH_NJOBS:-0}" -lt "${_njobs_max}" ]; do
Lucio Andrés Illanes Albornoz 0d1c4f
		_foundfl=0;
Lucio Andrés Illanes Albornoz 60fba6
		for _pkg_name in ${EX_PKG_NAMES}; do
Lucio Andrés Illanes Albornoz 60fba6
			if ! rtl_lmatch "${_pkg_disabled}" "${_pkg_name}"\
Lucio Andrés Illanes Albornoz 60fba6
			&& ! rtl_lmatch "${_pkg_finished}" "${_pkg_name}"\
Lucio Andrés Illanes Albornoz 725770
			&& ! rtl_lmatch "${EX_PKG_DISPATCH_WAIT}" "${_pkg_name}"\
Lucio Andrés Illanes Albornoz b6a9a1
			&& ex_pkg_check_depends "${_checkfl}" "${_pkg_disabled}" "${_pkg_finished}"	\
Lucio Andrés Illanes Albornoz cc9c32
					"${_pkg_name}" "${EX_PKG_NAMES}"; then
Lucio Andrés Illanes Albornoz c6d6e0
				exp_pkg_dispatch_package "${_build_steps_default}"			\
Lucio Andrés Illanes Albornoz c6d6e0
					"${_build_vars_default}" "${_dispatch_fn}"			\
Lucio Andrés Illanes Albornoz c6d6e0
					"${_group_name}" "${_pkg_name}" "${_restart_at}"		\
Lucio Andrés Illanes Albornoz 0d1c4f
					"${_workdir}"; _foundfl=1; break;
Lucio Andrés Illanes Albornoz 2b85d0
			fi;
Lucio Andrés Illanes Albornoz 2b85d0
		done;
Lucio Andrés Illanes Albornoz 0d1c4f
		if [ "${_foundfl:-0}" -eq 0 ]; then
Lucio Andrés Illanes Albornoz 0d1c4f
			break;
Lucio Andrés Illanes Albornoz 0d1c4f
		fi;
Lucio Andrés Illanes Albornoz 2b85d0
	done;
Lucio Andrés Illanes Albornoz 2b85d0
};
Lucio Andrés Illanes Albornoz 2b85d0
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz c6d6e0
# ex_pkg_dispatch() - dispatch a set of build group
Lucio Andrés Illanes Albornoz c6d6e0
# @_build_steps_default:	list of default build steps
Lucio Andrés Illanes Albornoz c6d6e0
# @_build_vars_default:		list of default build variables
Lucio Andrés Illanes Albornoz c6d6e0
# @_dispatch_fn:		top-level dispatch function name
Lucio Andrés Illanes Albornoz c6d6e0
# @_group_names:		build group name(s)
Lucio Andrés Illanes Albornoz 487c40
# @_groups_inhibit_deps:	inhibit group-group dependency expansion
Lucio Andrés Illanes Albornoz c6d6e0
# @_njobs_max:			maximum count of simultaneous jobs
Lucio Andrés Illanes Albornoz c6d6e0
# @_pipe_path:			pathname to build FIFO
Lucio Andrés Illanes Albornoz 221ee9
# @_restart:			optional whitespace-separated list of package names to rebuild
Lucio Andrés Illanes Albornoz c6d6e0
# @_restart_at:			optional comma-separated list of build steps at which to rebuild or ALL
Lucio Andrés Illanes Albornoz b6a9a1
# @_restart_recursive:		optional flag specifiying either no dependency expansion (0,) dependency expansion (1,) dependency expansion and forcibly rebuild (2,) forcibly rebuild reverse dependencies (3.)
Lucio Andrés Illanes Albornoz c6d6e0
# @_workdir:			pathname to build-specific temporary directory
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz b6a9a1
# Return:			zero (0) on success, non-zero (>0) on failure, ${EX_PKG_DISPATCH_WAIT} mutated post-return.
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz c6d6e0
ex_pkg_dispatch() {
Lucio Andrés Illanes Albornoz c6d6e0
	local	_build_steps_default="${1}" _build_vars_default="${2}" _dispatch_fn="${3}"		\
Lucio Andrés Illanes Albornoz 487c40
		_group_names="${4}" _groups_inhibit_deps="${5}" _njobs_max="${6}" _pipe_path="${7}"	\
Lucio Andrés Illanes Albornoz 487c40
		_restart="${8}" _restart_at="${9}" _restart_recursive="${10}" _workdir="${11}"		\
Lucio Andrés Illanes Albornoz 71825c
		_checkfl=1 _forcefl=0 _perc_group=0 _pkg_name="" _pkg_names="" _rc=0 _reversefl=0	\
Lucio Andrés Illanes Albornoz 60fba6
		EX_PKG_DISABLED EX_PKG_FINISHED EX_PKG_NAMES EXP_PKG_DISPATCH_COUNT			\
Lucio Andrés Illanes Albornoz 71825c
		EXP_PKG_DISPATCH_COUNT_CUR EXP_PKG_DISPATCH_COUNT_MAX EXP_PKG_DISPATCH_GROUP_CUR	\
Lucio Andrés Illanes Albornoz 71825c
		EXP_PKG_DISPATCH_GROUP_MAX EXP_PKG_DISPATCH_NJOBS; EX_PKG_DISPATCH_WAIT="";
Lucio Andrés Illanes Albornoz b6a9a1
	case "${_groups_inhibit_deps:-0}" in
Lucio Andrés Illanes Albornoz b6a9a1
	0)	_group_names="$(rtl_uniq $(rtl_lunfold_depends '${_name}_GROUP_DEPENDS' ${_group_names}))";
Lucio Andrés Illanes Albornoz b6a9a1
	esac;
Lucio Andrés Illanes Albornoz b6a9a1
	if [ -n "${_restart}" ]; then
Lucio Andrés Illanes Albornoz b6a9a1
		case "${_restart_recursive:-0}" in
Lucio Andrés Illanes Albornoz b6a9a1
		0)	_checkfl=0; _forcefl=0; _reversefl=0; ;;
Lucio Andrés Illanes Albornoz b6a9a1
		1)	_checkfl=1; _forcefl=0; _reversefl=0; ;;
Lucio Andrés Illanes Albornoz b6a9a1
		2)	_checkfl=1; _forcefl=1; _reversefl=0; ;;
Lucio Andrés Illanes Albornoz b6a9a1
		3)	_checkfl=1; _forcefl=1; _reversefl=1; ;;
Lucio Andrés Illanes Albornoz b6a9a1
		esac;
Lucio Andrés Illanes Albornoz 487c40
	fi;
Lucio Andrés Illanes Albornoz 71825c
	EXP_PKG_DISPATCH_GROUP_CUR=0; EXP_PKG_DISPATCH_GROUP_MAX="$(rtl_llength "${_group_names}")";
Lucio Andrés Illanes Albornoz 487c40
	for _group_name in ${_group_names}; do
Lucio Andrés Illanes Albornoz 60fba6
		EX_PKG_DISABLED=""; EX_PKG_DISPATCH_WAIT=""; EX_PKG_FINISHED=""; EX_PKG_NAMES="";
Lucio Andrés Illanes Albornoz 3382d9
		EXP_PKG_DISPATCH_COUNT=0; EXP_PKG_DISPATCH_COUNT_CUR=0; EXP_PKG_DISPATCH_COUNT_MAX=0; EXP_PKG_DISPATCH_NJOBS=0;
Lucio Andrés Illanes Albornoz 71825c
		_perc_group="$(rtl_percentage "${EXP_PKG_DISPATCH_GROUP_CUR}" "${EXP_PKG_DISPATCH_GROUP_MAX}")";
Lucio Andrés Illanes Albornoz 71825c
		if "${_dispatch_fn}" start_group "${_group_name}" "" "${EXP_PKG_DISPATCH_GROUP_CUR}" "${EXP_PKG_DISPATCH_GROUP_MAX}" "${_perc_group}"; then
Lucio Andrés Illanes Albornoz c6d6e0
			if rtl_fileop mkdir "${_workdir}"\
Lucio Andrés Illanes Albornoz b6a9a1
			&& rtl_log_msg notice "Resolving \`%s' dependencies..." "${_group_name}"\
Lucio Andrés Illanes Albornoz b6a9a1
			&& exp_pkg_dispatch_expand_packages "${_checkfl}" "${_forcefl}" "${_group_name}" "${_restart}" "${_reversefl}"\
Lucio Andrés Illanes Albornoz 60fba6
			&& exp_pkg_dispatch_complete "${_dispatch_fn}" "${_group_name}" "${EX_PKG_DISABLED}" "${EX_PKG_FINISHED}"\
Lucio Andrés Illanes Albornoz b6a9a1
			&& rtl_log_msg notice "Resolved \`%s' dependencies." "${_group_name}"\
Lucio Andrés Illanes Albornoz 60fba6
			&& EXP_PKG_DISPATCH_COUNT_MAX="$(rtl_llength "${EX_PKG_NAMES}")"\
Lucio Andrés Illanes Albornoz c6d6e0
			&& [ "${EXP_PKG_DISPATCH_COUNT_MAX}" -gt 0 ]; then
Lucio Andrés Illanes Albornoz 60fba6
				_pkg_names="$(rtl_lconcat "${_pkg_names}" "${EX_PKG_NAMES}")";
Lucio Andrés Illanes Albornoz c6d6e0
				exp_pkg_dispatch_group "${_build_steps_default}"			\
Lucio Andrés Illanes Albornoz b6a9a1
					"${_build_vars_default}" "${_checkfl}" "${_dispatch_fn}"	\
Lucio Andrés Illanes Albornoz b6a9a1
					"${_group_name}" "${_njobs_max}" "${_pipe_path}"		\
Lucio Andrés Illanes Albornoz b6a9a1
					"${_restart_at}" "${_workdir}"; _rc="${?}";
Lucio Andrés Illanes Albornoz c6d6e0
			fi;
Lucio Andrés Illanes Albornoz 71825c
			: $((EXP_PKG_DISPATCH_GROUP_CUR+=1));
Lucio Andrés Illanes Albornoz 71825c
			_perc_group="$(rtl_percentage "${EXP_PKG_DISPATCH_GROUP_CUR}" "${EXP_PKG_DISPATCH_GROUP_MAX}")";
Lucio Andrés Illanes Albornoz 71825c
			"${_dispatch_fn}" finish_group "${_group_name}" "" "${EXP_PKG_DISPATCH_GROUP_CUR}" "${EXP_PKG_DISPATCH_GROUP_MAX}" "${_perc_group}";
Lucio Andrés Illanes Albornoz c6d6e0
			if [ "${_rc}" -ne 0 ]; then
Lucio Andrés Illanes Albornoz c6d6e0
				break;
Lucio Andrés Illanes Albornoz c6d6e0
			fi;
Lucio Andrés Illanes Albornoz 2b85d0
		fi;
Lucio Andrés Illanes Albornoz b6a9a1
	done; return "${_rc}";
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
};
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
Lucio Andrés Illanes Albornoz 2b85d0
# vim:filetype=sh textwidth=0