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 | |
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.
-rw-r--r-- | subr/ex_pkg_dispatch.subr | 104 | ||||
-rw-r--r-- | subr/ex_pkg_env.subr | 99 | ||||
-rw-r--r-- | subr/ex_pkg_steps.subr | 66 | ||||
-rw-r--r-- | subr/ex_pkg_vars.subr | 3 |
4 files changed, 144 insertions, 128 deletions
diff --git a/subr/ex_pkg_dispatch.subr b/subr/ex_pkg_dispatch.subr index ff7f2ff5..3f4f5e5a 100644 --- a/subr/ex_pkg_dispatch.subr +++ b/subr/ex_pkg_dispatch.subr @@ -5,100 +5,36 @@ ex_pkg_dispatch() { local _tgt_name="${1}" _pkg_name="${2}" \ _restart="${3}" _restart_at="${4}" \ - _pkg_step_cmds _pkg_step_cmd_args \ _stdout_path _stderr_path \ - _pipe_path _pipe_path2 _pipe_msg _script_rc; - if [ "${_pkg_name#*_flavour_*}" != "${_pkg_name}" ]; then - PKG_NAME_PARENT="${_pkg_name%_flavour_*}"; - fi; - if ex_pkg_state_test "${_pkg_name}" finish; then - if [ -z "${_restart}" ]\ - && [ "${_tgt_name}" != "INVARIANTS" ]; then - return 0; - fi; - fi; - _pipe_path="${WORKDIR}/${_pkg_name}_build.fifo"; - ex_build_fileop rm "${_pipe_path}"; mkfifo "${_pipe_path}"; - _pipe2_path="${WORKDIR}/${_pkg_name}_build2.fifo"; - ex_build_fileop rm "${_pipe2_path}"; mkfifo "${_pipe2_path}"; - _stderr_path="${WORKDIR}/${_pkg_name}_stderr.log"; - _stdout_path="${WORKDIR}/${_pkg_name}_stdout.log"; - ex_build_fileop rm "${_stderr_path}" "${_stdout_path}"; - (set -o errexit -o noglob; - ex_pkg_vars; - if [ -z "${PKG_URL}" ]\ - && [ -z "${PKG_URLS_GIT}" ]\ - && [ -z "${PKG_VERSION}" ]\ - && ! ex_test_cmd "pkg_${PKG_NAME}_all"; then - ex_log_msg failexit "Error: package \`${PKG_NAME}' missing in build.vars."; - exit 1; - elif [ "${PKG_DISABLED:-0}" -eq 1 ]; then - ex_log_msg vnfo "Skipping disabled package \`${PKG_NAME}.'"; - echo "done ${PKG_BASE_DIR}" >&3; exit 0; + _pipe_path _pipe_path2 _pipe_msg \ + _script_rc=1; + if ex_pkg_state_test "${_pkg_name}" finish \ + && [ -z "${_restart}" ] \ + && [ "${_tgt_name}" != "INVARIANTS" ]; then + return 0; else - ex_pkg_env; - ex_build_fileop mkdir "${PKG_BASE_DIR}"; - ex_build_fileop cd "${PKG_BASE_DIR}"; + _pipe_path="${WORKDIR}/${_pkg_name}_build.fifo"; + ex_build_fileop rm "${_pipe_path}"; mkfifo "${_pipe_path}"; + _pipe2_path="${WORKDIR}/${_pkg_name}_build2.fifo"; + ex_build_fileop rm "${_pipe2_path}"; mkfifo "${_pipe2_path}"; + _stderr_path="${WORKDIR}/${_pkg_name}_stderr.log"; + _stdout_path="${WORKDIR}/${_pkg_name}_stdout.log"; + ex_build_fileop rm "${_stderr_path}" "${_stdout_path}"; fi; - set -- $(ex_lfilter -not "${BUILD_STEPS}" \ - "$(ex_get_var_unsafe PKG_$(ex_toupper "${_pkg_name}")_BUILD_STEPS_DISABLE)"); - while [ ${#} -gt 0 ]; do - _pkg_step_cmds=""; _pkg_step_cmd_args=""; - case "${1#*:}" in - dynamic) - if [ "${_tgt_name}" = "INVARIANTS" ]; then - _pkg_step_cmds="pkg_${_pkg_name}_${1%:*} pkg_${1%:*}"; - elif [ -n "${_restart}" ]; then - if [ -z "${_restart_at}" ]\ - || ex_lmatch "${_restart_at}" , "${1%:*}"; then - _pkg_step_cmds="pkg_${_pkg_name}_${1%:*} pkg_${1%:*}"; - fi; - elif ! ex_pkg_state_test "${_pkg_name}" "${1%:*}"; then - _pkg_step_cmds="pkg_${_pkg_name}_${1%:*} pkg_${1%:*}"; - fi; ;; - invariant) - _pkg_step_cmds="pkg_${1%:*}"; ;; - variant) - if ex_lmatch "${_restart_at}" "," "${1%:*}"; then - _pkg_step_cmds="pkg_${_pkg_name}_${1%:*} pkg_${1%:*}"; - fi; ;; - virtual) - _pkg_step_cmds="pkg_${_pkg_name}_${1%:*}"; - _pkg_step_cmd_args="${_restart_at:-ALL}"; ;; - all) - if ex_test_cmd "pkg_${_pkg_name}_${1%:*}"; then - "pkg_${_pkg_name}_${1%:*}" "${_restart_at:-ALL}"; - break; - fi; ;; - finish) ex_pkg_state_push "${_pkg_name}" finish; ;; - *) ;; - esac; - for __ in ${_pkg_step_cmds}; do - if ex_test_cmd "${__}"; then - ex_test_cmd "pkg_${_pkg_name}_${1%:*}_pre" \ - && "pkg_${_pkg_name}_${1%:*}_pre" - "${__}" ${_pkg_step_cmd_args}; - ex_test_cmd "pkg_${_pkg_name}_${1%:*}_post" \ - && "pkg_${_pkg_name}_${1%:*}_post" - if [ "${1#*:}" != "invariant" ]\ - && [ ${#} -ge 2 ]; then - ex_pkg_state_push "${_pkg_name}" "${1%:*}" "-${2#*:}"; - else - ex_pkg_state_push "${_pkg_name}" "${1%:*}"; - fi; break; - fi; - done; - shift; done; set -o xtrace + (set -o errexit -o noglob; + ex_pkg_vars; ex_pkg_env; + ex_pkg_steps "${_tgt_name}" "${_pkg_name}" \ + "${_restart}" "${_restart_at}"; echo "done ${PKG_BASE_DIR}" >&3; read __ <&4;) \ 1>"${_stdout_path}" 2>"${_stderr_path}" \ 3<>"${_pipe_path}" 4<>"${_pipe2_path}" & - _script_rc=1; while read _pipe_msg <"${_pipe_path}"; do + while read _pipe_msg <"${_pipe_path}"; do case "${_pipe_msg%% *}" in done) echo >"${_pipe2_path}"; _script_rc=0; break; ;; *) break; ;; esac; done; - ex_build_fileop rm "${_pipe_path}"; - return "${_script_rc:-0}"; + ex_build_fileop rm "${_pipe_path}" "${_pipe2_path}"; + return "${_script_rc:-1}"; }; # vim:filetype=sh diff --git a/subr/ex_pkg_env.subr b/subr/ex_pkg_env.subr index b3ea764c..a3310797 100644 --- a/subr/ex_pkg_env.subr +++ b/subr/ex_pkg_env.subr @@ -4,50 +4,63 @@ ex_pkg_env() { local _vname; - [ -z "${MIDIPIX_BUILD_PWD}" ] && MIDIPIX_BUILD_PWD="$(pwd)"; - [ -z "${PKG_FNAME}" ] && PKG_FNAME="${PKG_URL##*/}"; - [ -z "${PKG_TARGET}" ] && PKG_TARGET="${TARGET}"; - case "${PKG_BASE_DIR}" in - ?*) ;; - *) PKG_BASE_DIR="${WORKDIR}/${PKG_NAME}-${PKG_BUILD_TYPE:-native}-${PKG_TARGET}"; - if [ -n "${ARG_RESTART}" ]\ - && [ -z "${ARG_RESTART_AT}" ]; then - ex_build_fileop rm "${PKG_BASE_DIR}"; - fi; ;; - esac; - PKG_DESTDIR="${PKG_BASE_DIR}/destdir"; - case "${PKG_BUILD_TYPE}" in - host) export AR="ar"; - export CC="gcc"; - export CXX="g++"; - export RANLIB="ranlib"; ;; - *) export AR="${PKG_TARGET}-ar"; - export CC="${PKG_TARGET}-gcc"; - export CXX="${PKG_TARGET}-g++"; - export RANLIB="${PKG_TARGET}-ranlib"; - [ -x "${PREFIX}/bin/${TARGET}-pkg-config" ]\ - && export PKG_CONFIG="${PREFIX}/bin/${TARGET}-pkg-config"; - ;; - esac; - export LIBTOOL="${PKG_SLIBTOOL:-slibtool}"; - export MAKE="make LIBTOOL=${PKG_SLIBTOOL:-slibtool}"; - case "${PKG_SUBDIR}" in - ?*) ;; - *) case "${PKG_URLS_GIT}" in - ?*) PKG_SUBDIR="${PKG_URLS_GIT%%=*}"; ;; - *) case "${PKG_FNAME}" in - *.t*) PKG_SUBDIR="${PKG_FNAME%%.t*}"; ;; - *) PKG_SUBDIR="${PKG_NAME}"; ;; + if [ -z "${PKG_URL}" ]\ + && [ -z "${PKG_URLS_GIT}" ]\ + && [ -z "${PKG_VERSION}" ]\ + && ! ex_test_cmd "pkg_${PKG_NAME}_all"; then + ex_log_msg failexit "Error: package \`${PKG_NAME}' missing in build.vars."; + return 1; + elif [ "${PKG_DISABLED:-0}" -eq 1 ]; then + ex_log_msg vnfo "Skipping disabled package \`${PKG_NAME}.'"; + return 0; + else + [ -z "${MIDIPIX_BUILD_PWD}" ] && MIDIPIX_BUILD_PWD="$(pwd)"; + [ -z "${PKG_FNAME}" ] && PKG_FNAME="${PKG_URL##*/}"; + [ -z "${PKG_TARGET}" ] && PKG_TARGET="${TARGET}"; + case "${PKG_BASE_DIR}" in + ?*) ;; + *) PKG_BASE_DIR="${WORKDIR}/${PKG_NAME}-${PKG_BUILD_TYPE:-native}-${PKG_TARGET}"; + if [ -n "${ARG_RESTART}" ]\ + && [ -z "${ARG_RESTART_AT}" ]; then + ex_build_fileop rm "${PKG_BASE_DIR}"; + fi; ;; + esac; + ex_build_fileop mkdir "${PKG_BASE_DIR}"; + ex_build_fileop cd "${PKG_BASE_DIR}"; + PKG_DESTDIR="${PKG_BASE_DIR}/destdir"; + case "${PKG_BUILD_TYPE}" in + host) export AR="ar"; + export CC="gcc"; + export CXX="g++"; + export RANLIB="ranlib"; ;; + *) export AR="${PKG_TARGET}-ar"; + export CC="${PKG_TARGET}-gcc"; + export CXX="${PKG_TARGET}-g++"; + export RANLIB="${PKG_TARGET}-ranlib"; + [ -x "${PREFIX}/bin/${TARGET}-pkg-config" ]\ + && export PKG_CONFIG="${PREFIX}/bin/${TARGET}-pkg-config"; + ;; + esac; + export LIBTOOL="${PKG_SLIBTOOL:-slibtool}"; + export MAKE="make LIBTOOL=${PKG_SLIBTOOL:-slibtool}"; + case "${PKG_SUBDIR}" in + ?*) ;; + *) case "${PKG_URLS_GIT}" in + ?*) PKG_SUBDIR="${PKG_URLS_GIT%%=*}"; ;; + *) case "${PKG_FNAME}" in + *.t*) PKG_SUBDIR="${PKG_FNAME%%.t*}"; ;; + *) PKG_SUBDIR="${PKG_NAME}"; ;; + esac; ;; esac; ;; - esac; ;; - esac; - for _vname in $(ex_split : ${PKG_ENV_VARS_EXTRA}); do - export "${_vname}"; - done; - if [ -n "${PKG_ENV_VARS}" ]\ - && [ "${PKG_NO_LOG_VARS:-0}" -eq 0 ]; then - PKG_ENV_VARS="$(echo "${PKG_ENV_VARS}" | tr " " "\n" | sort | tr "\n" " ")"; - ex_log_env_vars "build" ${PKG_ENV_VARS}; + esac; + for _vname in $(ex_split : ${PKG_ENV_VARS_EXTRA}); do + export "${_vname}"; + done; + if [ -n "${PKG_ENV_VARS}" ]\ + && [ "${PKG_NO_LOG_VARS:-0}" -eq 0 ]; then + PKG_ENV_VARS="$(echo "${PKG_ENV_VARS}" | tr " " "\n" | sort | tr "\n" " ")"; + ex_log_env_vars "build" ${PKG_ENV_VARS}; + fi; fi; }; 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 diff --git a/subr/ex_pkg_vars.subr b/subr/ex_pkg_vars.subr index 07c2cacd..9c23b0d5 100644 --- a/subr/ex_pkg_vars.subr +++ b/subr/ex_pkg_vars.subr @@ -30,7 +30,8 @@ ex_pkg_vars() { . "${_vars_path}"; fi; done; - if [ -n "${PKG_NAME_PARENT}" ]; then + if [ "${PKG_NAME#*_flavour_*}" != "${PKG_NAME}" ]; then + PKG_NAME_PARENT="${_pkg_name%_flavour_*}"; exp_pkg_vars "${PKG_NAME_PARENT}"; fi; exp_pkg_vars "${PKG_NAME}"; |