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) 61ba13
	local _tgt_name="${1}" _pkg_name="${2}"			\
Lucio Andrés Illanes Albornoz (arab, vxp) 61ba13
		_restart="${3}" _restart_at="${4}"		\
Lucio Andrés Illanes Albornoz (arab, vxp) 61ba13
		_stdout_path _stderr_path			\
Lucio Andrés Illanes Albornoz 2d7199
		_pipe_path _pipe_msg _script_rc=1;
Lucio Andrés Illanes Albornoz (arab, vxp) 61ba13
	if ex_pkg_state_test "${_pkg_name}" finish		\
Lucio Andrés Illanes Albornoz (arab, vxp) 61ba13
	&& [ -z "${_restart}" ]					\
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
	&& [ "${_tgt_name}" != "INVARIANTS" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		return 0;
Lucio Andrés Illanes Albornoz (arab, vxp) fc9417
	else
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		_pipe_path="${WORKDIR}/${_pkg_name}_build.fifo";
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		ex_build_fileop rm "${_pipe_path}"; mkfifo "${_pipe_path}";
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		_stderr_path="${WORKDIR}/${_pkg_name}_stderr.log";
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		_stdout_path="${WORKDIR}/${_pkg_name}_stdout.log";
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		ex_build_fileop rm "${_stderr_path}" "${_stdout_path}";
Lucio Andrés Illanes Albornoz (arab, vxp) fc9417
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
	(set -o errexit -o noglob;
Lucio Andrés Illanes Albornoz 2d7199
	trap "if [ \${?} -eq 0 ]; then				\
Lucio Andrés Illanes Albornoz 2d7199
		echo \"done ${PKG_NAME}\" >&3;			\
Lucio Andrés Illanes Albornoz 2d7199
	      else						\
Lucio Andrés Illanes Albornoz 2d7199
		echo \"fail ${PKG_NAME}\" >&3;			\
Lucio Andrés Illanes Albornoz 2d7199
	      fi;" EXIT HUP INT TERM USR1 USR2;
Lucio Andrés Illanes Albornoz (arab, vxp) 4b2ce1
	if [ "${ARG_XTRACE:-0}" -eq 1 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 4b2ce1
		set -o xtrace;
Lucio Andrés Illanes Albornoz (arab, vxp) 4b2ce1
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 61ba13
	ex_pkg_vars;
Lucio Andrés Illanes Albornoz (arab, vxp) 61ba13
	if [ "${PKG_DISABLED:-0}" -eq 1 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 61ba13
		ex_log_msg vnfo "Skipping disabled package \`${PKG_NAME}.'";
Lucio Andrés Illanes Albornoz (arab, vxp) 61ba13
	else
Lucio Andrés Illanes Albornoz (arab, vxp) 61ba13
		ex_pkg_env;
Lucio Andrés Illanes Albornoz (arab, vxp) 61ba13
		ex_pkg_steps "${_tgt_name}" "${_pkg_name}"	\
Lucio Andrés Illanes Albornoz (arab, vxp) 61ba13
			"${_restart}" "${_restart_at}";
Lucio Andrés Illanes Albornoz 2d7199
	fi;)	1>"${_stdout_path}" 2>"${_stderr_path}"		\
Lucio Andrés Illanes Albornoz 2d7199
		3>"${_pipe_path}" &
Lucio Andrés Illanes Albornoz 2d7199
	while read _pipe_msg; do
Lucio Andrés Illanes Albornoz (arab, vxp) fc9417
	case "${_pipe_msg%% *}" in
Lucio Andrés Illanes Albornoz 2d7199
	done)	_script_rc=0; break; ;;
Lucio Andrés Illanes Albornoz 2d7199
	fail)	_script_rc=1; break; ;;
Lucio Andrés Illanes Albornoz 2d7199
	*)	_script_rc=1; break; ;;
Lucio Andrés Illanes Albornoz 2d7199
	esac; done <"${_pipe_path}";
Lucio Andrés Illanes Albornoz 2d7199
	ex_build_fileop rm "${_pipe_path}";
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
	return "${_script_rc:-1}";
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