summaryrefslogtreecommitdiffhomepage
path: root/subr
diff options
context:
space:
mode:
authorLucio Andrés Illanes Albornoz (arab, vxp) <lucio@lucioillanes.de>2017-11-22 16:00:55 +0000
committerLucio Andrés Illanes Albornoz (arab, vxp) <lucio@lucioillanes.de>2017-11-22 18:06:58 +0000
commitfc9417f077a909539495531229f9035c15fe10f0 (patch)
tree30195a268ceb7d5a6bb5a1c6167385bbbf68e58d /subr
parent14c984b00aece1050b63288fe5856854ebcbb352 (diff)
downloadmidipix_build-fc9417f077a909539495531229f9035c15fe10f0.tar.bz2
midipix_build-fc9417f077a909539495531229f9035c15fe10f0.tar.xz
build.sh, subr/ex_pkg_dispatch.subr: splits build logging and job control logic.
subr/ex_pkg_dispatch.subr: dispatch background jobs w/ redirected std{err,out} & FIFO. subr/ex_pkg_state.subr:ex_pkg_state_init(): trap(1) signals to abort build. vars/{gcc,musl}.vars: don't exit(1) from within package subroutine.
Diffstat (limited to 'subr')
-rw-r--r--subr/ex_pkg_dispatch.subr41
-rw-r--r--subr/ex_pkg_env.subr88
-rw-r--r--subr/ex_pkg_state.subr3
3 files changed, 78 insertions, 54 deletions
diff --git a/subr/ex_pkg_dispatch.subr b/subr/ex_pkg_dispatch.subr
index fc1ddaa9..ff7f2ff5 100644
--- a/subr/ex_pkg_dispatch.subr
+++ b/subr/ex_pkg_dispatch.subr
@@ -5,7 +5,9 @@
ex_pkg_dispatch() {
local _tgt_name="${1}" _pkg_name="${2}" \
_restart="${3}" _restart_at="${4}" \
- _pkg_step_cmds _pkg_step_cmd_args;
+ _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;
@@ -15,10 +17,29 @@ ex_pkg_dispatch() {
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; ex_pkg_env;
- ex_build_fileop mkdir "${PKG_BASE_DIR}";
- ex_build_fileop cd "${PKG_BASE_DIR}";
+ 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;
+ else
+ ex_pkg_env;
+ ex_build_fileop mkdir "${PKG_BASE_DIR}";
+ ex_build_fileop cd "${PKG_BASE_DIR}";
+ fi;
set -- $(ex_lfilter -not "${BUILD_STEPS}" \
"$(ex_get_var_unsafe PKG_$(ex_toupper "${_pkg_name}")_BUILD_STEPS_DISABLE)");
while [ ${#} -gt 0 ]; do
@@ -67,7 +88,17 @@ ex_pkg_dispatch() {
fi; break;
fi;
done;
- shift; done); return ${?};
+ shift; done; set -o xtrace
+ 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
+ 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}";
};
# vim:filetype=sh
diff --git a/subr/ex_pkg_env.subr b/subr/ex_pkg_env.subr
index cbd0b77d..b3ea764c 100644
--- a/subr/ex_pkg_env.subr
+++ b/subr/ex_pkg_env.subr
@@ -4,56 +4,46 @@
ex_pkg_env() {
local _vname;
- 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.";
- elif [ "${PKG_DISABLED:-0}" -eq 1 ]; then
- ex_log_msg vnfo "Skipping disabled package \`${PKG_NAME}.'";
- exit 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;
- 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; ;;
+ [ -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}"; ;;
esac; ;;
- esac;
- for _vname in $(ex_split : ${PKG_ENV_VARS_EXTRA}); do
- export "${_vname}";
- done;
- fi;
+ 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" " ")";
diff --git a/subr/ex_pkg_state.subr b/subr/ex_pkg_state.subr
index 4cc0a8b0..cb86bf2f 100644
--- a/subr/ex_pkg_state.subr
+++ b/subr/ex_pkg_state.subr
@@ -29,6 +29,9 @@ ex_pkg_state_init() {
BUILD_NFINI=${BUILD_NSKIP:=${BUILD_NFAIL:=${BUILD_NBUILT:=0}}};
BUILD_TIMES_SECS=$(ex_date %s);
BUILD_PKGS_FAILED="";
+ trap "rm -f ${BUILD_STATUS_IN_PROGRESS_FNAME}; \
+ ex_log_msg failexit \"Build aborted.\";" \
+ HUP INT TERM USR1 USR2;
};
ex_pkg_state_push() {