#
# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 LucĂa Andrea Illanes Albornoz <lucia@luciaillanes.de>
# set +o errexit -o noglob -o nounset is assumed.
#
rtl_state_clear() {
local _rsc_workdir="${1}" _rsc_pkg_name="${2}" \
_rsc_pkg_fname="";
for _rsc_pkg_fname in $(
find "${_rsc_workdir}" \
-maxdepth 1 \
-mindepth 1 \
-name .${_rsc_pkg_name}.\* \
-type f);
do
rtl_fileop rm "${_rsc_pkg_fname}";
done;
return 0;
};
rtl_state_set() {
local _rss_workdir="${1}" _rss_pkg_fname="${2}" _rss_build_step="${3}" \
_rss_done_fname_pfx="${1}/.${2}";
shift 3;
rtl_fileop touch "${_rss_done_fname_pfx}.${_rss_build_step}";
while [ ${#} -ge 1 ]; do
if [ "${#1}" -gt 0 ]; then
rtl_fileop rm "${_rss_done_fname_pfx}.${1}";
fi; shift;
done;
return 0;
};
rtl_state_test() {
local _rst_workdir="${1}" _rst_pkg_name="${2}" _rst_build_steps="${3}" \
_rst_restart_at="${4:-}" _rst_build_step="" _rst_done_fname="" \
IFS="," _rst_rc=0;
for _rst_build_step in ${_rst_build_steps}; do
_rst_done_fname="${_rst_workdir}/.${_rst_pkg_name}.${_rst_build_step}";
if [ "${_rst_restart_at:+1}" != 1 ]\
|| [ "${_rst_restart_at}" = "LAST" ]; then
rtl_fileop test "${_rst_done_fname}"; _rst_rc="${?}";
elif [ "${_rst_restart_at}" = "ALL" ]; then
_rst_rc=1;
else
rtl_lmatch \$_rst_restart_at "${_rst_build_step}" ",";
_rst_rc=$((${?} ? 0 : 1));
fi; [ "${_rst_rc}" -eq 0 ] && break;
done;
return "${_rst_rc}";
};
# vim:filetype=sh textwidth=0