Conan_Kudo / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame subr/ex_pkg_exec.subr

Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
#
Lucio Andrés Illanes Albornoz e1d469
# set +o errexit -o noglob -o nounset is assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
#
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
Lucio Andrés Illanes Albornoz 8a27f9
exp_pkg_exec_filter_vars_fn() {
Lucio Andrés Illanes Albornoz 8a27f9
	local _vname="${1}";
Lucio Andrés Illanes Albornoz 8a27f9
	case "${_vname}" in
Lucio Andrés Illanes Albornoz 8a27f9
	DEFAULT|PKG_*)
Lucio Andrés Illanes Albornoz 8a27f9
		return 0; ;;
Lucio Andrés Illanes Albornoz 8a27f9
	BUILD_DLCACHEDIR|BUILD_WORKDIR|MIDIPIX_BUILD_PWD)
Lucio Andrés Illanes Albornoz 8a27f9
		return 0; ;;
Lucio Andrés Illanes Albornoz 8a27f9
	CONFIG_CACHE_GNULIB)
Lucio Andrés Illanes Albornoz 8a27f9
		return 0; ;;
Lucio Andrés Illanes Albornoz 8a27f9
	PREFIX|PREFIX_CROSS|PREFIX_MINGW32|PREFIX_MINIPIX|PREFIX_NATIVE|PREFIX_RPM)
Lucio Andrés Illanes Albornoz 8a27f9
		return 0; ;;
Lucio Andrés Illanes Albornoz 8a27f9
	*)	return 1; ;;
Lucio Andrés Illanes Albornoz 8a27f9
	esac;
Lucio Andrés Illanes Albornoz 8a27f9
};
Lucio Andrés Illanes Albornoz 8a27f9
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz 2b85d0
# exp_pkg_exec_pre() - XXX
Lucio Andrés Illanes Albornoz 2b85d0
# @_group_name:		build group name
Lucio Andrés Illanes Albornoz 2b85d0
# @_pkg_name:		single package name
Lucio Andrés Illanes Albornoz 2b85d0
# @_restart_at:		optional comma-separated list of build steps at which to rebuild or ALL
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz 2b85d0
# Return:		zero (0) on success, non-zero (>0) on failure
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
exp_pkg_exec_pre() {
Lucio Andrés Illanes Albornoz b96c60
	local _group_name="${1}" _pkg_name="${2}" _restart_at="${3}";
Lucio Andrés Illanes Albornoz e1d469
	if [ -z "${PKG_URL:-}" ]\
Lucio Andrés Illanes Albornoz e1d469
	&& [ -z "${PKG_URLS_GIT:-}" ]\
Lucio Andrés Illanes Albornoz e1d469
	&& [ -z "${PKG_VERSION:-}" ]\
Lucio Andrés Illanes Albornoz c6d6e0
	&& ! rtl_test_cmd "pkg_${_pkg_name}_all"; then
Lucio Andrés Illanes Albornoz c6d6e0
		"${_dispatch_fn}" missing_pkg "${_group_name}" "${_pkg_name}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		return 1;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	elif ! ex_pkg_state_test "${_pkg_name}" "start" "${_restart_at}"; then
Lucio Andrés Illanes Albornoz 2b85d0
		if [ "${PKG_NO_CLEAN_BASE_DIR:-0}" -eq 0 ]\
Lucio Andrés Illanes Albornoz 8a4e16
		&& ! rtl_fileop rm "${PKG_BASE_DIR}" "${PKG_BUILD_DIR}" "${PKG_DESTDIR}" "${PKG_DESTDIR_HOST}"\
Lucio Andrés Illanes Albornoz c6d6e0
		|| ! rtl_fileop mkdir "${PKG_BASE_DIR}"; then
Lucio Andrés Illanes Albornoz bf9edf
			return 1;
Lucio Andrés Illanes Albornoz 2b85d0
		fi;
Lucio Andrés Illanes Albornoz c6d6e0
		if ! rtl_fileop mkdir "${PKG_BUILD_DIR}" "${PKG_DESTDIR}"\
Lucio Andrés Illanes Albornoz 2b85d0
		|| ! ex_pkg_state_set "${_pkg_name}" "start"; then
Lucio Andrés Illanes Albornoz bf9edf
			return 1;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	fi;
Lucio Andrés Illanes Albornoz c6d6e0
	rtl_fileop cd "${PKG_BUILD_DIR}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
};
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz 2b85d0
# exp_pkg_exec_step() - XXX
Lucio Andrés Illanes Albornoz 2b85d0
# @_group_name:		build group name
Lucio Andrés Illanes Albornoz 2b85d0
# @_pkg_name:		single package name
Lucio Andrés Illanes Albornoz 2b85d0
# @_restart_at:		optional comma-separated list of build steps at which to rebuild or ALL
Lucio Andrés Illanes Albornoz 2b85d0
# @_step:		build step to execute
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz 2b85d0
# Return:		zero (0) on success, non-zero (>0) on failure
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz 2b85d0
exp_pkg_exec_step() {
Lucio Andrés Illanes Albornoz 2b85d0
	local	_group_name="${1}" _pkg_name="${2}" _restart_at="${3}" _step="${4}"	\
Lucio Andrés Illanes Albornoz 2b85d0
		_fn_name="" _pkg_step_fn="" _rc=0;
Lucio Andrés Illanes Albornoz c6d6e0
	if rtl_test_cmd "pkg_${_pkg_name}_${_step}"; then
Lucio Andrés Illanes Albornoz 2b85d0
		_pkg_step_fn="pkg_${_pkg_name}_${_step}";
Lucio Andrés Illanes Albornoz 2b85d0
	else
Lucio Andrés Illanes Albornoz 2b85d0
		_pkg_step_fn="pkg_${_step}";
Lucio Andrés Illanes Albornoz 2b85d0
	fi;
Lucio Andrés Illanes Albornoz 2b85d0
	for _fn_name in \
Lucio Andrés Illanes Albornoz 2b85d0
			"pkg_${_pkg_name}_${_step}_pre"	\
Lucio Andrés Illanes Albornoz 2b85d0
			"${_pkg_step_fn}"		\
Lucio Andrés Illanes Albornoz 2b85d0
			"pkg_${_pkg_name}_${_step}_post"; do
Lucio Andrés Illanes Albornoz c6d6e0
		if rtl_test_cmd "${_fn_name}"\
Lucio Andrés Illanes Albornoz 2b85d0
		&& ! "${_fn_name}" "${_group_name}" "${_pkg_name}" "${_restart_at}"; then
Lucio Andrés Illanes Albornoz 2b85d0
			_rc=1; break;
Lucio Andrés Illanes Albornoz 2b85d0
		fi;
Lucio Andrés Illanes Albornoz 2b85d0
	done;
Lucio Andrés Illanes Albornoz 2b85d0
	return "${_rc}";
Lucio Andrés Illanes Albornoz 2b85d0
};
Lucio Andrés Illanes Albornoz 2b85d0
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz 2b85d0
# exp_pkg_exec() - XXX
Lucio Andrés Illanes Albornoz 2b85d0
# @_dispatch_fn:	top-level dispatch function name
Lucio Andrés Illanes Albornoz 2b85d0
# @_group_name:		build group name
Lucio Andrés Illanes Albornoz 2b85d0
# @_pkg_name:		single package name
Lucio Andrés Illanes Albornoz 2b85d0
# @_restart_at:		optional comma-separated list of build steps at which to rebuild or ALL
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz 2b85d0
# Return:		zero (0) on success, non-zero (>0) on failure
Lucio Andrés Illanes Albornoz 2b85d0
#
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
ex_pkg_exec() {
Lucio Andrés Illanes Albornoz 2b85d0
	local	_dispatch_fn="${1}" _group_name="${2}" _pkg_name="${3}" _restart_at="${4}"	\
Lucio Andrés Illanes Albornoz 2b85d0
		_rc=0 _step="" _step_next="";
Lucio Andrés Illanes Albornoz 2b85d0
	if exp_pkg_exec_pre "${_group_name}" "${_pkg_name}" "${_restart_at}"\
Lucio Andrés Illanes Albornoz c6d6e0
	&& "${_dispatch_fn}" start_pkg_child "${_group_name}" "${_pkg_name}"; then
Lucio Andrés Illanes Albornoz c6d6e0
		if rtl_test_cmd "pkg_${_pkg_name}_all"; then
Lucio Andrés Illanes Albornoz dda17d
			"pkg_${_pkg_name}_all" "${_restart_at}"; _rc="${?}";
Lucio Andrés Illanes Albornoz 2b85d0
		else	set -- ${PKG_BUILD_STEPS};
Lucio Andrés Illanes Albornoz 2b85d0
			while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz e1d469
				_step="${1}"; _step_next="${2:-}"; shift;
Lucio Andrés Illanes Albornoz f243be
				if [ "${ARG_DUMP_IN}" = "${_step}" ]; then
Lucio Andrés Illanes Albornoz f243be
					printf "" > "${BUILD_WORKDIR}/${_pkg_name}.dump";
Lucio Andrés Illanes Albornoz f243be
					rtl_filter_vars exp_pkg_exec_filter_vars_fn >> "${BUILD_WORKDIR}/${_pkg_name}.dump";
Lucio Andrés Illanes Albornoz f243be
					export >> "${BUILD_WORKDIR}/${_pkg_name}.dump";
Lucio Andrés Illanes Albornoz f243be
					exit 1;
Lucio Andrés Illanes Albornoz f243be
				elif [ "${PKG_FORCE:-0}" -eq 0 ]\
Lucio Andrés Illanes Albornoz c6d6e0
				&& ex_pkg_state_test "${_pkg_name}" "${_step}" "${_restart_at}"	; then
Lucio Andrés Illanes Albornoz 2b85d0
					continue;
Lucio Andrés Illanes Albornoz 2b85d0
				elif ! exp_pkg_exec_step "${_group_name}" "${_pkg_name}" "${_restart_at}" "${_step}"; then
Lucio Andrés Illanes Albornoz 2b85d0
					_rc=1; break;
Lucio Andrés Illanes Albornoz (arab, vxp) fce0a9
				else
Lucio Andrés Illanes Albornoz b6a9a1
					printf "step %s %s %s\n" "${_group_name}" "${_pkg_name}" "${_step}" >&3;
Lucio Andrés Illanes Albornoz 2b85d0
					ex_pkg_state_set "${_pkg_name}" "${_step}" "${_step_next:+-${_step_next}}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
				fi;
Lucio Andrés Illanes Albornoz 2b85d0
			done;
Lucio Andrés Illanes Albornoz 2b85d0
		fi;
Lucio Andrés Illanes Albornoz bf9edf
		if [ "${_rc:-0}" -eq 0 ]; then
Lucio Andrés Illanes Albornoz bf9edf
			if [ -z "${_restart_at}" ]\
Lucio Andrés Illanes Albornoz bf9edf
			|| [ "${_restart_at}" = "ALL" ]; then
Lucio Andrés Illanes Albornoz bf9edf
				ex_pkg_state_set "${_pkg_name}" finish;
Lucio Andrés Illanes Albornoz bf9edf
			fi;
Lucio Andrés Illanes Albornoz 8a27f9
		elif [ "${_rc:-0}" -ne 0 ]\
Lucio Andrés Illanes Albornoz 8a27f9
		&&   [ "${ARG_DUMP_ON_ABORT:-0}" -eq 1 ]; then
Lucio Andrés Illanes Albornoz 8a27f9
			printf "" > "${BUILD_WORKDIR}/${_pkg_name}.dump";
Lucio Andrés Illanes Albornoz 8a27f9
			rtl_filter_vars exp_pkg_exec_filter_vars_fn >> "${BUILD_WORKDIR}/${_pkg_name}.dump";
Lucio Andrés Illanes Albornoz 8a27f9
			export >> "${BUILD_WORKDIR}/${_pkg_name}.dump";
Lucio Andrés Illanes Albornoz dda17d
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	fi;
Lucio Andrés Illanes Albornoz 2b85d0
	return "${_rc}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
};
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
# vim:filetype=sh