From 4a5da5254e1207686f492e7ce8759c80466185f3 Mon Sep 17 00:00:00 2001 From: Lucio Andrés Illanes Albornoz Date: Feb 25 2020 22:31:28 +0000 Subject: build.sh: reintroduce {disabled,skipped}_pkg messages at -v[v[v]]. build.sh, subr/build_init.subr: minor cleanup. subr/ex_pkg_dispatch.subr:exp_pkg_expand_packages(): call ${_dispatch_fn} w/ {disabled,skipped}_pkg for {disabled,skipped} packages. subr/ex_pkg_dispatch.subr:exp_pkg_expand_packages(): don't mutate ${EX_PKG_NSKIPPED}. subr/ex_pkg_dispatch.subr:ex_pkg_dispatch(): don't set ${EX_PKG_NSKIPPED}. --- diff --git a/build.sh b/build.sh index d9bfd93..be59adb 100755 --- a/build.sh +++ b/build.sh @@ -5,7 +5,7 @@ buildp_dispatch() { local _msg="${1}" _group_name="${2}" _pkg_name="${3}" \ _build_group_lc="" _build_group_meta="" _build_groups_lc="" \ - _njobs_max=1 _pkg_names="" _pkg_restart="" _rc=0; + _pkg_names="" _pkg_restart="" _rc=0; case "${_msg}" in # Top-level start_build) shift; build_init "${@}"; @@ -15,13 +15,10 @@ buildp_dispatch() { if ! ex_rtl_lmatch "${ARG_DIST}" "rpm" ","; then _build_groups_lc="$(ex_rtl_lfilter "${_build_groups_lc}" "host_deps_rpm")"; fi; - if [ "${ARG_PARALLEL:-0}" -gt 1 ]; then - _njobs_max="${ARG_PARALLEL}"; - fi; for _build_group_lc in ${_build_groups_lc}; do - ex_pkg_dispatch buildp_dispatch "${_build_group_lc}" "${_njobs_max}" \ + ex_pkg_dispatch buildp_dispatch "${_build_group_lc}" "${ARG_PARALLEL:-1}" \ "${ARG_RESTART}" "${ARG_RESTART_AT}" "${ARG_RESTART_RECURSIVE}"; _rc="${?}"; - : $((_nskipped+=${EX_PKG_NSKIPPED})); _pkg_names="$(ex_rtl_lconcat "${_pkg_names}" "${EX_PKG_NAMES}")"; + _pkg_names="$(ex_rtl_lconcat "${_pkg_names}" "${EX_PKG_NAMES}")"; if [ "${_rc}" -ne 0 ]; then break; fi; @@ -32,12 +29,12 @@ buildp_dispatch() { ex_rtl_log_msg failexit "Error: package \`${_pkg_restart}' unknown."; fi; done; - if ! ex_pkg_dispatch buildp_dispatch "invariants" "${_njobs_max}" "ALL" "ALL" 2; then + if ! ex_pkg_dispatch buildp_dispatch "invariants" "${ARG_PARALLEL:-1}" "ALL" "ALL" 2; then break; fi; buildp_dispatch finish_build; ;; finish_build) build_fini; - ex_rtl_log_msg info "${BUILD_NFINI:-0} finished, ${_nskipped:-0} skipped, and ${BUILD_NFAIL:-0} failed builds in ${BUILD_NBUILT:-0} build script(s)."; + ex_rtl_log_msg info "${BUILD_NFINI:-0} finished, ${BUILD_NSKIP:-0} skipped, and ${BUILD_NFAIL:-0} failed package(s)."; ex_rtl_log_msg info "Build time: ${BUILD_TIMES_HOURS:-0} hour(s), ${BUILD_TIMES_MINUTES:-0} minute(s), and ${BUILD_TIMES_SECS:-0} second(s)."; if [ -n "${BUILD_PKGS_FAILED}" ]; then ex_rtl_log_msg failexit "Build script failure(s) in: ${BUILD_PKGS_FAILED}."; @@ -71,6 +68,10 @@ buildp_dispatch() { fi; exit 1; fi; ;; + disabled_pkg) : $((BUILD_NSKIP+=1)); + ex_rtl_log_msg vnfo "$(printf "Skipping disabled package \`%s.'" "${_pkg_name}")"; ;; + skipped_pkg) : $((BUILD_NSKIP+=1)); + ex_rtl_log_msg vnfo "$(printf "Skipping finished package \`%s.'" "${_pkg_name}")"; ;; step_pkg) ex_rtl_log_msg vucc "$(printf "Finished build step %s of package \`%s'." "${4}" "${_pkg_name}")"; ;; # Child process diff --git a/subr/build_init.subr b/subr/build_init.subr index 870128b..a52ff5f 100644 --- a/subr/build_init.subr +++ b/subr/build_init.subr @@ -40,11 +40,9 @@ buildp_init_args() { fi; fi; ex_rtl_log_set_vnfo_lvl "${ARG_VERBOSE:-0}"; - BUILD_IS_PARENT=1; - BUILD_DATE_START="$(ex_rtl_date %Y-%m-%d-%H-%M-%S)"; - BUILD_NFINI="${BUILD_NSKIP:=${BUILD_NFAIL:=${BUILD_NBUILT:=0}}}"; - BUILD_PKGS_FAILED=""; - BUILD_TIMES_SECS="$(ex_rtl_date %s)"; + BUILD_DATE_START="$(ex_rtl_date %Y-%m-%d-%H-%M-%S)"; BUILD_IS_PARENT=1; + BUILD_NFAIL="${BUILD_NFINI:=${BUILD_NSKIP:=0}}"; + BUILD_PKGS_FAILED=""; BUILD_TIMES_SECS="$(ex_rtl_date %s)"; if [ "${ARG_FETCH_FORCE}" = "ipv4" ]; then DEFAULT_GIT_ARGS="-4${DEFAULT_GIT_ARGS:+ ${DEFAULT_GIT_ARGS}}"; DEFAULT_WGET_ARGS="-4${DEFAULT_WGET_ARGS:+ ${DEFAULT_WGET_ARGS}}"; diff --git a/subr/ex_pkg_dispatch.subr b/subr/ex_pkg_dispatch.subr index d3053c4..2d34a90 100644 --- a/subr/ex_pkg_dispatch.subr +++ b/subr/ex_pkg_dispatch.subr @@ -84,7 +84,7 @@ exp_pkg_dispatch_packages() { # @_restart: optional comma-separated list of package names to rebuild # @_restart_recursive: optional flag specifiying either no dependency expansion (0,) dependency expansion (1,) dependency expansion and forcibly rebuild (2.) # -# Return: zero (0) on success, non-zero (>0) on failure, ${EX_PKG_NSKIPPED}, ${EX_PKG_NAMES}, and ${PKG_COMPLETE} set post-return. +# Return: zero (0) on success, non-zero (>0) on failure, ${EX_PKG_NAMES} and ${PKG_COMPLETE} set post-return. # exp_pkg_expand_packages() { local _group_name="${1}" _restart="${2}" _restart_recursive="${3}" _pkg_name="" _pkg_names=""; @@ -99,12 +99,14 @@ exp_pkg_expand_packages() { for _pkg_name in ${_pkg_names}; do if [ -n "$(ex_rtl_get_var_unsafe -u "PKG_${_pkg_name}_DISABLED")" ]; then PKG_COMPLETE="$(ex_rtl_lconcat "${PKG_COMPLETE}" "${_pkg_name}")"; - : $((EX_PKG_NSKIPPED+=1)); _pkg_names="$(ex_rtl_lfilter "${_pkg_names}" "${_pkg_name}")"; + _pkg_names="$(ex_rtl_lfilter "${_pkg_names}" "${_pkg_name}")"; + "${_dispatch_fn}" disabled_pkg "${_group_name}" "${_pkg_name}"; elif ex_pkg_state_test "${_pkg_name}" finish\ && ! ex_rtl_lmatch "${_restart}" "${_pkg_name}"\ && [ "${_restart_recursive:-0}" -ne 2 ]; then PKG_COMPLETE="$(ex_rtl_lconcat "${PKG_COMPLETE}" "${_pkg_name}")"; - : $((EX_PKG_NSKIPPED+=1)); _pkg_names="$(ex_rtl_lfilter "${_pkg_names}" "${_pkg_name}")"; + _pkg_names="$(ex_rtl_lfilter "${_pkg_names}" "${_pkg_name}")"; + "${_dispatch_fn}" skipped_pkg "${_group_name}" "${_pkg_name}"; fi; done; EX_PKG_NAMES="${_pkg_names}"; return 0; @@ -120,12 +122,12 @@ exp_pkg_expand_packages() { # @_restart_at: optional comma-separated list of build steps at which to rebuild or ALL # @_restart_recursive: optional flag specifiying either no dependency expansion (0,) dependency expansion (1,) dependency expansion and forcibly rebuild (2.) # -# Return: zero (0) on success, non-zero (>0) on failure, ${EX_PKG_NAMES} and ${EX_PKG_NSKIPPED} set post-return. +# Return: zero (0) on success, non-zero (>0) on failure, ${EX_PKG_NAMES} set post-return. # ex_pkg_dispatch() { local _dispatch_fn="${1}" _group_name="${2}" _njobs_max="${3}" _restart="${4}" _restart_at="${5}" \ _restart_recursive="${6}" _pipe_msg="" _pipe_path="${BUILD_WORKDIR}/build.fifo" _pkg_name="" \ - _script_rc=0 NJOBS=0 PKG_COMPLETE="" PKG_COUNT=0 PKG_COUNT_MAX=0 PKG_NAMES="" PKG_WAIT=""; EX_PKG_NSKIPPED=0; EX_PKG_NAMES=""; + _script_rc=0 NJOBS=0 PKG_COMPLETE="" PKG_COUNT=0 PKG_COUNT_MAX=0 PKG_NAMES="" PKG_WAIT=""; EX_PKG_NAMES=""; if "${_dispatch_fn}" start_group "${_group_name}" ""; then if ex_rtl_fileop mkdir "${BUILD_WORKDIR}"\ && ex_rtl_log_msg vnfo "Resolving \`${_group_name}' dependencies..."\