summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xbuild.sh25
-rw-r--r--etc/build.usage7
-rw-r--r--subr/ex_pkg_dispatch.subr23
-rw-r--r--subr/ex_rtl_state.subr8
-rw-r--r--vars/midipix.vars1
5 files changed, 40 insertions, 24 deletions
diff --git a/build.sh b/build.sh
index c0986675..146ac4b2 100755
--- a/build.sh
+++ b/build.sh
@@ -4,7 +4,7 @@
buildp_dispatch() {
local _msg="${1}" _pkg_name="${2}" _tgt_name="${3}" \
- _build_tgt_meta="" _build_tgt_lc="" _build_tgt_pkg_names="" _build_tgt_uc="" _build_tgts_lc="";
+ _build_tgt_meta="" _build_tgt_lc="" _build_tgts_lc=""_pkg_restart="" _pkgs_found="";
case "${_msg}" in
# Top-level
start_build) shift; build_args "${@}"; build_init; build_checks;
@@ -15,26 +15,20 @@ buildp_dispatch() {
if ! ex_rtl_lmatch "${ARG_DIST}" , rpm; then
_build_tgts_lc="$(ex_rtl_lfilter_not "${_build_tgts_lc}" "host_tools_rpm")";
fi;
- if [ -n "${ARG_RESTART}" ]\
- && [ "${ARG_RESTART}" != ALL ]; then
- _build_tgt_pkg_names="";
- for _build_tgt_lc in ${_build_tgts_lc}; do
- _build_tgt_uc="$(ex_rtl_toupper "${_build_tgt_lc}")";
- _build_tgt_pkg_names="${_build_tgt_pkg_names:+${_build_tgt_pkg_names} }$(ex_rtl_get_var_unsafe ${_build_tgt_uc}_PACKAGES)";
- done;
- _build_tgt_pkg_names="$(ex_rtl_lfilter_not "${ARG_RESTART}" "${_build_tgt_pkg_names}")";
- if [ -n "${_build_tgt_pkg_names}" ]; then
- ex_rtl_log_msg failexit "Error: package(s) \`${_build_tgt_pkg_names}' unknown.";
- fi;
- fi;
for _build_tgt_lc in ${_build_tgts_lc}; do
ex_pkg_dispatch "${_build_tgt_lc}" \
"${ARG_RESTART}" "${ARG_RESTART_AT}" \
- buildp_dispatch;
+ buildp_dispatch _pkgs_found;
if [ ${?} -ne 0 ]; then
break;
fi;
done;
+ for _pkg_restart in ${ARG_RESTART}; do
+ if ! ex_rtl_lmatch "ALL LAST" " " "${_pkg_restart}" \
+ && ! ex_rtl_lmatch "${_pkgs_found}" " " "${_pkg_restart}"; then
+ ex_rtl_log_msg failexit "Error: package \`${_pkg_restart}' unknown.";
+ fi;
+ done;
if ! ex_pkg_dispatch "invariants" "ALL" "ALL" buildp_dispatch; then
break;
fi;
@@ -64,6 +58,9 @@ buildp_dispatch() {
else
ex_rtl_log_msg fail "${BUILD_WORKDIR}/${_pkg_name}_stderrout.log:";
cat "${BUILD_WORKDIR}/${_pkg_name}_stderrout.log";
+ if [ -n "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}" ]; then
+ echo "${_pkg_name}" > "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}";
+ fi;
ex_rtl_log_msg fail "Build failed in \`${_pkg_name}'.";
if [ "${ARG_PARALLEL:-0}" -eq 1 ]; then
ex_rtl_log_msg fail "Terminating pending builds...";
diff --git a/etc/build.usage b/etc/build.usage
index 8d46e768..b065e18e 100644
--- a/etc/build.usage
+++ b/etc/build.usage
@@ -1,5 +1,5 @@
usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..]]
- [-F ipv4|ipv6|offline] [-h] [-P [jobs]] [-r ALL|name[,..][:step,..]]
+ [-F ipv4|ipv6|offline] [-h] [-P [jobs]] [-r ALL|LAST|name[,..][:step,..]]
[-R] [-v[v[v[v]]]] [--as-needed] [--debug-minipix] [<target>[ ..]]
-a nt32|nt64 Selects 32-bit or 64-bit architecture; defaults to nt64.
-b debug|release Selects debug or release build; defaults to debug.
@@ -20,9 +20,10 @@ usage: ./build.sh [-a nt32|nt64] [-b debug|release] [-C dir[,..]] [-D kind[,..]]
processors on the host system.
If -R is not specified and at least one (1) package fails to build,
all remaining package builds will be forcibly aborted for convenience.
- -r ALL|name[,..][:step,..]
+ -r ALL[:step,..]|LAST|name[,..][:step,..]
Restart all packages/the specified comma-separated package(s)
- completely or at optionally specified comma-separated step(s).
+ completely or at optionally specified comma-separated step(s)
+ or restart the last failed package and resume build.
Currently defined steps are:
fetch_wget, fetch_git, fetch_extract,
configure_patch_pre, configure_autotools, configure_patch,
diff --git a/subr/ex_pkg_dispatch.subr b/subr/ex_pkg_dispatch.subr
index 8c774d7b..45653b4f 100644
--- a/subr/ex_pkg_dispatch.subr
+++ b/subr/ex_pkg_dispatch.subr
@@ -28,18 +28,25 @@ exp_pkg_dispatch() {
};
ex_pkg_dispatch() {
- local _tgt_name="${1}" _restart="${2}" _restart_at="${3}" \
- _dispatch_fn="${4}" _tgt_name_uc="" \
- _pkg_names="" _njob="" _njobs="" _njobs_max="" \
- _pipe_path="" _stderrout_path="" _pipe_msg="" _script_rc="";
+ local _tgt_name="${1}" _restart="${2}" _restart_at="${3}" _dispatch_fn="${4}" _pkgs_found_vname="${5}" \
+ _last_pkg="" _njob="" _njobs="" _njobs_max="" _pipe_msg="" _pipe_path="" \
+ _pkg_names="" _pkgs_found="" _script_rc="" _stderrout_path="" _tgt_name_uc="";
ex_rtl_fileop mkdir "${BUILD_WORKDIR}";
_pipe_path="${BUILD_WORKDIR}/build.fifo";
_tgt_name_uc="$(ex_rtl_toupper "${_tgt_name}")";
"${_dispatch_fn}" start_target "" "${_tgt_name}";
_pkg_names="$(ex_rtl_get_var_unsafe ${_tgt_name_uc}_PACKAGES)";
- if [ -n "${_restart}" ]\
- && [ "${_restart}" != ALL ]; then
- _pkg_names="$(ex_rtl_lfilter "${_pkg_names}" "${_restart}")";
+ if [ -n "${_restart}" ]; then
+ if [ "${_restart}" = "LAST" ]; then
+ if [ -n "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}" ]\
+ && [ -e "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}" ]; then
+ _last_pkg="$(cat "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}")";
+ ex_rtl_fileop rm "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}";
+ ex_rtl_state_clear "${BUILD_WORKDIR}" "${_last_pkg}";
+ fi;
+ elif [ "${_restart}" != "ALL" ]; then
+ _pkg_names="$(ex_rtl_lfilter "${_pkg_names}" "${_restart}")";
+ fi;
fi;
if [ "$(ex_rtl_get_var_unsafe ${_tgt_name_uc}_PARALLELISE)" = 1 ]\
&& [ "${ARG_PARALLEL:-0}" -gt 1 ]; then
@@ -55,6 +62,7 @@ ex_pkg_dispatch() {
if [ ${#} -eq 0 ]; then
break;
else
+ _pkgs_found="${_pkgs_found:+${_pkgs_found} }${1}";
exp_pkg_dispatch "${1}" "${_tgt_name}" \
"${_restart_at}" "${_dispatch_fn}" \
"${_stderrout_path}" "${_pipe_path}" \
@@ -93,6 +101,7 @@ ex_pkg_dispatch() {
fi;
done;
"${_dispatch_fn}" finish_target "" "${_tgt_name}";
+ ex_rtl_set_var_unsafe "${_pkgs_found_vname}" "${_pkgs_found}";
};
# vim:filetype=sh
diff --git a/subr/ex_rtl_state.subr b/subr/ex_rtl_state.subr
index fe52b29a..70e72a06 100644
--- a/subr/ex_rtl_state.subr
+++ b/subr/ex_rtl_state.subr
@@ -2,6 +2,14 @@
# set -o noglob is assumed.
#
+ex_rtl_state_clear() {
+ local _workdir="${1}" _pkg_name="${2}" _pkg_fname="";
+ for _pkg_fname in $(find "${_workdir}" \
+ -maxdepth 1 -mindepth 1 -name .${_pkg_name}.\* -type f); do
+ ex_rtl_fileop rm "${_pkg_fname}";
+ done;
+};
+
ex_rtl_state_set() {
local _workdir="${1}" _pkg_fname="${2}" _done_fname_pfx="";
_done_fname_pfx="${_workdir}/.${_pkg_fname}";
diff --git a/vars/midipix.vars b/vars/midipix.vars
index 4113c0e8..f7cbcd66 100644
--- a/vars/midipix.vars
+++ b/vars/midipix.vars
@@ -79,6 +79,7 @@
: ${DEFAULT_NATIVE_RANLIB:=${DEFAULT_TARGET}-ranlib};
# Build {log,status} & tarball names
+: ${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME:=${BUILD_WORKDIR}/last_failed_pkg};
: ${DEFAULT_BUILD_LOG_FNAME:=${PREFIX}/build.log};
: ${DEFAULT_BUILD_LOG_LAST_FNAME:=${PREFIX}/build.log.last};
: ${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME:=${PREFIX}/BUILD_IN_PROGRESS};