diff options
author | Lucio Andrés Illanes Albornoz (arab, vxp) <lucio@lucioillanes.de> | 2017-11-22 18:31:27 +0000 |
---|---|---|
committer | Lucio Andrés Illanes Albornoz (arab, vxp) <lucio@lucioillanes.de> | 2017-11-22 18:38:54 +0000 |
commit | d18b1a13558fd4c78372fe610e7f6391f9eae874 (patch) | |
tree | b1525c7ea9060ae50f6ef3aafcfe398bf2dd7083 /subr/ex_pkg_steps.subr | |
parent | fc9417f077a909539495531229f9035c15fe10f0 (diff) | |
download | midipix_build-d18b1a13558fd4c78372fe610e7f6391f9eae874.tar.bz2 midipix_build-d18b1a13558fd4c78372fe610e7f6391f9eae874.tar.xz |
subr/ex_pkg_{dispatch,steps}.subr: split.
subr/ex_pkg_{env,vars}.subr: moved checks.
Diffstat (limited to 'subr/ex_pkg_steps.subr')
-rw-r--r-- | subr/ex_pkg_steps.subr | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/subr/ex_pkg_steps.subr b/subr/ex_pkg_steps.subr new file mode 100644 index 00000000..da2ce6b6 --- /dev/null +++ b/subr/ex_pkg_steps.subr @@ -0,0 +1,66 @@ +# +# set -o errexit -o noglob are assumed. +# + +ex_pkg_steps() { + local _tgt_name="${1}" _pkg_name="${2}" \ + _restart="${3}" _restart_at="${4}" \ + _step _step_type \ + _step_cmds _step_cmd_args \ + _step_cmd_pfx _step_cmd _step_next; + set -- $(ex_lfilter -not "${BUILD_STEPS}" "${PKG_BUILD_STEPS_DISABLE}"); + while [ ${#} -gt 0 ]; do + _step="${1}"; _step_next="${2}"; + _step_cmds=""; _step_cmd_args=""; + _step_type="${_step#*:}"; + _step="${_step%%:*}"; + _step_cmd_pfx="pkg_${_pkg_name}_${_step}"; + case "${_step_type}" in + dynamic) + if [ "${_tgt_name}" = "INVARIANTS" ]; then + _step_cmds="${_step_cmd_pfx} pkg_${_step}"; + elif [ -n "${_restart}" ]; then + if [ -z "${_restart_at}" ]\ + || ex_lmatch "${_restart_at}" , "${_step}"; then + _step_cmds="${_step_cmd_pfx} pkg_${_step}"; + fi; + elif ! ex_pkg_state_test "${_pkg_name}" "${_step}"; then + _step_cmds="${_step_cmd_pfx} pkg_${_step}"; + fi; ;; + invariant) + _step_cmds="pkg_${_step}"; ;; + variant) + if ex_lmatch "${_restart_at}" "," "${_step}"; then + _step_cmds="${_step_cmd_pfx} pkg_${_step}"; + fi; ;; + virtual) + _step_cmds="pkg_${_pkg_name}_${_step}"; + _step_cmd_args="${_restart_at:-ALL}"; ;; + all) + if ex_test_cmd "pkg_${_pkg_name}_${_step}"; then + "${_step_cmd_pfx}" "${_restart_at:-ALL}"; + break; + fi; ;; + finish) ex_pkg_state_push "${_pkg_name}" finish; ;; + *) ;; + esac; + for _step_cmd in ${_step_cmds}; do + if ex_test_cmd "${_step_cmd}"; then + ex_test_cmd "${_step_cmd_pfx}_pre" \ + && "${_step_cmd_pfx}_pre" + "${_step_cmd}" ${_step_cmd_args}; + ex_test_cmd "${_step_cmd_pfx}_post" \ + && "${_step_cmd_pfx}_post" + if [ "${_step_type}" != "invariant" ] \ + && [ -n "${_step_next}" ]; then + ex_pkg_state_push "${_pkg_name}" "${_step}"; + ex_pkg_state_push "${_pkg_name}" "-${_step_next}"; + else + ex_pkg_state_push "${_pkg_name}" "${_step}"; + fi; break; + fi; + done; + shift; done; +}; + +# vim:filetype=sh |