diff options
-rwxr-xr-x | build.sh | 34 | ||||
-rw-r--r-- | subr/ex_pkg_dispatch.subr | 41 | ||||
-rw-r--r-- | subr/ex_pkg_env.subr | 88 | ||||
-rw-r--r-- | subr/ex_pkg_state.subr | 3 | ||||
-rw-r--r-- | vars/gcc.vars | 5 | ||||
-rw-r--r-- | vars/musl.vars | 3 |
6 files changed, 94 insertions, 80 deletions
@@ -3,10 +3,10 @@ # for __ in $(find subr -name *.subr); do . "${__}"; done; -ex_setup_args "${@}"; ex_setup_env; ex_setup_checks; ex_setup_subdirs; -ex_pkg_state_init; {( +ex_setup_args "${@}"; ex_setup_env; ex_setup_checks; ex_setup_subdirs; ex_pkg_state_init; ex_log_msg info "Build started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE_START}."; ex_log_env_vars "build (global)" ${LOG_ENV_VARS}; + for BUILD_TARGET_META in invariants ${BUILD_TARGETS_META:-world}; do for BUILD_TARGET_LC in $(ex_get_var_unsafe "$(ex_toupper "${BUILD_TARGET_META}")_TARGET"); do BUILD_TARGET="$(ex_toupper "${BUILD_TARGET_LC}")"; @@ -16,38 +16,36 @@ for BUILD_TARGET_META in invariants ${BUILD_TARGETS_META:-world}; do BUILD_PACKAGES="$(ex_lfilter "${BUILD_PACKAGES}" "${BUILD_PACKAGES_RESTART}")"; fi; for PKG_NAME in ${BUILD_PACKAGES}; do + ex_log_msg vnfo "Starting \`${PKG_NAME}' build..."; ex_pkg_dispatch "${BUILD_TARGET}" "${PKG_NAME}" \ "${ARG_RESTART}" "${ARG_RESTART_AT}"; BUILD_SCRIPT_RC=${?}; case ${BUILD_SCRIPT_RC} in 0) ex_log_msg succ "Finished \`${PKG_NAME}' build."; - : $((BUILD_NFINI+=1)); continue; ;; - *) ex_log_msg fail "Build failed in \`${PKG_NAME}' (last return code ${BUILD_SCRIPT_RC}.)."; - : $((BUILD_NFAIL+=1)); - if [ ${ARG_RELAXED:-0} -eq 1 ]; then - BUILD_PKGS_FAILED="${BUILD_PKGS_FAILED:+${BUILD_PKGS_FAILED} }${PKG_NAME}"; - continue; - else - break; - fi; + : $((BUILD_NFINI+=1)); continue; ;; + *) ex_log_msg fail "Build failed in \`${PKG_NAME}', check \`${WORKDIR}/${PKG_NAME}_std{err,out}.log' for details."; + : $((BUILD_NFAIL+=1)); + if [ ${ARG_RELAXED:-0} -eq 1 ]; then + BUILD_PKGS_FAILED="${BUILD_PKGS_FAILED:+${BUILD_PKGS_FAILED} }${PKG_NAME}"; + continue; + else + break; + fi; ;; esac; done; if [ "${BUILD_SCRIPT_RC:-0}" -ne 0 ]; then break; fi; done; -done; ex_pkg_state_fini; +done; + +ex_pkg_state_fini; ex_log_msg info "${BUILD_NFINI} finished, ${BUILD_NSKIP} skipped, and ${BUILD_NFAIL} failed builds in ${BUILD_NBUILT} build script(s)."; ex_log_msg info "Build time: ${BUILD_TIMES_HOURS} hour(s), ${BUILD_TIMES_MINUTES} minute(s), and ${BUILD_TIMES_SECS} second(s)."; if [ ${ARG_RELAXED:-0} -eq 1 ]\ && [ -n "${BUILD_PKGS_FAILED}" ]; then ex_log_msg info "Build script failure(s) in: ${BUILD_PKGS_FAILED}."; fi; -exit "${BUILD_SCRIPT_RC:-0}")} 2>&1 | tee "${BUILD_LOG_FNAME}" & TEE_PID="${!}"; - -trap "rm -f ${BUILD_STATUS_IN_PROGRESS_FNAME}; \ - ex_log_msg fail \"Build aborted.\"; \ - echo kill ${TEE_PID}; \ - kill ${TEE_PID}" HUP INT TERM USR1 USR2; wait; +exit "${BUILD_SCRIPT_RC:-0}" # vim:filetype=sh 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() { diff --git a/vars/gcc.vars b/vars/gcc.vars index 277ba8a8..f3b192b8 100644 --- a/vars/gcc.vars +++ b/vars/gcc.vars @@ -159,7 +159,6 @@ pkg_gcc_stage1_all() { fi; ex_pkg_state_push "${PKG_NAME}" install finish; fi; - exit 0; }; pkg_gcc_runtime_all() { @@ -176,7 +175,6 @@ pkg_gcc_runtime_all() { make ${PKG_MAKEFLAGS_BUILD} install-target-libgcc; ex_pkg_state_push "${PKG_NAME}" install finish; fi; - exit 0; }; pkg_gcc_libstdcpp_v3_all() { @@ -193,7 +191,6 @@ pkg_gcc_libstdcpp_v3_all() { make ${PKG_MAKEFLAGS_BUILD} install-target-libstdc++-v3; ex_pkg_state_push "${PKG_NAME}" install finish; fi; - exit 0; }; pkg_gcc_full_all() { @@ -210,7 +207,6 @@ pkg_gcc_full_all() { make ${PKG_MAKEFLAGS_BUILD} install; ex_pkg_state_push "${PKG_NAME}" install finish; fi; - exit 0; }; pkg_gcc_native_all() { @@ -253,7 +249,6 @@ pkg_gcc_native_all() { make ${PKG_MAKEFLAGS_BUILD} "DESTDIR=${PKG_PREFIX}" install; ex_pkg_state_push "${PKG_NAME}" install finish; fi; - exit 0; }; # vim:filetype=sh diff --git a/vars/musl.vars b/vars/musl.vars index 5605872f..d2dfd54c 100644 --- a/vars/musl.vars +++ b/vars/musl.vars @@ -53,7 +53,6 @@ pkg_musl_no_complex_all() { ./lazy -e "${_install}" -x build; ex_pkg_state_push "${PKG_NAME}" build finish; fi; - exit 0; }; pkg_musl_native_all() { @@ -76,7 +75,6 @@ pkg_musl_native_all() { ex_build_fileop ln_symbolic ../lib/libc.so "${PKG_PREFIX}/bin/ldd"; ex_pkg_state_push "${PKG_NAME}" build finish; fi; - exit 0; }; pkg_musl_full_all() { @@ -98,7 +96,6 @@ pkg_musl_full_all() { ./lazy -e "${_install}" -x build; ex_pkg_state_push "${PKG_NAME}" build finish; fi; - exit 0; }; # vim:filetype=sh |