Conan_Kudo / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame subr/ex_pkg_steps.subr

Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
#
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
# set -o errexit -o noglob are assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
#
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
ex_pkg_steps() {
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
	local _tgt_name="${1}" _pkg_name="${2}"				\
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		_restart="${3}" _restart_at="${4}"			\
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		_step _step_type					\
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		_step_cmds _step_cmd_args				\
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		_step_cmd_pfx _step_cmd _step_next;
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
	set -- $(ex_lfilter -not "${BUILD_STEPS}" "${PKG_BUILD_STEPS_DISABLE}");
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
	while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		_step="${1}"; _step_next="${2}";
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		_step_cmds=""; _step_cmd_args="";
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		_step_type="${_step#*:}";
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		_step="${_step%%:*}";
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		_step_cmd_pfx="pkg_${_pkg_name}_${_step}";
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		case "${_step_type}" in
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		dynamic)
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
			if [ "${_tgt_name}" = "INVARIANTS" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
				_step_cmds="${_step_cmd_pfx} pkg_${_step}";
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
			elif [ -n "${_restart}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
				if [ -z "${_restart_at}" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
				|| ex_lmatch "${_restart_at}" , "${_step}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
					_step_cmds="${_step_cmd_pfx} pkg_${_step}";
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
				fi;
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
			elif ! ex_pkg_state_test "${_pkg_name}" "${_step}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
				_step_cmds="${_step_cmd_pfx} pkg_${_step}";
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
			fi; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		invariant)
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
			_step_cmds="pkg_${_step}"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		variant)
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
			if ex_lmatch "${_restart_at}" "," "${_step}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
				_step_cmds="${_step_cmd_pfx} pkg_${_step}";
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
			fi; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		virtual)
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
			_step_cmds="pkg_${_pkg_name}_${_step}";
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
			_step_cmd_args="${_restart_at:-ALL}"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		all)
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
			if ex_test_cmd "pkg_${_pkg_name}_${_step}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
				"${_step_cmd_pfx}" "${_restart_at:-ALL}";
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
				break;
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
			fi; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		finish)	ex_pkg_state_push "${_pkg_name}" finish; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		*)	;;
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		esac;
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		for _step_cmd in ${_step_cmds}; do
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
			if ex_test_cmd "${_step_cmd}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
				ex_test_cmd "${_step_cmd_pfx}_pre"	\
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
					&& "${_step_cmd_pfx}_pre"
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
				"${_step_cmd}" ${_step_cmd_args};
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
				ex_test_cmd "${_step_cmd_pfx}_post"	\
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
					&& "${_step_cmd_pfx}_post"
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
				if [ "${_step_type}" != "invariant" ]	\
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
				&& [ -n "${_step_next}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
					ex_pkg_state_push "${_pkg_name}" "${_step}";
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
					ex_pkg_state_push "${_pkg_name}" "-${_step_next}";
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
				else
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
					ex_pkg_state_push "${_pkg_name}" "${_step}";
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
				fi; break;
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
			fi;
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		done;
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
	shift; done;
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
};
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
# vim:filetype=sh