summaryrefslogtreecommitdiffhomepage
path: root/subr.rtl
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2021-05-10 15:26:25 +0100
committerLucio Andrés Illanes Albornoz <lucio@lucioillanes.de>2021-05-10 15:26:25 +0100
commit3e5303fb9ba19addfcb672c1f3aa78d02efb7ebc (patch)
tree448feaab5f16dcf1c450efebde18b0f56c3b0ebf /subr.rtl
parente1a4743914675267e94b3510bea6d8c8c357a32e (diff)
downloadmidipix_build-3e5303fb9ba19addfcb672c1f3aa78d02efb7ebc.tar.bz2
midipix_build-3e5303fb9ba19addfcb672c1f3aa78d02efb7ebc.tar.xz
Implements {fetch,configure,build,install}_clean.
build.sh:buildp_dispatch_fail_pkg(): print NL when writing to ${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}. etc/{README.md,build.usage}: updated. midipix.env: updated. subr.rtl/rtl_complex.subr:rtl_sunset(): initial implementation. subr.rtl/rtl_list.subr:rtl_l{filter[23],length2,lift[23]}(): initial implementation. subr.rtl/rtl_state.subr:rtl_state_test(): take ${_build_steps} vs. ${_build_step}. subr/{build_init,ex_pkg_restart}.subr: splits extended restart syntax processing logic. subr/ex_pkg_exec.subr:ex_pkg_exec(): filter "start". subr/pkg_{build,configure,fetch,install}_clean.subr: initial implementation.
Diffstat (limited to 'subr.rtl')
-rw-r--r--subr.rtl/rtl_complex.subr8
-rw-r--r--subr.rtl/rtl_list.subr42
-rw-r--r--subr.rtl/rtl_state.subr26
3 files changed, 66 insertions, 10 deletions
diff --git a/subr.rtl/rtl_complex.subr b/subr.rtl/rtl_complex.subr
index 8866484f..61637f69 100644
--- a/subr.rtl/rtl_complex.subr
+++ b/subr.rtl/rtl_complex.subr
@@ -72,4 +72,12 @@ rtl_percentage() {
printf "%d\n" "${_perc}";
};
+rtl_sunset() {
+ local _rs_rset="${1#\$}" _rs_kname="" IFS=" ";
+ eval set -- '${'"${_rs_rset}"'}';
+ while [ "${#}" -gt 0 ]; do
+ unset "${_rs_rset}${_rs_kname}"; shift;
+ done; unset "${_rs_rset}";
+};
+
# vim:filetype=sh
diff --git a/subr.rtl/rtl_list.subr b/subr.rtl/rtl_list.subr
index 29abef2e..e24973e9 100644
--- a/subr.rtl/rtl_list.subr
+++ b/subr.rtl/rtl_list.subr
@@ -46,6 +46,31 @@ rtl_lfilter() {
printf "%s" "${_lnew}";
};
+rtl_lfilter2() {
+ local _rlist="${1#\$}" _rlist_new="${2#\$}" _filter="${3}" _sep="${4:- }" IFS="${4:-${IFS:- }}"\
+ _filterfl="" _litem="" _litem_filter="" _lnew="";
+
+ if [ "${_filter:+1}" != 1 ]; then
+ eval ${_rlist_new}=; return 0;
+ else eval set -- '${'"${_rlist}"'}'\; ${_rlist_new}=;
+ while [ "${#}" -gt 0 ]; do
+ _litem="${1}"; shift; _filterfl=0;
+ for _litem_filter in ${_filter}; do
+ if [ "${_litem_filter}" = "${_litem}" ]; then
+ _filterfl=1; break;
+ fi;
+ done;
+ if [ "${_filterfl:-0}" -eq 0 ]; then
+ eval ${_rlist_new}='${'"${_rlist_new}"':+${'"${_rlist_new}"'}${_sep}}${_litem}';
+ fi;
+ done;
+ fi;
+};
+
+rtl_lfilter3() {
+ rtl_lfilter2 "${1}" "${1}" "${2}" "${3:-}";
+};
+
rtl_lfirst() {
local _list="${1}" _sep="${2}" IFS; IFS="${_sep}";
set -- ${_list}; RTL_LFIRST_HEAD="${1}";
@@ -64,12 +89,29 @@ rtl_llength() {
printf "%s" "${_llength}";
};
+rtl_llength2() {
+ local _rlist="${1#\$}" _rlen="${2#\$}" _sep="${3:- }" IFS="${3:-${IFS:- }}";
+ eval set -- '${'"${_rlist}"'}'\; ${_rlen}='${#}';
+};
+
rtl_llift() {
local _list="${1}" _sep="${2}" _sep_new="${3}" IFS; IFS="${_sep}";
set -- ${_list}; IFS="${_sep_new}";
printf "%s" "${*}";
};
+rtl_llift2() {
+ local _rlist="${1#\$}" _rlist_new="${2#\$}" _sep="${3}" \
+ _sep_new="${4}" IFS; IFS="${_sep}";
+
+ eval set -- '${'"${_rlist}"'}'; IFS="${_sep_new}";
+ eval ${_rlist_new}='"${*}"';
+};
+
+rtl_llift3() {
+ rtl_llift2 "${1}" "${1}" "${2}" "${3}";
+};
+
rtl_lmatch() {
local _list="${1}" _item="${2}" _sep="${3:- }";
[ -n "$(rtl_lsearch "${_list}" "${_item}" "${_sep}")" ];
diff --git a/subr.rtl/rtl_state.subr b/subr.rtl/rtl_state.subr
index 203ec520..da091e9c 100644
--- a/subr.rtl/rtl_state.subr
+++ b/subr.rtl/rtl_state.subr
@@ -23,16 +23,22 @@ rtl_state_set() {
};
rtl_state_test() {
- local _workdir="${1}" _pkg_name="${2}" _build_step="${3}" _restart_at="${4:-}" _done_fname="";
- _done_fname="${_workdir}/.${_pkg_name}.${_build_step}";
- if [ -z "${_restart_at}" ]\
- || [ "${_restart_at}" = "LAST" ]; then
- rtl_fileop test "${_done_fname}";
- elif [ "${_restart_at}" = "ALL" ]; then
- return 1;
- else
- ! rtl_lmatch "${_restart_at}" "${_build_step}" ",";
- fi;
+ local _workdir="${1}" _pkg_name="${2}" _build_steps="${3}" \
+ _restart_at="${4:-}" _build_step="" _done_fname="" \
+ IFS="," _rc=0;
+
+ for _build_step in ${_build_steps}; do
+ _done_fname="${_workdir}/.${_pkg_name}.${_build_step}";
+ if [ "${_restart_at:+1}" != 1 ]\
+ || [ "${_restart_at}" = "LAST" ]; then
+ rtl_fileop test "${_done_fname}"; _rc="${?}";
+ elif [ "${_restart_at}" = "ALL" ]; then
+ _rc=1;
+ else
+ rtl_lmatch "${_restart_at}" "${_build_step}" ",";
+ _rc=$((${?} ? 0 : 1));
+ fi; [ "${_rc}" -eq 0 ] && break;
+ done; return "${_rc}";
};
# vim:filetype=sh