Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
#
Lucio Andrés Illanes Albornoz e1d469
# set +o errexit -o noglob -o nounset is assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
#
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
Lucio Andrés Illanes Albornoz c6d6e0
rtl_state_clear() {
Lucio Andrés Illanes Albornoz da0364
	local _workdir="${1}" _pkg_name="${2}" _pkg_fname="";
Lucio Andrés Illanes Albornoz da0364
	for _pkg_fname in $(find "${_workdir}"				\
Lucio Andrés Illanes Albornoz da0364
			-maxdepth 1 -mindepth 1 -name .${_pkg_name}.\* -type f); do
Lucio Andrés Illanes Albornoz c6d6e0
		rtl_fileop rm "${_pkg_fname}";
Lucio Andrés Illanes Albornoz da0364
	done;
Lucio Andrés Illanes Albornoz da0364
};
Lucio Andrés Illanes Albornoz da0364
Lucio Andrés Illanes Albornoz c6d6e0
rtl_state_set() {
Lucio Andrés Illanes Albornoz 370e98
	local	_workdir="${1}" _pkg_fname="${2}" _build_step="${3}"	\
Lucio Andrés Illanes Albornoz 370e98
		_done_fname_pfx="${1}/.${2}"; shift 3;
Lucio Andrés Illanes Albornoz 370e98
Lucio Andrés Illanes Albornoz 370e98
	rtl_fileop touch "${_done_fname_pfx}.${_build_step}";
Lucio Andrés Illanes Albornoz 370e98
	while [ ${#} -ge 1 ]; do
Lucio Andrés Illanes Albornoz 370e98
		if [ "${#1}" -gt 0 ]; then
Lucio Andrés Illanes Albornoz 370e98
			rtl_fileop rm "${_done_fname_pfx}.${1}";
Lucio Andrés Illanes Albornoz 370e98
		fi; shift;
Lucio Andrés Illanes Albornoz 370e98
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
};
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
Lucio Andrés Illanes Albornoz c6d6e0
rtl_state_test() {
Lucio Andrés Illanes Albornoz 3e5303
	local	_workdir="${1}" _pkg_name="${2}" _build_steps="${3}"	\
Lucio Andrés Illanes Albornoz 3e5303
		_restart_at="${4:-}" _build_step="" _done_fname=""	\
Lucio Andrés Illanes Albornoz 3e5303
		IFS="," _rc=0;
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
	for _build_step in ${_build_steps}; do
Lucio Andrés Illanes Albornoz 3e5303
		_done_fname="${_workdir}/.${_pkg_name}.${_build_step}";
Lucio Andrés Illanes Albornoz 3e5303
		if [ "${_restart_at:+1}" != 1 ]\
Lucio Andrés Illanes Albornoz 3e5303
		|| [ "${_restart_at}" = "LAST" ]; then
Lucio Andrés Illanes Albornoz 3e5303
			rtl_fileop test "${_done_fname}"; _rc="${?}";
Lucio Andrés Illanes Albornoz 3e5303
		elif [ "${_restart_at}" = "ALL" ]; then
Lucio Andrés Illanes Albornoz 3e5303
			_rc=1;
Lucio Andrés Illanes Albornoz 3e5303
		else
Lucio Andrés Illanes Albornoz 3e5303
			rtl_lmatch "${_restart_at}" "${_build_step}" ",";
Lucio Andrés Illanes Albornoz 3e5303
			_rc=$((${?} ? 0 : 1));
Lucio Andrés Illanes Albornoz 3e5303
		fi; [ "${_rc}" -eq 0 ] && break;
Lucio Andrés Illanes Albornoz 3e5303
	done; return "${_rc}";
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