Conan_Kudo / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame subr/ex_pkg_state.subr

Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
#
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
# set -o errexit -o noglob are assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
#
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
ex_pkg_state_build_dir() {
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	PKG_BUILD_DIR="${1}-${2}-${PKG_TARGET}";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
};
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
ex_pkg_state_fini() {
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	: $((BUILD_TIMES_SECS=$(ex_date %s)-${BUILD_TIMES_SECS}));
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	: $((BUILD_TIMES_HOURS=${BUILD_TIMES_SECS}/3600));
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	: $((BUILD_TIMES_MINUTES=(${BUILD_TIMES_SECS}%3600)/60));
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	: $((BUILD_TIMES_SECS=(${BUILD_TIMES_SECS}%3600)%60));
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	if [ -f "${BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		ex_build_fileop rm ${BUILD_STATUS_IN_PROGRESS_FNAME};
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
};
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
ex_pkg_state_init() {
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	if [ -e ${BUILD_STATUS_IN_PROGRESS_FNAME} ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		ex_log_msg failexit "Error: another build targeting this architecture and build type is currently in progress.";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	else
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		touch ${BUILD_STATUS_IN_PROGRESS_FNAME};
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	if [ -e ${BUILD_LOG_FNAME} ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		mv -- ${BUILD_LOG_FNAME} ${BUILD_LOG_LAST_FNAME};
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	BUILD_DATE_START="$(ex_date %Y-%m-%d-%H-%M-%S)";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	BUILD_NFINI=${BUILD_NSKIP:=${BUILD_NFAIL:=${BUILD_NBUILT:=0}}};
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	BUILD_TIMES_SECS=$(ex_date %s);
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	BUILD_PKGS_FAILED="";
Lucio Andrés Illanes Albornoz (arab, vxp) fc9417
	trap "rm -f ${BUILD_STATUS_IN_PROGRESS_FNAME};		\
Lucio Andrés Illanes Albornoz (arab, vxp) fc9417
		ex_log_msg failexit \"Build aborted.\";"	\
Lucio Andrés Illanes Albornoz (arab, vxp) fc9417
		HUP INT TERM USR1 USR2;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
};
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
ex_pkg_state_push() {
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	local _pkg_fname="${1}";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	local _done_fname_pfx="${WORKDIR}/.${_pkg_fname}";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	shift; while [ ${#} -ge 1 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		if [ "${1#-}" != "${1}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
			ex_build_fileop rm "${_done_fname_pfx}.${1#-}";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		else
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
			touch "${_done_fname_pfx}.${1}";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
			ex_log_msg info "Finished build step ${1} of package \`${_pkg_fname}'.";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		fi; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
};
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
ex_pkg_state_test() {
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	local _done_fname="${WORKDIR}/.${1}.${2}" _restart_at="${3}";
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	if [ -z "${_restart_at}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		if [ -e "${_done_fname}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
			return 0;	# Skip
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		else
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
			return 1;	# Build
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	elif [ "${_restart_at}" = "ALL" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		return 1;		# Build
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	elif ex_lmatch "${_restart_at}" , "${2}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		return 1;		# Build
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	else
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
		return 0;		# Skip
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
};
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
# vim:filetype=sh