Conan_Kudo / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame subr/ex_pkg_exec.subr

Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
#
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
# set -o errexit -o noglob are assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
#
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
exp_pkg_exec_pre() {
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	local _pkg_name="${1}" _tgt_name="${2}" _restart_at="${3}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	if [ -z "${PKG_URL}" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	&& [ -z "${PKG_URLS_GIT}" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	&& [ -z "${PKG_VERSION}" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	&& ! ex_rtl_test_cmd "pkg_${_pkg_name}_all"; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		"${_dispatch_fn}" exec_missing "${_pkg_name}" "${_tgt_name}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		return 1;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	elif ! ex_pkg_state_test "${_pkg_name}" "start" "${_restart_at}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		if [ "${PKG_NO_CLEAN_BASE_DIR:-0}" -eq 0 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			ex_rtl_fileop rm "${PKG_BASE_DIR}" "${PKG_BUILD_DIR}" "${PKG_DESTDIR}";
Lucio Andrés Illanes Albornoz (arab, vxp) 9ca572
			ex_rtl_fileop mkdir "${PKG_BASE_DIR}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 9ca572
		ex_rtl_fileop mkdir "${PKG_BUILD_DIR}" "${PKG_DESTDIR}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		ex_pkg_state_set "${_pkg_name}" "start";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	ex_rtl_fileop cd "${PKG_BUILD_DIR}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
};
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
ex_pkg_exec() {
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	local _pkg_name="${1}" _tgt_name="${2}" _restart_at="${3}"			\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		_step _step_cmd _step_cmd_pfx _step_rc;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	exp_pkg_exec_pre "${_pkg_name}" "${_tgt_name}" "${_restart_at}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	"${_dispatch_fn}" exec_start "${_pkg_name}" "${_tgt_name}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	if ex_rtl_test_cmd "pkg_${_pkg_name}_all"; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		"pkg_${_pkg_name}_all" "${_restart_at}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	else	set -- ${PKG_BUILD_STEPS};
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			_step="${1}"; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			if ex_pkg_state_test "${_pkg_name}" "${_step}"			\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
					"${_restart_at}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
				continue;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			else	ex_rtl_try_run						\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
					"pkg_${_pkg_name}_${_step}_pre"			\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
					"${_pkg_name}" "${_tgt_name}" "${_restart_at}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
				if ex_rtl_test_cmd "pkg_${_pkg_name}_${_step}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
					ex_rtl_try_run "pkg_${_pkg_name}_${_step}"	\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
						"${_pkg_name}" "${_tgt_name}" "${_restart_at}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
				else	
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
					ex_rtl_try_run "pkg_${_step}"			\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
						"${_pkg_name}" "${_tgt_name}" "${_restart_at}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
				fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
				ex_rtl_try_run						\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
					"pkg_${_pkg_name}_${_step}_post"		\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
					"${_pkg_name}" "${_tgt_name}" "${_restart_at}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			echo "step ${_pkg_name} ${_tgt_name} ${_step}" >&3;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			"${_dispatch_fn}" exec_step "${_pkg_name}" "${_tgt_name}" "${_step}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			ex_pkg_state_set "${_pkg_name}" "${_step}" "${1:+-${1}}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		done;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		"${_dispatch_fn}" exec_finish "${_pkg_name}" "${_tgt_name}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		ex_pkg_state_set "${_pkg_name}" finish;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
};
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
# vim:filetype=sh