Blame subr/ex_pkg_dispatch.subr

Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
#
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
# set -o errexit -o noglob are assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
#
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
ex_pkg_dispatch() {
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
	local _tgt_name="${1}" _pkg_name="${2}"		\
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
		_restart="${3}" _restart_at="${4}"	\
Lucio Andrés Illanes Albornoz (arab, vxp) d7620f
		_pkg_step_cmds _pkg_step_cmd_args;
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
	if [ "${_pkg_name#*_flavour_*}" != "${_pkg_name}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) d7620f
		PKG_NAME_PARENT="${_pkg_name%_flavour_*}";
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
	(set -o errexit -o noglob;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	ex_pkg_vars; ex_pkg_env;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	ex_build_fileop mkdir "${PKG_BASE_DIR}";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	ex_build_fileop cd "${PKG_BASE_DIR}";
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
	if [ -n "${_restart}" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
	|| [ "${_tgt_name}" = "INVARIANTS" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	|| ! ex_pkg_state_test "${_pkg_name}" finish; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		set -- $(ex_lfilter -not "${BUILD_STEPS}"	\
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
				"$(ex_get_var_unsafe PKG_$(ex_toupper "${_pkg_name}")_BUILD_STEPS_DISABLE)");
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
		while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
			_pkg_step_cmds=""; _pkg_step_cmd_args="";
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
			case "${1#*:}" in
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
			dynamic)
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
				if [ "${_tgt_name}" = "INVARIANTS" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
					_pkg_step_cmds="pkg_${_pkg_name}_${1%:*} pkg_${1%:*}";
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
				elif [ -n "${_restart}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
					if [ -z "${_restart_at}" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
					|| ex_lmatch "${_restart_at}" , "${1%:*}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
						_pkg_step_cmds="pkg_${_pkg_name}_${1%:*} pkg_${1%:*}";
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
					fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
				elif ! ex_pkg_state_test "${_pkg_name}" "${1%:*}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
					_pkg_step_cmds="pkg_${_pkg_name}_${1%:*} pkg_${1%:*}";
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
				fi; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
			invariant)
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
				_pkg_step_cmds="pkg_${1%:*}"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
			variant)
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
				if ex_lmatch "${_restart_at}" "," "${1%:*}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
					_pkg_step_cmds="pkg_${_pkg_name}_${1%:*} pkg_${1%:*}";
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
				fi; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
			virtual)
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
				_pkg_step_cmds="pkg_${_pkg_name}_${1%:*}";
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
				_pkg_step_cmd_args="${_restart_at:-ALL}"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
			all)
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
				if ex_test_cmd "pkg_${_pkg_name}_${1%:*}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
					"pkg_${_pkg_name}_${1%:*}" "${_restart_at:-ALL}";
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
					break;
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
				fi; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
			finish)	ex_pkg_state_push "${_pkg_name}" finish; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
			*)	;;
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
			esac;
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
			for __ in ${_pkg_step_cmds}; do
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
				if ex_test_cmd "${__}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
					ex_test_cmd "pkg_${_pkg_name}_${1%:*}_pre"	\
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
						&& "pkg_${_pkg_name}_${1%:*}_pre"
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
					"${__}" ${_pkg_step_cmd_args};
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
					ex_test_cmd "pkg_${_pkg_name}_${1%:*}_post"	\
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
						&& "pkg_${_pkg_name}_${1%:*}_post"
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
					if [ "${1#*:}" != "invariant" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
					&& [ ${#} -ge 2 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
						ex_pkg_state_push "${_pkg_name}" "${1%:*}" "-${2#*:}";
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
					else
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
						ex_pkg_state_push "${_pkg_name}" "${1%:*}";
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
					fi; break;
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
				fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
			done;
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
		shift; done;
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
	fi); return ${?};
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
};
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
# vim:filetype=sh