midipix / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame build.sh

lalbornoz 340f4c
#!/bin/sh
Lucio Andrés Illanes Albornoz (arab, vxp) a39ccb
# Copyright (c) 2016, 2017 Lucio Andrés Illanes Albornoz <lucio@lucioillanes.de>
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
#
Lucio Andrés Illanes Albornoz (arab, vxp) 090fd4
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
for __ in $(find subr -name *.subr); do . "${__}"; done;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
ex_setup_args "${@}"; ex_setup_env; ex_setup_checks; ex_setup_subdirs;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
ex_pkg_state_init; {(
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
ex_log_msg info "Build started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE_START}.";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
ex_log_env_vars "build (global)" ${LOG_ENV_VARS};
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
for BUILD_TARGET_META in invariants ${BUILD_TARGETS_META:-world}; do
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	for BUILD_TARGET_LC in $(ex_get_var_unsafe "$(ex_toupper "${BUILD_TARGET_META}")_TARGET"); do
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		BUILD_TARGET="$(ex_toupper "${BUILD_TARGET_LC}")";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		BUILD_PACKAGES="$(ex_get_var_unsafe ${BUILD_TARGET}_PACKAGES)";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		if [ "${BUILD_TARGET}" != "INVARIANTS" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		&& [ -n "${BUILD_PACKAGES_RESTART}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
			BUILD_PACKAGES="$(ex_lfilter "${BUILD_PACKAGES}" "${BUILD_PACKAGES_RESTART}")";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		for PKG_NAME in ${BUILD_PACKAGES}; do
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
			ex_pkg_dispatch "${BUILD_TARGET}" "${PKG_NAME}"	\
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
				"${ARG_RESTART}" "${ARG_RESTART_AT}";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
			BUILD_SCRIPT_RC=${?};
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
			case ${BUILD_SCRIPT_RC} in
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
			0) ex_log_msg succ "Finished \`${PKG_NAME}' build.";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
				: $((BUILD_NFINI+=1)); continue; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
			*) ex_log_msg fail "Build failed in \`${PKG_NAME}' (last return code ${BUILD_SCRIPT_RC}.).";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
				: $((BUILD_NFAIL+=1));
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
				if [ ${ARG_RELAXED:-0} -eq 1 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
					BUILD_PKGS_FAILED="${BUILD_PKGS_FAILED:+${BUILD_PKGS_FAILED} }${PKG_NAME}";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
					continue;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
				else
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
					break;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
				fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
			esac;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		done;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		if [ "${BUILD_SCRIPT_RC:-0}" -ne 0 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
			break;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		fi;
lalbornoz 340f4c
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
done; ex_pkg_state_fini;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
ex_log_msg info "${BUILD_NFINI} finished, ${BUILD_NSKIP} skipped, and ${BUILD_NFAIL} failed builds in ${BUILD_NBUILT} build script(s).";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
ex_log_msg info "Build time: ${BUILD_TIMES_HOURS} hour(s), ${BUILD_TIMES_MINUTES} minute(s), and ${BUILD_TIMES_SECS} second(s).";
Lucio Andrés Illanes Albornoz (arab, vxp) ceeb88
if [ ${ARG_RELAXED:-0} -eq 1 ]\
Lucio Andrés Illanes Albornoz (arab, vxp) ceeb88
&& [ -n "${BUILD_PKGS_FAILED}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	ex_log_msg info "Build script failure(s) in: ${BUILD_PKGS_FAILED}.";
Lucio Andrés Illanes Albornoz (arab, vxp) ceeb88
fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 49b460
exit "${BUILD_SCRIPT_RC:-0}")} 2>&1 | tee "${BUILD_LOG_FNAME}" & TEE_PID="${!}";
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
Lucio Andrés Illanes Albornoz (arab, vxp) e2a4f2
trap "rm -f ${BUILD_STATUS_IN_PROGRESS_FNAME};	\
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	ex_log_msg fail \"Build aborted.\";	\
Lucio Andrés Illanes Albornoz (arab, vxp) e2a4f2
	echo kill ${TEE_PID};			\
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	kill ${TEE_PID}" HUP INT TERM USR1 USR2; wait;
lalbornoz 340f4c
lalbornoz 340f4c
# vim:filetype=sh