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 b96c60
	local _group_name="${1}" _pkg_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 b96c60
		"${_dispatch_fn}" exec_missing "${_group_name}" "${_pkg_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 b96c60
	local _group_name="${1}" _pkg_name="${2}" _restart_at="${3}"			\
Lucio Andrés Illanes Albornoz 907bd3
		_step="" _step_cmd="" _step_cmd_pfx="" _step_rc="";
Lucio Andrés Illanes Albornoz (arab, vxp) 30ae14
	trap "if [ \${?} -eq 0 ]; then							\
Lucio Andrés Illanes Albornoz b96c60
		echo \"done ${_group_name} ${_pkg_name}\" >&3;				\
Lucio Andrés Illanes Albornoz (arab, vxp) 30ae14
	      else									\
Lucio Andrés Illanes Albornoz b96c60
		echo \"fail ${_group_name} ${_pkg_name}\" >&3;				\
Lucio Andrés Illanes Albornoz (arab, vxp) 30ae14
		pkill -U "${$}";							\
Lucio Andrés Illanes Albornoz (arab, vxp) 30ae14
	      fi;" EXIT HUP INT TERM USR1 USR2;
Lucio Andrés Illanes Albornoz b96c60
	exp_pkg_exec_pre "${_group_name}" "${_pkg_name}" "${_restart_at}";
Lucio Andrés Illanes Albornoz b96c60
	"${_dispatch_fn}" exec_start "${_group_name}" "${_pkg_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 b96c60
					"${_group_name}" "${_pkg_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 b96c60
						"${_group_name}" "${_pkg_name}" "${_restart_at}";
Lucio Andrés Illanes Albornoz (arab, vxp) fce0a9
				else
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
					ex_rtl_try_run "pkg_${_step}"			\
Lucio Andrés Illanes Albornoz b96c60
						"${_group_name}" "${_pkg_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 b96c60
					"${_group_name}" "${_pkg_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 b96c60
			echo "step ${_group_name} ${_pkg_name} ${_step}" >&3;
Lucio Andrés Illanes Albornoz b96c60
			"${_dispatch_fn}" exec_step "${_group_name}" "${_pkg_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
	fi;
Lucio Andrés Illanes Albornoz b96c60
	"${_dispatch_fn}" exec_finish "${_group_name}" "${_pkg_name}";
Lucio Andrés Illanes Albornoz (arab, vxp) 4b9285
	ex_pkg_state_set "${_pkg_name}" finish;
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