Blame subr.rtl/rtl_state.subr

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() {
e9fa07
	local	_rsc_workdir="${1}" _rsc_pkg_name="${2}"	\
e9fa07
		_rsc_pkg_fname="";
e9fa07
e9fa07
	for _rsc_pkg_fname in $(
e9fa07
		find "${_rsc_workdir}"			\
e9fa07
			-maxdepth 1			\
e9fa07
			-mindepth 1			\
e9fa07
			-name .${_rsc_pkg_name}.\*	\
e9fa07
			-type f);
e9fa07
	do
e9fa07
		rtl_fileop rm "${_rsc_pkg_fname}";
Lucio Andrés Illanes Albornoz da0364
	done;
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz da0364
};
Lucio Andrés Illanes Albornoz da0364
Lucio Andrés Illanes Albornoz c6d6e0
rtl_state_set() {
e9fa07
	local	_rss_workdir="${1}" _rss_pkg_fname="${2}" _rss_build_step="${3}"	\
e9fa07
		_rss_done_fname_pfx="${1}/.${2}";
e9fa07
	shift 3;
Lucio Andrés Illanes Albornoz 370e98
e9fa07
	rtl_fileop touch "${_rss_done_fname_pfx}.${_rss_build_step}";
Lucio Andrés Illanes Albornoz 370e98
	while [ ${#} -ge 1 ]; do
Lucio Andrés Illanes Albornoz 370e98
		if [ "${#1}" -gt 0 ]; then
e9fa07
			rtl_fileop rm "${_rss_done_fname_pfx}.${1}";
Lucio Andrés Illanes Albornoz 370e98
		fi; shift;
Lucio Andrés Illanes Albornoz 370e98
	done;
e9fa07
	return 0;
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() {
e9fa07
	local	_rst_workdir="${1}" _rst_pkg_name="${2}" _rst_build_steps="${3}"	\
e9fa07
		_rst_restart_at="${4:-}" _rst_build_step="" _rst_done_fname=""		\
e9fa07
		IFS="," _rst_rc=0;
Lucio Andrés Illanes Albornoz 3e5303
e9fa07
	for _rst_build_step in ${_rst_build_steps}; do
e9fa07
		_rst_done_fname="${_rst_workdir}/.${_rst_pkg_name}.${_rst_build_step}";
e9fa07
		if [ "${_rst_restart_at:+1}" != 1 ]\
e9fa07
		|| [ "${_rst_restart_at}" = "LAST" ]; then
e9fa07
			rtl_fileop test "${_rst_done_fname}"; _rst_rc="${?}";
e9fa07
		elif [ "${_rst_restart_at}" = "ALL" ]; then
e9fa07
			_rst_rc=1;
Lucio Andrés Illanes Albornoz 3e5303
		else
e9fa07
			rtl_lmatch \$_rst_restart_at "${_rst_build_step}" ",";
e9fa07
			_rst_rc=$((${?} ? 0 : 1));
e9fa07
		fi; [ "${_rst_rc}" -eq 0 ] && break;
e9fa07
	done;
e9fa07
	return "${_rst_rc}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
};
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
64844b
# vim:filetype=sh textwidth=0