summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rwxr-xr-xbuild.sh4
-rw-r--r--subr/build.subr25
-rw-r--r--subr/pre_state.subr31
3 files changed, 33 insertions, 27 deletions
diff --git a/build.sh b/build.sh
index 5d213b85..20578262 100755
--- a/build.sh
+++ b/build.sh
@@ -4,7 +4,7 @@
for __ in $(find subr -name *.subr); do . "${__}"; done;
pre_setup_args "${@}"; pre_setup_env; pre_check; pre_subdirs;
-build_files_init; {(
+pre_state init; {(
log_msg info "Build started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE_START}.";
log_env_vars "build (global)" ${LOG_ENV_VARS};
for BUILD_TARGET_LC in $(subst_tgts invariants ${BUILD_TARGETS_META:-world}); do
@@ -34,7 +34,7 @@ for BUILD_TARGET_LC in $(subst_tgts invariants ${BUILD_TARGETS_META:-world}); do
if [ "${BUILD_SCRIPT_RC:-0}" -ne 0 ]; then
break;
fi;
-done; build_files_fini;
+done; pre_state fini;
log_msg info "${BUILD_NFINI} finished, ${BUILD_NSKIP} skipped, and ${BUILD_NFAIL} failed builds in ${BUILD_NBUILT} build script(s).";
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 ]\
diff --git a/subr/build.subr b/subr/build.subr
index b7341632..526d9f25 100644
--- a/subr/build.subr
+++ b/subr/build.subr
@@ -47,30 +47,6 @@ build_fileop() {
fi;
};
-build_files_fini() {
- : $((BUILD_TIMES_SECS=$(command date +%s)-${BUILD_TIMES_SECS}));
- : $((BUILD_TIMES_HOURS=${BUILD_TIMES_SECS}/3600));
- : $((BUILD_TIMES_MINUTES=(${BUILD_TIMES_SECS}%3600)/60));
- : $((BUILD_TIMES_SECS=(${BUILD_TIMES_SECS}%3600)%60));
- if [ -f "${BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then
- build_fileop rm ${BUILD_STATUS_IN_PROGRESS_FNAME};
- fi;
-};
-build_files_init() {
- if [ -e ${BUILD_STATUS_IN_PROGRESS_FNAME} ]; then
- log_msg failexit "Error: another build targeting this architecture and build type is currently in progress.";
- else
- touch ${BUILD_STATUS_IN_PROGRESS_FNAME};
- fi;
- if [ -e ${BUILD_LOG_FNAME} ]; then
- mv -- ${BUILD_LOG_FNAME} ${BUILD_LOG_LAST_FNAME};
- fi;
- BUILD_DATE_START="$(date %Y-%m-%d-%H-%M-%S)";
- BUILD_NFINI=${BUILD_NSKIP:=${BUILD_NFAIL:=${BUILD_NBUILT:=0}}};
- BUILD_TIMES_SECS=$(command date +%s);
- BUILD_PKGS_FAILED="";
-};
-
is_build_script_done() {
local _done_fname="${WORKDIR}/.${1}.${2}" _restart_at="${3}";
if [ -z "${_restart_at}" ]; then
@@ -87,7 +63,6 @@ is_build_script_done() {
return 0; # Skip
fi;
};
-
set_build_script_done() {
local _pkg_fname="${1}";
local _done_fname_pfx="${WORKDIR}/.${_pkg_fname}";
diff --git a/subr/pre_state.subr b/subr/pre_state.subr
new file mode 100644
index 00000000..58bfc59a
--- /dev/null
+++ b/subr/pre_state.subr
@@ -0,0 +1,31 @@
+#
+# set -o errexit -o noglob are assumed.
+#
+
+pre_state() {
+ case "${1}" in
+ fini) : $((BUILD_TIMES_SECS=$(command date +%s)-${BUILD_TIMES_SECS}));
+ : $((BUILD_TIMES_HOURS=${BUILD_TIMES_SECS}/3600));
+ : $((BUILD_TIMES_MINUTES=(${BUILD_TIMES_SECS}%3600)/60));
+ : $((BUILD_TIMES_SECS=(${BUILD_TIMES_SECS}%3600)%60));
+ if [ -f "${BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then
+ build_fileop rm ${BUILD_STATUS_IN_PROGRESS_FNAME};
+ fi;
+ ;;
+ init) if [ -e ${BUILD_STATUS_IN_PROGRESS_FNAME} ]; then
+ log_msg failexit "Error: another build targeting this architecture and build type is currently in progress.";
+ else
+ touch ${BUILD_STATUS_IN_PROGRESS_FNAME};
+ fi;
+ if [ -e ${BUILD_LOG_FNAME} ]; then
+ mv -- ${BUILD_LOG_FNAME} ${BUILD_LOG_LAST_FNAME};
+ fi;
+ BUILD_DATE_START="$(date %Y-%m-%d-%H-%M-%S)";
+ BUILD_NFINI=${BUILD_NSKIP:=${BUILD_NFAIL:=${BUILD_NBUILT:=0}}};
+ BUILD_TIMES_SECS=$(command date +%s);
+ BUILD_PKGS_FAILED="";
+ ;;
+ esac;
+};
+
+# vim:filetype=sh