Conan_Kudo / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

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) fc24fa
	if ex_pkg_state_test "${_pkg_name}" finish; then
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
		if [ -z "${_restart}" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
		&& [ "${_tgt_name}" != "INVARIANTS" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
			return 0;
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
	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) fc24fa
	set -- $(ex_lfilter -not "${BUILD_STEPS}"	\
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
			"$(ex_get_var_unsafe PKG_$(ex_toupper "${_pkg_name}")_BUILD_STEPS_DISABLE)");
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
	while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
		_pkg_step_cmds=""; _pkg_step_cmd_args="";
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
		case "${1#*:}" in
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
		dynamic)
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
			if [ "${_tgt_name}" = "INVARIANTS" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
				_pkg_step_cmds="pkg_${_pkg_name}_${1%:*} pkg_${1%:*}";
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
			elif [ -n "${_restart}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
				if [ -z "${_restart_at}" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
				|| 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) fc24fa
			elif ! ex_pkg_state_test "${_pkg_name}" "${1%:*}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
				_pkg_step_cmds="pkg_${_pkg_name}_${1%:*} pkg_${1%:*}";
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
			fi; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
		invariant)
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
			_pkg_step_cmds="pkg_${1%:*}"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
		variant)
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
			if ex_lmatch "${_restart_at}" "," "${1%:*}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
				_pkg_step_cmds="pkg_${_pkg_name}_${1%:*} pkg_${1%:*}";
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
			fi; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
		virtual)
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
			_pkg_step_cmds="pkg_${_pkg_name}_${1%:*}";
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
			_pkg_step_cmd_args="${_restart_at:-ALL}"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
		all)
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
			if ex_test_cmd "pkg_${_pkg_name}_${1%:*}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
				"pkg_${_pkg_name}_${1%:*}" "${_restart_at:-ALL}";
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
				break;
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
			fi; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
		finish)	ex_pkg_state_push "${_pkg_name}" finish; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
		*)	;;
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
		esac;
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
		for __ in ${_pkg_step_cmds}; do
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
			if ex_test_cmd "${__}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
				ex_test_cmd "pkg_${_pkg_name}_${1%:*}_pre"	\
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
					&& "pkg_${_pkg_name}_${1%:*}_pre"
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
				"${__}" ${_pkg_step_cmd_args};
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
				ex_test_cmd "pkg_${_pkg_name}_${1%:*}_post"	\
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
					&& "pkg_${_pkg_name}_${1%:*}_post"
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
				if [ "${1#*:}" != "invariant" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
				&& [ ${#} -ge 2 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
					ex_pkg_state_push "${_pkg_name}" "${1%:*}" "-${2#*:}";
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
				else
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
					ex_pkg_state_push "${_pkg_name}" "${1%:*}";
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
				fi; break;
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
			fi;
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
		done;
Lucio Andrés Illanes Albornoz (arab, vxp) fc24fa
	shift; done); 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