midipix / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame subr/ex_pkg_env.subr

Lucio Andrés Illanes Albornoz (arab, vxp) 570129
#
Lucio Andrés Illanes Albornoz (arab, vxp) 802215
# set -o errexit -o noglob are assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
#
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
exp_pkg_env_source() {
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	local _pkg_name="${1}" _tgt_name="${2}"				\
Lucio Andrés Illanes Albornoz (arab, vxp) 0ddc1e
		_tgt_name_uc _pkg_name_uc _pkg_name_inherit_uc		\
Lucio Andrés Illanes Albornoz (arab, vxp) 0ddc1e
		_build_type_uc _vname_dst _vars_set="";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	ex_rtl_fileop source_opt "vars/${_pkg_name}.vars";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	_tgt_name_uc="$(ex_rtl_toupper "${_tgt_name}")";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	_pkg_name_uc="$(ex_rtl_toupper "${_pkg_name}")";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	ex_rtl_set_vars BUILD_TYPE					\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		"DEFAULT ${_tgt_name_uc} PKG_${_pkg_name_uc}"		\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		_vars_set;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	_build_type_uc="$(ex_rtl_toupper "${PKG_BUILD_TYPE}")";
Lucio Andrés Illanes Albornoz (arab, vxp) 0ddc1e
	ex_rtl_set_vars INHERIT_FROM "PKG_${_pkg_name_uc}" _vars_set;
Lucio Andrés Illanes Albornoz (arab, vxp) 0ddc1e
	_pkg_name_inherit_uc="$(ex_rtl_toupper "${PKG_INHERIT_FROM}")";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	for _vname_dst in $(ex_rtl_lfilter_not				\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			"${DEFAULT_BUILD_VARS}" BUILD_TYPE); do
Lucio Andrés Illanes Albornoz (arab, vxp) 0ddc1e
		if [ -n "${_pkg_name_inherit_uc}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 0ddc1e
			ex_rtl_set_vars "${_vname_dst}"			\
Lucio Andrés Illanes Albornoz (arab, vxp) 0ddc1e
				"DEFAULT DEFAULT_${_build_type_uc}	\
Lucio Andrés Illanes Albornoz (arab, vxp) 0ddc1e
				${_tgt_name_uc}				\
Lucio Andrés Illanes Albornoz (arab, vxp) 0ddc1e
				PKG_${_pkg_name_inherit_uc}		\
Lucio Andrés Illanes Albornoz (arab, vxp) 0ddc1e
				PKG_${_pkg_name_uc}" _vars_set;
Lucio Andrés Illanes Albornoz (arab, vxp) 0ddc1e
		else
Lucio Andrés Illanes Albornoz (arab, vxp) 0ddc1e
			ex_rtl_set_vars "${_vname_dst}"			\
Lucio Andrés Illanes Albornoz (arab, vxp) 0ddc1e
				"DEFAULT DEFAULT_${_build_type_uc}	\
Lucio Andrés Illanes Albornoz (arab, vxp) 0ddc1e
				${_tgt_name_uc} PKG_${_pkg_name_uc}"	\
Lucio Andrés Illanes Albornoz (arab, vxp) 0ddc1e
				_vars_set;
Lucio Andrés Illanes Albornoz (arab, vxp) 0ddc1e
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	ex_rtl_unset_vars $(ex_rtl_lfilter_not				\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		"$(set | awk -F= '/^PKG_/{print $1}' | sort)"		\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		"${_vars_set}");
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
};
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
ex_pkg_env() {
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	local _pkg_name="${1}" _tgt_name="${2}" _restart_at="${3}" _vname;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	exp_pkg_env_source "${_pkg_name}" "${_tgt_name}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	: ${PKG_NAME:="${_pkg_name}"};
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	: ${MIDIPIX_BUILD_PWD:="$(pwd)"};
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	: ${PKG_BASE_DIR:="${BUILD_WORKDIR}/${_pkg_name}-${PKG_BUILD_TYPE}-${PKG_TARGET}"};
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	: ${PKG_FNAME:="${PKG_URL##*/}"};
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	: ${PKG_BUILD_STEPS:="$(ex_rtl_lfilter_not "${DEFAULT_BUILD_STEPS}"		\
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		"${PKG_BUILD_STEPS_DISABLE}")"};
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	if [ -z "${PKG_SUBDIR}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		if [ -n "${PKG_URLS_GIT}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			PKG_SUBDIR="${PKG_URLS_GIT%%=*}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		else case "${PKG_FNAME}" in
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		*.t*)	PKG_SUBDIR="${PKG_FNAME%%.t*}"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		*)	PKG_SUBDIR="${_pkg_name}"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		esac; fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	if [ -z "${PKG_BUILD_DIR}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		case "${PKG_IN_TREE:-0}" in
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		0) PKG_BUILD_DIR="obj"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		1) PKG_BUILD_DIR="${PKG_SUBDIR}"; ;; 
Lucio Andrés Illanes Albornoz (arab, vxp) d18b1a
		esac;
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	PKG_BUILD_DIR="${PKG_BASE_DIR}/${PKG_BUILD_DIR}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	PKG_CONFIGURE="${PKG_BASE_DIR}/${PKG_CONFIGURE:-${PKG_SUBDIR}/configure}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	PKG_DESTDIR="${PKG_BASE_DIR}/${PKG_DESTDIR:-destdir}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	ex_rtl_push_IFS :; for _vname in ${PKG_ENV_VARS_EXTRA}; do
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		export "${_vname}";
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	done; ex_rtl_pop_IFS;
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
};
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
ex_pkg_state_set() { ex_rtl_state_set "${BUILD_WORKDIR}" "${@}"; };
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
ex_pkg_state_test() { ex_rtl_state_test "${BUILD_WORKDIR}" "${@}"; };
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
Lucio Andrés Illanes Albornoz (arab, vxp) 570129
# vim:filetype=sh