From 7bed8897ea5cd2bb80f275f93e4287754bd5cc97 Mon Sep 17 00:00:00 2001 From: Lucio Andrés Illanes Albornoz Date: Mar 05 2020 13:21:40 +0000 Subject: subr/ex_pkg{,_dispatch}.subr: implement -r ***name[,..][:step,..]: forcibly rebuild all packages that depend on the specified package(s). etc/{build.usage,README.md}, subr/build_init.subr: updated. --- diff --git a/etc/README.md b/etc/README.md index 861d7d9..3543254 100644 --- a/etc/README.md +++ b/etc/README.md @@ -206,8 +206,9 @@ usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..] Restart the specified comma-separated package(s) completely or at optionally specified comma-separated list of build steps. - Prepend w/ `*' to automatically include dependencies and `**' to - forcibly rebuild all dependencies. + Prepend w/ `*' to automatically include dependencies, `**' to + forcibly rebuild all dependencies, and `***` to forcibly rebuild + all packages that depend on the specified package(s). Currently defined build steps are: fetch_wget, fetch_git, fetch_extract, configure_patch_pre, @@ -223,7 +224,7 @@ usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..] new commits. --debug-minipix Don't strip(1) minipix binaries to facilitate debugging minipix. [ ..] One of: dev_packages, dist, host_deps, host_deps_rpm, - host_toolchain, host_tools, minipix, native_packages, + host_toolchain, host_tools, minipix, native_packages, native_runtime, native_toolchain, native_tools. ``` diff --git a/etc/build.usage b/etc/build.usage index 0f0f816..d0b900b 100644 --- a/etc/build.usage +++ b/etc/build.usage @@ -1,6 +1,6 @@ -usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..]] - [-F ipv4|ipv6|offline] [-h] [-p jobs] [-P] [-r ALL|LAST] - [-r [*[*]]name[,..][:step,..]] [-R] [-v[v[v[v]]]] [--as-needed] +usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..]] + [-F ipv4|ipv6|offline] [-h] [-p jobs] [-P] [-r ALL|LAST] + [-r [*[*[*]]]name[,..][:step,..]] [-R] [-v[v[v[v]]]] [--as-needed] [--debug-minipix] [|=[ ..]] -a nt32|nt64 Selects 32-bit or 64-bit architecture; defaults to nt64. @@ -25,12 +25,13 @@ usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..] -r ALL|LAST Restart all packages or the last failed package and resume build, resp. - -r [*[*]]name[,..][:step,..] + -r [*[*[*]]]name[,..][:step,..] Restart the specified comma-separated package(s) completely or at optionally specified comma-separated list of build steps. - Prepend w/ `*' to automatically include dependencies and `**' to - forcibly rebuild all dependencies. + Prepend w/ `*' to automatically include dependencies, `**' to + forcibly rebuild all dependencies, and `***` to forcibly rebuild + all packages that depend on the specified package(s). Currently defined build steps are: fetch_wget, fetch_git, fetch_extract, configure_patch_pre, @@ -46,5 +47,5 @@ usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..] new commits. --debug-minipix Don't strip(1) minipix binaries to facilitate debugging minipix. [ ..] One of: dev_packages, dist, host_deps, host_deps_rpm, - host_toolchain, host_tools, minipix, native_packages, + host_toolchain, host_tools, minipix, native_packages, native_runtime, native_toolchain, native_tools. diff --git a/subr/build_init.subr b/subr/build_init.subr index 7d52d9b..075affb 100644 --- a/subr/build_init.subr +++ b/subr/build_init.subr @@ -10,7 +10,9 @@ buildp_init_args() { _status="Git repository has not changed since last build and --as-needed was specified."; fi; if [ -n "${ARG_RESTART}" ]; then - if [ "${ARG_RESTART#\*\*}" != "${ARG_RESTART}" ]; then + if [ "${ARG_RESTART#\*\*\*}" != "${ARG_RESTART}" ]; then + ARG_RESTART="${ARG_RESTART#\*\*\*}"; ARG_RESTART_RECURSIVE=3; + elif [ "${ARG_RESTART#\*\*}" != "${ARG_RESTART}" ]; then ARG_RESTART="${ARG_RESTART#\*\*}"; ARG_RESTART_RECURSIVE=2; elif [ "${ARG_RESTART#\*}" != "${ARG_RESTART}" ]; then ARG_RESTART="${ARG_RESTART#\*}"; ARG_RESTART_RECURSIVE=1; diff --git a/subr/ex_pkg.subr b/subr/ex_pkg.subr index e4a6814..7c8c515 100644 --- a/subr/ex_pkg.subr +++ b/subr/ex_pkg.subr @@ -7,7 +7,7 @@ # @_pkg_complete: list of completed packages # @_pkg_name: single package name # @_pkg_wait: list of in-progress packages -# @_restart_recursive: optional flag specifiying either no dependency expansion (0,) dependency expansion (1,) dependency expansion and forcibly rebuild (2.) +# @_restart_recursive: optional flag specifiying either no dependency expansion (0,) dependency expansion (1,) dependency expansion and forcibly rebuild (2,) forcibly rebuild reverse dependencies (3.) # # Return: zero (0) given no outstanding dependencies, non-zero (>0) otherwise # @@ -15,14 +15,16 @@ ex_pkg_check_depends() { local _pkg_complete="${1}" _pkg_name="${2}" _pkg_wait="${3}" _restart_recursive="${4}" \ _pkg_depends="" _pkg_name_depend="" _dependfl=0; if _pkg_depends="$(rtl_lunfold_depends 'PKG_${_name}_DEPENDS' $(rtl_get_var_unsafe -u "PKG_"${_pkg_name}"_DEPENDS"))"\ - && [ -n "${_pkg_depends}" ]\ - && ! [ -n "${_restart}" ] || [ "${_restart_recursive:-0}" -ge 1 ]; then - for _pkg_name_depend in $(rtl_uniq ${_pkg_depends}); do - if ! rtl_lmatch "${_pkg_complete}" "${_pkg_name_depend}"\ - || rtl_lmatch "${_pkg_wait}" "${_pkg_name_depend}"; then - _dependfl=1; break; - fi; - done; + && [ -n "${_pkg_depends}" ]; then + if [ -z "${_restart}" ]\ + || [ "${_restart_recursive:-0}" -ge 1 ]; then + for _pkg_name_depend in $(rtl_uniq ${_pkg_depends}); do + if ! rtl_lmatch "${_pkg_complete}" "${_pkg_name_depend}"\ + || rtl_lmatch "${_pkg_wait}" "${_pkg_name_depend}"; then + _dependfl=1; break; + fi; + done; + fi; fi; return "${_dependfl}"; }; @@ -31,28 +33,34 @@ ex_pkg_check_depends() { # ex_pkg_expand_packages() - expand build group name to list of packages ordered and filtered according to dependency and restart constraints # @_group_name: build group name # @_restart: optional whitespace-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.) +# @_restart_recursive: optional flag specifiying either no dependency expansion (0,) dependency expansion (1,) dependency expansion and forcibly rebuild (2,) forcibly rebuild reverse dependencies (3.) # # Return: zero (0) on success, non-zero (>0) on failure, ${EXP_PKG_COMPLETE}, ${EXP_PKG_DISABLED}, ${EXP_PKG_FINISHED}, and ${EXP_PKG_NAMES} set post-return. # ex_pkg_expand_packages() { local _group_name="${1}" _restart="${2}" _restart_recursive="${3}" \ - _pkg_name="" _pkg_names="" _restart_check=0; + _pkg_depends="" _pkg_name="" _pkg_names="" _restart_check=0; EXP_PKG_COMPLETE=""; EXP_PKG_DISABLED=""; EXP_PKG_FINISHED=""; EXP_PKG_NAMES=""; if _pkg_names="$(rtl_get_var_unsafe -u "${_group_name}_PACKAGES")"\ && [ -n "${_pkg_names}" ]; then - if [ -n "${_restart}" ] && ! rtl_lmatch "${_restart}" "ALL LAST"; then - _pkg_names="$(rtl_lsearch "${_pkg_names}" "${_restart}")"; - fi; - if ! [ -n "${_restart}" ] || [ "${_restart_recursive:-0}" -ge 1 ]; then - _pkg_names="$(rtl_uniq $(rtl_lunfold_depends 'PKG_${_name}_DEPENDS' ${_pkg_names}))"; + if [ "${_restart_recursive:-0}" -ne 3 ]; then + if [ -n "${_restart}" ] && ! rtl_lmatch "${_restart}" "ALL LAST"; then + _pkg_names="$(rtl_lsearch "${_pkg_names}" "${_restart}")"; + fi; + if [ -z "${_restart}" ]\ + || [ "${_restart_recursive:-0}" -eq 1 ]\ + || [ "${_restart_recursive:-0}" -eq 2 ]; then + _pkg_names="$(rtl_uniq $(rtl_lunfold_depends 'PKG_${_name}_DEPENDS' ${_pkg_names}))"; + fi; fi; for _pkg_name in ${_pkg_names}; do - if [ "${_restart}" = "ALL" ]\ - || rtl_lmatch "${_restart}" "${_pkg_name}"; then - _restart_check=1; - else - _restart_check=0; + if [ "${_restart_recursive:-0}" -ne 3 ]; then + if [ "${_restart}" = "ALL" ]\ + || rtl_lmatch "${_restart}" "${_pkg_name}"; then + _restart_check=1; + else + _restart_check=0; + fi; fi; if [ -n "$(rtl_get_var_unsafe -u "PKG_${_pkg_name}_DISABLED")" ]; then EXP_PKG_COMPLETE="$(rtl_lconcat "${EXP_PKG_COMPLETE}" "${_pkg_name}")"; @@ -61,11 +69,19 @@ ex_pkg_expand_packages() { elif ex_pkg_state_test "${_pkg_name}" finish\ && [ "${_restart_check:-0}" -eq 0 ]\ && [ "${_restart_recursive:-0}" -ne 2 ]\ + && [ "${_restart_recursive:-0}" -ne 3 ]\ && [ "x$(rtl_get_var_unsafe -u "${_group_name}_FORCE")" != "x1" ]; then EXP_PKG_COMPLETE="$(rtl_lconcat "${EXP_PKG_COMPLETE}" "${_pkg_name}")"; EXP_PKG_FINISHED="$(rtl_lconcat "${EXP_PKG_FINISHED}" "${_pkg_name}")"; _pkg_names="$(rtl_lfilter "${_pkg_names}" "${_pkg_name}")"; fi; + if [ "${_restart_recursive:-0}" -eq 3 ]; then + if ! _pkg_depends="$(rtl_lunfold_depends 'PKG_${_name}_DEPENDS' $(rtl_get_var_unsafe -u "PKG_"${_pkg_name}"_DEPENDS"))"\ + || [ -z "${_pkg_depends}" ]\ + || ! rtl_lmatch "${_pkg_depends}" "${_restart}"; then + _pkg_names="$(rtl_lfilter "${_pkg_names}" "${_pkg_name}")"; + fi; + fi; done; EXP_PKG_NAMES="${_pkg_names}"; fi; diff --git a/subr/ex_pkg_dispatch.subr b/subr/ex_pkg_dispatch.subr index 688cd0e..5d7081c 100644 --- a/subr/ex_pkg_dispatch.subr +++ b/subr/ex_pkg_dispatch.subr @@ -30,7 +30,7 @@ exp_pkg_dispatch_complete() { # @_njobs_max: maximum count of simultaneous jobs # @_pipe_path: pathname to build FIFO # @_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.) +# @_restart_recursive: optional flag specifiying either no dependency expansion (0,) dependency expansion (1,) dependency expansion and forcibly rebuild (2,) forcibly rebuild reverse dependencies (3.) # @_workdir: pathname to build-specific temporary directory # # Return: zero (0) on success, non-zero (>0) on failure. @@ -120,7 +120,7 @@ exp_pkg_dispatch_package() { # @_pipe_path: pathname to parent-child process FIFO # @_pkg_complete: list of completed 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.) +# @_restart_recursive: optional flag specifiying either no dependency expansion (0,) dependency expansion (1,) dependency expansion and forcibly rebuild (2,) forcibly rebuild reverse dependencies (3.) # @_workdir: pathname to build-specific temporary directory # # Return: zero (0) on success, non-zero (>0) on failure, ${EXP_PKG_DISPATCH_NJOBS}, ${EXP_PKG_DISPATCH_COUNT}, ${EXP_PKG_NAMES}, and ${EX_PKG_DISPATCH_WAIT} may be mutated post-return.