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() {
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 907bd3
	local _workdir="${1}" _pkg_fname="${2}" _done_fname_pfx="";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	_done_fname_pfx="${_workdir}/.${_pkg_fname}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	shift 2; while [ ${#} -ge 1 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		if [ -z "${1}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			shift; continue;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		elif [ "${1#-}" != "${1}" ]; then
Lucio Andrés Illanes Albornoz c6d6e0
			rtl_fileop rm "${_done_fname_pfx}.${1#-}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		else
Lucio Andrés Illanes Albornoz c6d6e0
			rtl_fileop touch "${_done_fname_pfx}.${1}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	shift; 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 e1d469
	local _workdir="${1}" _pkg_name="${2}" _build_step="${3}" _restart_at="${4:-}" _done_fname="";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	_done_fname="${_workdir}/.${_pkg_name}.${_build_step}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	if [ -z "${_restart_at}" ]; then
Lucio Andrés Illanes Albornoz c6d6e0
		rtl_fileop test "${_done_fname}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	elif [ "${_restart_at}" = "ALL" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		return 1;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	else
Lucio Andrés Illanes Albornoz c6d6e0
		! rtl_lmatch "${_restart_at}" "${_build_step}" ",";
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