Blame subr/pkg_setup_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) 1da591
pkg_setup_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) 1da591
		_pkg_name_parent _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) 1da591
		_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) 1da591
	if [ -n "${_restart}" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
	|| [ "${_tgt_name}" = "INVARIANTS" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
	|| ! is_build_script_done "${_pkg_name}" finish; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
		set -- $(lfilter -not "${BUILD_STEPS}"	\
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
				"$(get_var_unsafe PKG_$(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) 1da591
					|| 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
				elif ! is_build_script_done "${_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) 1da591
				if 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) 1da591
				if 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) 1da591
			*)	continue; ;;
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) 1da591
				if test_cmd "${__}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
					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) 1da591
					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) 1da591
					if [ "${1#*:}" != "always" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
					&& [ ${#} -ge 2 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
						set_build_script_done "${_pkg_name}" "${1%:*}" "-${2#*:}";
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
					else
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
						set_build_script_done "${_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