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) 820be1
#
Lucio Andrés Illanes Albornoz (arab, vxp) bd97b6
#
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
#
Lucio Andrés Illanes Albornoz (arab, vxp) 1fb552
for __ in subr/*.subr; do . "${__}"; done;
Lucio Andrés Illanes Albornoz (arab, vxp) 0981c3
set -o noglob;
Lucio Andrés Illanes Albornoz (arab, vxp) 090fd4
while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) 6e48a0
case ${1} in
Lucio Andrés Illanes Albornoz (arab, vxp) f3562b
-4)	ARG_IPV4_ONLY=1; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) f3562b
-6)	ARG_IPV6_ONLY=1; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 6e313c
-c)	ARG_CLEAN=1; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 6e313c
-N)	ARG_OFFLINE=1; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) a0561a
-i)	ARG_IGNORE_SHA256SUMS=1; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) a0f521
-R)	ARG_RELAXED=1; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 7b01b5
--debug-minipix)
Lucio Andrés Illanes Albornoz (arab, vxp) 7b01b5
	ARG_DEBUG_MINIPIX=1; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 1fb552
-t*)	ARG_TARBALL=1; [ "${1#-t.}" != "${1}" ] && TARBALL_SUFFIX="${1#-t.}"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 6e313c
-v)	ARG_VERBOSE=1; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 6e313c
-x)	ARG_XTRACE=1; set -o xtrace; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 1fb552
-a)	[ -z "${2}" ] && exec cat etc/build.usage || ARCH="${2}"; shift; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 1fb552
-b)	[ -z "${2}" ] && exec cat etc/build.usage || BUILD="${2}"; shift; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 59765f
-r)	if [ -z "${2}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 49ffbe
		exec cat build.usage;
Lucio Andrés Illanes Albornoz (arab, vxp) 59765f
	elif [ "${2%:*}" = "${2}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1fb552
		ARG_RESTART="${2}";
Lucio Andrés Illanes Albornoz (arab, vxp) 59765f
	else
Lucio Andrés Illanes Albornoz (arab, vxp) 1fb552
		ARG_RESTART="${2%:*}"; ARG_RESTART_AT="${2#*:}";
Lucio Andrés Illanes Albornoz (arab, vxp) a0561a
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 0981c3
	BUILD_PACKAGES_RESTART="$(echo ${ARG_RESTART} | sed "s/,/ /g")";
Lucio Andrés Illanes Albornoz (arab, vxp) 802215
	shift; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 820be1
*=*)	set_var_unsafe "${1%%=*}" "${1#*=}"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 49b460
*)	if lmatch "${1}" " " "${ALL_TARGETS}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) 49b460
		BUILD_TARGETS_META="${BUILD_TARGETS_META:+${BUILD_TARGETS_META} }${1}";
Lucio Andrés Illanes Albornoz (arab, vxp) 49b460
	else
Lucio Andrés Illanes Albornoz (arab, vxp) 49b460
		exec cat etc/build.usage;
Lucio Andrés Illanes Albornoz (arab, vxp) 49b460
	fi; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) e2fea1
esac; shift; done;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
pre_setup_env; pre_check; pre_subdirs; build_files_init;
Lucio Andrés Illanes Albornoz (arab, vxp) bd97b6
Lucio Andrés Illanes Albornoz (arab, vxp) bd97b6
#
Lucio Andrés Illanes Albornoz (arab, vxp) bd97b6
#
Lucio Andrés Illanes Albornoz (arab, vxp) bd97b6
#
Lucio Andrés Illanes Albornoz (arab, vxp) bd97b6
{(
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
log_msg info "Build started by ${BUILD_USER:=${USER}}@${BUILD_HNAME:=$(hostname)} at ${BUILD_DATE_START}.";
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
log_env_vars "build (global)" ${LOG_ENV_VARS};
Lucio Andrés Illanes Albornoz (arab, vxp) bd97b6
for BUILD_TARGET_LC in $(subst_tgts invariants ${BUILD_TARGETS_META:-world}); do
Lucio Andrés Illanes Albornoz (arab, vxp) 49b460
	BUILD_TARGET="$(toupper "${BUILD_TARGET_LC}")";
Lucio Andrés Illanes Albornoz (arab, vxp) 1fb552
	BUILD_PACKAGES="$(get_var_unsafe ${BUILD_TARGET}_PACKAGES)";
Lucio Andrés Illanes Albornoz (arab, vxp) 0981c3
	if [ "${BUILD_TARGET}" != "INVARIANTS" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 0981c3
	&& [ -n "${BUILD_PACKAGES_RESTART}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 0981c3
		BUILD_PACKAGES="$(lfilter "${BUILD_PACKAGES}" "${BUILD_PACKAGES_RESTART}")";
Lucio Andrés Illanes Albornoz (arab, vxp) 0981c3
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 802215
	for PKG_NAME in ${BUILD_PACKAGES}; do
Lucio Andrés Illanes Albornoz (arab, vxp) 1da591
		pkg_setup_dispatch "${BUILD_TARGET}" "${PKG_NAME}" "${ARG_RESTART}" "${ARG_RESTART_AT}";
Lucio Andrés Illanes Albornoz (arab, vxp) 1fb552
		case "${BUILD_SCRIPT_RC:=${?}}" in
Lucio Andrés Illanes Albornoz (arab, vxp) 802215
		0) log_msg succ "Finished \`${PKG_NAME}' build.";
Lucio Andrés Illanes Albornoz (arab, vxp) 59765f
			: $((BUILD_NFINI+=1)); continue; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 802215
		*) log_msg fail "Build failed in \`${PKG_NAME}' (last return code ${BUILD_SCRIPT_RC}.).";
Lucio Andrés Illanes Albornoz (arab, vxp) a0f521
			: $((BUILD_NFAIL+=1));
Lucio Andrés Illanes Albornoz (arab, vxp) ceeb88
			if [ ${ARG_RELAXED:-0} -eq 1 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ceeb88
				BUILD_PKGS_FAILED="${BUILD_PKGS_FAILED:+${BUILD_PKGS_FAILED} }${PKG_NAME}";
Lucio Andrés Illanes Albornoz (arab, vxp) ceeb88
				continue;
Lucio Andrés Illanes Albornoz (arab, vxp) ceeb88
			else
Lucio Andrés Illanes Albornoz (arab, vxp) ceeb88
				break;
Lucio Andrés Illanes Albornoz (arab, vxp) ceeb88
			fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 59765f
		esac;
lalbornoz 340f4c
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) 1fb552
	if [ "${BUILD_SCRIPT_RC:-0}" -ne 0 ]; then
lalbornoz 340f4c
		break;
lalbornoz 340f4c
	fi;
lalbornoz 340f4c
done;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
build_files_fini;
Lucio Andrés Illanes Albornoz (arab, vxp) 96b309
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) 820be1
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) ceeb88
	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) e2a4f2
trap "rm -f ${BUILD_STATUS_IN_PROGRESS_FNAME};	\
Lucio Andrés Illanes Albornoz (arab, vxp) e2a4f2
	log_msg fail \"Build aborted.\";	\
Lucio Andrés Illanes Albornoz (arab, vxp) e2a4f2
	echo kill ${TEE_PID};			\
Lucio Andrés Illanes Albornoz (arab, vxp) e2a4f2
	kill ${TEE_PID}" HUP INT TERM USR1 USR2;
Lucio Andrés Illanes Albornoz (arab, vxp) e2a4f2
wait;
lalbornoz 340f4c
lalbornoz 340f4c
# vim:filetype=sh