Blame subr/ex_pkg.subr

Lucio Andrés Illanes Albornoz c6d6e0
#
Lucio Andrés Illanes Albornoz e1d469
# set +o errexit -o noglob -o nounset is assumed.
Lucio Andrés Illanes Albornoz c6d6e0
#
Lucio Andrés Illanes Albornoz c6d6e0
Lucio Andrés Illanes Albornoz c6d6e0
#
Lucio Andrés Illanes Albornoz c6d6e0
# ex_pkg_check_depends() - check single named package for unsatisfied dependencies
Lucio Andrés Illanes Albornoz b6a9a1
# @_checkfl:		enable (1) or inhibit (0) dependency expansion
Lucio Andrés Illanes Albornoz 60fba6
# @_pkg_disabled:	list of disabled packages
Lucio Andrés Illanes Albornoz 60fba6
# @_pkg_finished:	list of finished packages
Lucio Andrés Illanes Albornoz c6d6e0
# @_pkg_name:		single package name
Lucio Andrés Illanes Albornoz c6d6e0
# @_pkg_wait:		list of in-progress packages
Lucio Andrés Illanes Albornoz c6d6e0
#
Lucio Andrés Illanes Albornoz c6d6e0
# Return:		zero (0) given no outstanding dependencies, non-zero (>0) otherwise
Lucio Andrés Illanes Albornoz c6d6e0
#
Lucio Andrés Illanes Albornoz c6d6e0
ex_pkg_check_depends() {
Lucio Andrés Illanes Albornoz b6a9a1
	local	_checkfl="${1}" _pkg_disabled="${2}" _pkg_finished="${3}" _pkg_name="${4}" _pkg_wait="${5}"\
Lucio Andrés Illanes Albornoz b6a9a1
		_dependfl=0 _pkg_depends="" _pkg_name_depend="";
Lucio Andrés Illanes Albornoz b6a9a1
	if [ "${_checkfl:-0}" -eq 1 ]\
Lucio Andrés Illanes Albornoz b6a9a1
	&& _pkg_depends="$(rtl_uniq $(rtl_lunfold_depends 'PKG_${_name}_DEPENDS' $(rtl_get_var_unsafe -u "PKG_"${_pkg_name}"_DEPENDS")))"; then
Lucio Andrés Illanes Albornoz b6a9a1
		for _pkg_name_depend in $(rtl_uniq ${_pkg_depends}); do
Lucio Andrés Illanes Albornoz b6a9a1
			if ! rtl_lmatch "${_pkg_disabled}" "${_pkg_name_depend}"\
Lucio Andrés Illanes Albornoz b6a9a1
			&& ! rtl_lmatch "${_pkg_finished}" "${_pkg_name_depend}"; then
Lucio Andrés Illanes Albornoz b6a9a1
				_dependfl=1; break;
Lucio Andrés Illanes Albornoz b6a9a1
			elif rtl_lmatch "${_pkg_wait}" "${_pkg_name_depend}"; then
Lucio Andrés Illanes Albornoz b6a9a1
				_dependfl=1; break;
Lucio Andrés Illanes Albornoz b6a9a1
			fi;
Lucio Andrés Illanes Albornoz b6a9a1
		done;
Lucio Andrés Illanes Albornoz c6d6e0
	fi;
Lucio Andrés Illanes Albornoz c6d6e0
	return "${_dependfl}";
Lucio Andrés Illanes Albornoz c6d6e0
};
Lucio Andrés Illanes Albornoz c6d6e0
Lucio Andrés Illanes Albornoz c6d6e0
#
Lucio Andrés Illanes Albornoz 60fba6
# ex_pkg_find_package() - find build group a single named package belongs to
Lucio Andrés Illanes Albornoz 60fba6
# @_group_names:	build group names
Lucio Andrés Illanes Albornoz 60fba6
# @_pkg_name:		single named package
Lucio Andrés Illanes Albornoz 60fba6
#
Lucio Andrés Illanes Albornoz 60fba6
# Return:		zero (0) on success, non-zero (>0) if package not found, group name on stdout if package was found.
Lucio Andrés Illanes Albornoz 60fba6
#
Lucio Andrés Illanes Albornoz 60fba6
ex_pkg_find_package() {
Lucio Andrés Illanes Albornoz b6a9a1
	local _group_names="${1}" _pkg_name="${2}" _foundfl=0 _group_name="" _pkg_names="";
Lucio Andrés Illanes Albornoz 60fba6
	for _group_name in ${_group_names}; do
Lucio Andrés Illanes Albornoz 60fba6
		if _pkg_names="$(rtl_get_var_unsafe -u "${_group_name}_PACKAGES")"\
Lucio Andrés Illanes Albornoz 60fba6
		&& [ -n "${_pkg_names}" ]\
Lucio Andrés Illanes Albornoz 60fba6
		&& rtl_lmatch "${_pkg_names}" "${_pkg_name}"; then
Lucio Andrés Illanes Albornoz 60fba6
			_foundfl=1; break;
Lucio Andrés Illanes Albornoz 60fba6
		fi;
Lucio Andrés Illanes Albornoz 60fba6
	done;
Lucio Andrés Illanes Albornoz 60fba6
	case "${_foundfl:-0}" in
Lucio Andrés Illanes Albornoz 60fba6
	0)	return 1; ;;
Lucio Andrés Illanes Albornoz b6a9a1
	1)	printf "%s" "${_group_name}"; return 0; ;;
Lucio Andrés Illanes Albornoz 60fba6
	esac;
Lucio Andrés Illanes Albornoz 60fba6
};
Lucio Andrés Illanes Albornoz 60fba6
Lucio Andrés Illanes Albornoz 60fba6
#
Lucio Andrés Illanes Albornoz 60fba6
# ex_pkg_get_packages() - get list of packages belonging to single named build group
Lucio Andrés Illanes Albornoz 60fba6
# @_group_name:	build group name
Lucio Andrés Illanes Albornoz 60fba6
#
Lucio Andrés Illanes Albornoz 60fba6
# Return:	zero (0) on success, non-zero (>0) on failure, list of package names on stdout on success.
Lucio Andrés Illanes Albornoz 60fba6
#
Lucio Andrés Illanes Albornoz 60fba6
ex_pkg_get_packages() {
Lucio Andrés Illanes Albornoz 60fba6
	local _group_name="${1}" _pkg_names="";
Lucio Andrés Illanes Albornoz 60fba6
	if _pkg_names="$(rtl_get_var_unsafe -u "${_group_name}_PACKAGES")"\
Lucio Andrés Illanes Albornoz 60fba6
	&& [ -n "${_pkg_names}" ]; then
Lucio Andrés Illanes Albornoz b6a9a1
		printf "%s" "${_pkg_names}"; return 0;
Lucio Andrés Illanes Albornoz 60fba6
	else
Lucio Andrés Illanes Albornoz 60fba6
		return 1;
Lucio Andrés Illanes Albornoz 60fba6
	fi;
Lucio Andrés Illanes Albornoz 60fba6
};
Lucio Andrés Illanes Albornoz 60fba6
Lucio Andrés Illanes Albornoz 60fba6
#
Lucio Andrés Illanes Albornoz b6a9a1
# ex_pkg_load_dump() - load package dump
Lucio Andrés Illanes Albornoz b6a9a1
# @_pkg_name:	package name
Lucio Andrés Illanes Albornoz b6a9a1
#
Lucio Andrés Illanes Albornoz b6a9a1
# Return:	zero (0) on success, non-zero (>0) on failure, package dump post-return on success.
Lucio Andrés Illanes Albornoz b6a9a1
#
Lucio Andrés Illanes Albornoz b6a9a1
ex_pkg_load_dump() {
Lucio Andrés Illanes Albornoz b6a9a1
	local _pkg_name="${1}" _workdir="${2}" _rc=0; _status="";
Lucio Andrés Illanes Albornoz b6a9a1
	if [ ! -e "${_workdir}/${_pkg_name}.dump" ]; then
Lucio Andrés Illanes Albornoz 97b131
		rtl_log_msg warning "Warning: failed to locate environment dump for package \`%s' in \`%s'." "${_pkg_name}" "${_workdir}";
Lucio Andrés Illanes Albornoz 97b131
		rtl_log_msg info "Rebuilding package \`%s' w/ --dump-in _build..." "${_pkg_name}";
Lucio Andrés Illanes Albornoz b6a9a1
		(export	ARCH BUILD BUILD_DLCACHEDIR BUILD_WORKDIR		\
Lucio Andrés Illanes Albornoz b6a9a1
			PREFIX PREFIX_CROSS PREFIX_MINGW32 PREFIX_MINIPIX	\
Lucio Andrés Illanes Albornoz b6a9a1
			PREFIX_NATIVE PREFIX_ROOT PREFIX_RPM;
Lucio Andrés Illanes Albornoz b6a9a1
		./build.sh --dump-in _build -P -r "${_pkg_name}" -v);
Lucio Andrés Illanes Albornoz b6a9a1
		if [ ! -e "${_workdir}/${_pkg_name}.dump" ]; then
Lucio Andrés Illanes Albornoz b6a9a1
			_rc=1; _status="Error: failed to locate environment dump for package \`${_pkg_name}' in \`${_workdir}'.";
Lucio Andrés Illanes Albornoz b6a9a1
		fi;
Lucio Andrés Illanes Albornoz b6a9a1
	else
Lucio Andrés Illanes Albornoz b6a9a1
		_rc=0;
Lucio Andrés Illanes Albornoz b6a9a1
	fi;
Lucio Andrés Illanes Albornoz b6a9a1
	if [ "${_rc:-0}" -eq 0 ]\
Lucio Andrés Illanes Albornoz b6a9a1
	&& ! . "${_workdir}/${_pkg_name}.dump"; then
Lucio Andrés Illanes Albornoz b6a9a1
		_rc=1; _status="Error: failed to source environment dump for package \`${_pkg_name}' from \`${_workdir}'.";
Lucio Andrés Illanes Albornoz b6a9a1
	elif [ "${_rc:-0}" -eq 0 ]\
Lucio Andrés Illanes Albornoz b6a9a1
	&&   ! rtl_fileop cd "${PKG_BUILD_DIR}"; then
Lucio Andrés Illanes Albornoz b6a9a1
		_rc=1; _status="Error: failed to change working directory to \`${PKG_BUILD_DIR}'.";
Lucio Andrés Illanes Albornoz b6a9a1
	fi; return "${_rc}";
Lucio Andrés Illanes Albornoz b6a9a1
};
Lucio Andrés Illanes Albornoz b6a9a1
Lucio Andrés Illanes Albornoz b6a9a1
#
Lucio Andrés Illanes Albornoz b6a9a1
# ex_pkg_load_vars() - load build variables
Lucio Andrés Illanes Albornoz b6a9a1
#
Lucio Andrés Illanes Albornoz b6a9a1
# Return:	zero (0) on success, non-zero (>0) on failure, build variables post-return on success.
Lucio Andrés Illanes Albornoz b6a9a1
#
Lucio Andrés Illanes Albornoz b6a9a1
ex_pkg_load_vars() {
Lucio Andrés Illanes Albornoz b6a9a1
	local _rc=0; _status="";
Lucio Andrés Illanes Albornoz b6a9a1
	if ! rtl_lmatch "${ARCH}" "nt32 nt64"; then
Lucio Andrés Illanes Albornoz b6a9a1
		_rc=1; _status="Error: invalid architecture \`${ARCH}'.";
Lucio Andrés Illanes Albornoz b6a9a1
	elif ! rtl_lmatch "${BUILD}" "debug release"; then
Lucio Andrés Illanes Albornoz b6a9a1
		_rc=1; _status="Error: unknown build type \`${BUILD}'.";
Lucio Andrés Illanes Albornoz b6a9a1
	else	case "${ARCH}" in
Lucio Andrés Illanes Albornoz b6a9a1
		nt32)	DEFAULT_TARGET="i686-nt32-midipix"; ;;
Lucio Andrés Illanes Albornoz b6a9a1
		nt64)	DEFAULT_TARGET="x86_64-nt64-midipix"; ;;
Lucio Andrés Illanes Albornoz b6a9a1
		esac;
Lucio Andrés Illanes Albornoz b6a9a1
		rtl_fileop source_opt							\
Lucio Andrés Illanes Albornoz b6a9a1
			"${HOME}/midipix_build.vars" "${HOME}/.midipix_build.vars"	\
Lucio Andrés Illanes Albornoz b6a9a1
			../midipix_build.vars ./midipix.env;
Lucio Andrés Illanes Albornoz b6a9a1
		if [ -z "${PREFIX}" ]; then
Lucio Andrés Illanes Albornoz b6a9a1
			_rc=1; _status="Error: \${PREFIX} empty or unset.";
Lucio Andrés Illanes Albornoz b6a9a1
		fi;
Lucio Andrés Illanes Albornoz b6a9a1
	fi; return "${_rc}";
Lucio Andrés Illanes Albornoz b6a9a1
};
Lucio Andrés Illanes Albornoz b6a9a1
Lucio Andrés Illanes Albornoz b6a9a1
#
Lucio Andrés Illanes Albornoz b6a9a1
# ex_pkg_load_groups() - load all available build groups
Lucio Andrés Illanes Albornoz b6a9a1
#
Lucio Andrés Illanes Albornoz b6a9a1
# Return:	zero (0) on success, non-zero (>0) on failure, build groups loaded and ${EX_PKG_BUILD_GROUPS} set post-return.
Lucio Andrés Illanes Albornoz b6a9a1
#
Lucio Andrés Illanes Albornoz b6a9a1
ex_pkg_load_groups() {
Lucio Andrés Illanes Albornoz b6a9a1
	local  _build_groups="" _fname="" _group="" _groups="";
Lucio Andrés Illanes Albornoz b6a9a1
	for _fname in $(find ./groups -name *.group | sort); do
Lucio Andrés Illanes Albornoz b6a9a1
		rtl_fileop source_opt "${_fname}";
Lucio Andrés Illanes Albornoz e1d469
		if [ -n "${GROUP_TARGET:-}" ]; then
Lucio Andrés Illanes Albornoz b6a9a1
			_group="${GROUP_TARGET}"; unset GROUP_TARGET;
Lucio Andrés Illanes Albornoz b6a9a1
		else
Lucio Andrés Illanes Albornoz b6a9a1
			_group="${_fname##*/}"; _group="${_group%.group}"; _group="${_group#*.}";
Lucio Andrés Illanes Albornoz b6a9a1
		fi;
Lucio Andrés Illanes Albornoz b6a9a1
		if ! rtl_lmatch "${_groups}" "${_group}"; then
Lucio Andrés Illanes Albornoz b6a9a1
			_groups="$(rtl_lconcat "${_groups}" "${_group}")";
Lucio Andrés Illanes Albornoz e1d469
			if [ -n "${GROUP_AUTO:-}" ]; then
Lucio Andrés Illanes Albornoz b6a9a1
				if [ "${GROUP_AUTO:-0}" -ne 0 ]; then
Lucio Andrés Illanes Albornoz b6a9a1
					_build_groups="$(rtl_lconcat "${_build_groups}" "${_group}")";
Lucio Andrés Illanes Albornoz b6a9a1
				fi;
Lucio Andrés Illanes Albornoz b6a9a1
				unset GROUP_AUTO;
Lucio Andrés Illanes Albornoz b6a9a1
			else
Lucio Andrés Illanes Albornoz b6a9a1
				_build_groups="$(rtl_lconcat "${_build_groups}" "${_group}")";
Lucio Andrés Illanes Albornoz b6a9a1
			fi;
Lucio Andrés Illanes Albornoz b6a9a1
		fi;
Lucio Andrés Illanes Albornoz b6a9a1
	done;
Lucio Andrés Illanes Albornoz b6a9a1
	EX_PKG_BUILD_GROUPS="$(rtl_uniq "${_build_groups}")";
Lucio Andrés Illanes Albornoz b6a9a1
};
Lucio Andrés Illanes Albornoz b6a9a1
Lucio Andrés Illanes Albornoz b6a9a1
#
Lucio Andrés Illanes Albornoz 60fba6
# ex_pkg_unfold_depends() - unfold list of package names into dependency-expanded set of complete, disabled, finished, and outstanding package names
Lucio Andrés Illanes Albornoz b6a9a1
# @_checkfl:		enable (1) or inhibit (0) dependency expansion
Lucio Andrés Illanes Albornoz b6a9a1
# @_forcefl:		enable (1) or inhibit (0) forcibly rebuilding finished packages
Lucio Andrés Illanes Albornoz c6d6e0
# @_group_name:		build group name
Lucio Andrés Illanes Albornoz 60fba6
# @_pkg_names:		list of package names
Lucio Andrés Illanes Albornoz 221ee9
# @_restart:		optional whitespace-separated list of package names to rebuild
Lucio Andrés Illanes Albornoz 60fba6
# @_test_finished:	only exclude disabled packages from ${EX_PKG_NAMES} (0,) split finished packages into ${EX_PKG_FINISHED}
Lucio Andrés Illanes Albornoz c6d6e0
#
Lucio Andrés Illanes Albornoz 60fba6
# Return:		zero (0) on success, non-zero (>0) on failure, ${EX_PKG_DISABLED}, ${EX_PKG_FINISHED}, and ${EX_PKG_NAMES} set post-return.
Lucio Andrés Illanes Albornoz c6d6e0
#
Lucio Andrés Illanes Albornoz 60fba6
ex_pkg_unfold_depends() {
Lucio Andrés Illanes Albornoz b6a9a1
	local	_checkfl="${1}" _forcefl="${2}" _group_name="${3}" _pkg_names="${4}" _restart="${5}" _test_finished="${6}"\
Lucio Andrés Illanes Albornoz 60fba6
		_pkg_name="" _restartfl=0;
Lucio Andrés Illanes Albornoz 60fba6
	if [ -n "${_restart}" ] && ! rtl_lmatch "${_restart}" "ALL LAST"; then
Lucio Andrés Illanes Albornoz 60fba6
		_pkg_names="$(rtl_lsearch "${_pkg_names}" "${_restart}")";
Lucio Andrés Illanes Albornoz 60fba6
	fi;
Lucio Andrés Illanes Albornoz b6a9a1
	if [ -n "${_restart}" ] && [ "${_checkfl:-0}" -eq 1 ]; then
Lucio Andrés Illanes Albornoz 60fba6
		_pkg_names="$(rtl_uniq $(rtl_lunfold_depends 'PKG_${_name}_DEPENDS' ${_pkg_names}))";
Lucio Andrés Illanes Albornoz 60fba6
	fi;
Lucio Andrés Illanes Albornoz 60fba6
	for _pkg_name in ${_pkg_names}; do
Lucio Andrés Illanes Albornoz 60fba6
		if [ "${_restart}" = "ALL" ]\
Lucio Andrés Illanes Albornoz 60fba6
		|| rtl_lmatch "${_restart}" "${_pkg_name}"; then
Lucio Andrés Illanes Albornoz 60fba6
			_restartfl=1;
Lucio Andrés Illanes Albornoz 60fba6
		else
Lucio Andrés Illanes Albornoz 60fba6
			_restartfl=0;
Lucio Andrés Illanes Albornoz 60fba6
		fi;
Lucio Andrés Illanes Albornoz 60fba6
		if [ "x$(rtl_get_var_unsafe -u "PKG_${_pkg_name}_DISABLED")" = "x1" ]; then
Lucio Andrés Illanes Albornoz 60fba6
			EX_PKG_DISABLED="$(rtl_lconcat "${EX_PKG_DISABLED}" "${_pkg_name}")";
Lucio Andrés Illanes Albornoz 60fba6
			_pkg_names="$(rtl_lfilter "${_pkg_names}" "${_pkg_name}")";
Lucio Andrés Illanes Albornoz 60fba6
		elif [ "${_test_finished:-1}" -eq 1 ]\
Lucio Andrés Illanes Albornoz 60fba6
		&&   ex_pkg_state_test "${_pkg_name}" finish\
Lucio Andrés Illanes Albornoz 60fba6
		&&   [ "${_restartfl:-0}" -eq 0 ]\
Lucio Andrés Illanes Albornoz b6a9a1
		&&   [ "${_forcefl:-0}" -ne 1 ]\
Lucio Andrés Illanes Albornoz 60fba6
		&&   [ "x$(rtl_get_var_unsafe -u "${_group_name}_FORCE")" != "x1" ]; then
Lucio Andrés Illanes Albornoz 60fba6
			EX_PKG_FINISHED="$(rtl_lconcat "${EX_PKG_FINISHED}" "${_pkg_name}")";
Lucio Andrés Illanes Albornoz 60fba6
			_pkg_names="$(rtl_lfilter "${_pkg_names}" "${_pkg_name}")";
Lucio Andrés Illanes Albornoz 60fba6
		fi;
Lucio Andrés Illanes Albornoz 60fba6
	done;
Lucio Andrés Illanes Albornoz 60fba6
	EX_PKG_DISABLED="$(rtl_uniq ${EX_PKG_DISABLED})";
Lucio Andrés Illanes Albornoz 60fba6
	EX_PKG_FINISHED="$(rtl_uniq ${EX_PKG_FINISHED})";
Lucio Andrés Illanes Albornoz 60fba6
	EX_PKG_NAMES="$(rtl_uniq ${_pkg_names})";
Lucio Andrés Illanes Albornoz 60fba6
};
Lucio Andrés Illanes Albornoz 60fba6
Lucio Andrés Illanes Albornoz 60fba6
#
Lucio Andrés Illanes Albornoz 60fba6
# ex_pkg_unfold_rdepends() - unfold list of package names into reverse dependency-expanded set of complete, disabled, finished, and outstanding package names
Lucio Andrés Illanes Albornoz 60fba6
# @_group_name:		build group name
Lucio Andrés Illanes Albornoz 60fba6
# @_pkg_names:		list of package names
Lucio Andrés Illanes Albornoz 60fba6
# @_restart:		optional whitespace-separated list of package names to rebuild
Lucio Andrés Illanes Albornoz 60fba6
# @_test_finished:	only exclude disabled packages from ${EX_PKG_NAMES} (0,) split finished packages into ${EX_PKG_FINISHED}
Lucio Andrés Illanes Albornoz 60fba6
#
Lucio Andrés Illanes Albornoz 60fba6
# Return:		zero (0) on success, non-zero (>0) on failure, ${EX_PKG_DISABLED}, ${EX_PKG_FINISHED}, and ${EX_PKG_NAMES} set post-return.
Lucio Andrés Illanes Albornoz 60fba6
#
Lucio Andrés Illanes Albornoz 60fba6
ex_pkg_unfold_rdepends() {
Lucio Andrés Illanes Albornoz 57b30d
	local	_group_name="${1}" _pkg_names="${2}" _restart="${3}" _test_finished="${4}"\
Lucio Andrés Illanes Albornoz 57b30d
		_pkg_depends="" _pkg_name="" _pkg_name_depend="" _pkg_rdepends="";
Lucio Andrés Illanes Albornoz 60fba6
	for _pkg_name_depend in ${_restart}; do
Lucio Andrés Illanes Albornoz 60fba6
		for _pkg_name in ${_pkg_names}; do
Lucio Andrés Illanes Albornoz 60fba6
			if [ "${_pkg_name}" != "${_pkg_name_depend}" ]\
Lucio Andrés Illanes Albornoz 60fba6
			&& [ "x$(rtl_get_var_unsafe -u "PKG_${_pkg_name}_DISABLED")" != "x1" ]\
Lucio Andrés Illanes Albornoz 60fba6
			&& _pkg_depends="$(rtl_lunfold_depends 'PKG_${_name}_DEPENDS' $(rtl_get_var_unsafe -u "PKG_"${_pkg_name}"_DEPENDS"))"\
Lucio Andrés Illanes Albornoz 60fba6
			&& [ -n "${_pkg_depends}" ]\
Lucio Andrés Illanes Albornoz 60fba6
			&& rtl_lmatch "${_pkg_depends}" "${_pkg_name_depend}"; then
Lucio Andrés Illanes Albornoz 60fba6
				_pkg_rdepends="$(rtl_lconcat "${_pkg_rdepends}" "${_pkg_name}")";
Lucio Andrés Illanes Albornoz 7bed88
			fi;
Lucio Andrés Illanes Albornoz 60fba6
		done;
Lucio Andrés Illanes Albornoz 60fba6
	done;
Lucio Andrés Illanes Albornoz 60fba6
	_pkg_names="";
Lucio Andrés Illanes Albornoz 60fba6
	for _pkg_name in ${_pkg_rdepends}; do
Lucio Andrés Illanes Albornoz 60fba6
		if _pkg_depends="$(rtl_lunfold_depends 'PKG_${_name}_DEPENDS' $(rtl_get_var_unsafe -u "PKG_"${_pkg_name}"_DEPENDS"))"\
Lucio Andrés Illanes Albornoz 60fba6
		&& [ -n "${_pkg_depends}" ]; then
Lucio Andrés Illanes Albornoz 60fba6
			for _pkg_name_depend in ${_pkg_depends}; do
Lucio Andrés Illanes Albornoz 60fba6
				if [ "x$(rtl_get_var_unsafe -u "PKG_${_pkg_name_depend}_DISABLED")" = "x1" ]; then
Lucio Andrés Illanes Albornoz 60fba6
					EX_PKG_DISABLED="$(rtl_lconcat "${EX_PKG_DISABLED}" "${_pkg_name_depend}")";
Lucio Andrés Illanes Albornoz 60fba6
				elif [ "${_test_finished:-1}" -eq 1 ]\
Lucio Andrés Illanes Albornoz 60fba6
				&&   ex_pkg_state_test "${_pkg_name_depend}" finish\
Lucio Andrés Illanes Albornoz 60fba6
				&&   [ "x$(rtl_get_var_unsafe -u "${_group_name}_FORCE")" != "x1" ]\
Lucio Andrés Illanes Albornoz 60fba6
				&&   ! rtl_lmatch "${_pkg_rdepends}" "${_pkg_name_depend}"; then
Lucio Andrés Illanes Albornoz 60fba6
					EX_PKG_FINISHED="$(rtl_lconcat "${EX_PKG_FINISHED}" "${_pkg_name_depend}")";
Lucio Andrés Illanes Albornoz 60fba6
				elif [ "${_test_finished:-1}" -eq 0 ]\
Lucio Andrés Illanes Albornoz 60fba6
				||   ! ex_pkg_state_test "${_pkg_name_depend}" finish\
Lucio Andrés Illanes Albornoz 60fba6
				||   [ "x$(rtl_get_var_unsafe -u "${_group_name}_FORCE")" = "x1" ]; then
Lucio Andrés Illanes Albornoz 60fba6
					_pkg_names="$(rtl_lconcat "${_pkg_names}" "${_pkg_name_depend}")";
Lucio Andrés Illanes Albornoz 7bed88
				fi;
Lucio Andrés Illanes Albornoz d4a069
			done;
Lucio Andrés Illanes Albornoz d4a069
		fi;
Lucio Andrés Illanes Albornoz 60fba6
		_pkg_names="$(rtl_lconcat "${_pkg_names}" "${_pkg_name}")";
Lucio Andrés Illanes Albornoz 60fba6
	done;
Lucio Andrés Illanes Albornoz 60fba6
	EX_PKG_DISABLED="$(rtl_uniq ${EX_PKG_DISABLED})";
Lucio Andrés Illanes Albornoz 60fba6
	EX_PKG_FINISHED="$(rtl_uniq ${EX_PKG_FINISHED})";
Lucio Andrés Illanes Albornoz 60fba6
	EX_PKG_NAMES="$(rtl_uniq ${_pkg_names})";
Lucio Andrés Illanes Albornoz c6d6e0
};
Lucio Andrés Illanes Albornoz c6d6e0
Lucio Andrés Illanes Albornoz 57b30d
#
Lucio Andrés Illanes Albornoz 57b30d
# ex_pkg_unfold_rdepends_direct() - unfold list of package names into direct reverse dependency-expanded set of disabled and outstanding package names
Lucio Andrés Illanes Albornoz 57b30d
# @_group_name:		build group name
Lucio Andrés Illanes Albornoz 57b30d
# @_pkg_names:		list of package names
Lucio Andrés Illanes Albornoz 57b30d
# @_restart:		optional whitespace-separated list of package names to rebuild
Lucio Andrés Illanes Albornoz 57b30d
#
Lucio Andrés Illanes Albornoz 57b30d
# Return:		zero (0) on success, non-zero (>0) on failure, ${EX_PKG_DISABLED} and ${EX_PKG_RDEPENDS_DIRECT} set post-return.
Lucio Andrés Illanes Albornoz 57b30d
#
Lucio Andrés Illanes Albornoz 57b30d
ex_pkg_unfold_rdepends_direct() {
Lucio Andrés Illanes Albornoz 57b30d
	local	_group_name="${1}" _pkg_names="${2}" _restart="${3}"\
Lucio Andrés Illanes Albornoz 57b30d
		_pkg_depends="" _pkg_disabled="" _pkg_name="" _pkg_name_depend="" _pkg_rdepends="";
Lucio Andrés Illanes Albornoz 57b30d
	for _pkg_name_depend in ${_restart}; do
Lucio Andrés Illanes Albornoz 57b30d
		for _pkg_name in ${_pkg_names}; do
Lucio Andrés Illanes Albornoz 57b30d
			if [ "${_pkg_name}" != "${_pkg_name_depend}" ]\
Lucio Andrés Illanes Albornoz 57b30d
			&& _pkg_depends="$(rtl_get_var_unsafe -u "PKG_${_pkg_name}_DEPENDS")"\
Lucio Andrés Illanes Albornoz 57b30d
			&& [ -n "${_pkg_depends}" ]\
Lucio Andrés Illanes Albornoz 57b30d
			&& rtl_lmatch "${_pkg_depends}" "${_pkg_name_depend}"; then
Lucio Andrés Illanes Albornoz 57b30d
				if [ "x$(rtl_get_var_unsafe -u "PKG_${_pkg_name}_DISABLED")" != "x1" ]; then
Lucio Andrés Illanes Albornoz 57b30d
					_pkg_rdepends="$(rtl_lconcat "${_pkg_rdepends}" "${_pkg_name}")";
Lucio Andrés Illanes Albornoz 57b30d
				else
Lucio Andrés Illanes Albornoz 57b30d
					_pkg_disabled="$(rtl_lconcat "${_pkg_disabled}" "${_pkg_name}")";
Lucio Andrés Illanes Albornoz 57b30d
				fi;
Lucio Andrés Illanes Albornoz 57b30d
			fi;
Lucio Andrés Illanes Albornoz 57b30d
		done;
Lucio Andrés Illanes Albornoz 57b30d
	done;
Lucio Andrés Illanes Albornoz 57b30d
	EX_PKG_DISABLED="$(rtl_uniq ${_pkg_disabled})";
Lucio Andrés Illanes Albornoz 57b30d
	EX_PKG_RDEPENDS_DIRECT="$(rtl_uniq ${_pkg_rdepends})";
Lucio Andrés Illanes Albornoz 57b30d
};
Lucio Andrés Illanes Albornoz 57b30d
Lucio Andrés Illanes Albornoz c6d6e0
# vim:filetype=sh textwidth=0