Blame subr/ex_pkg_restart.subr

Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
# set +o errexit -o noglob -o nounset is assumed.
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
# exp_pkg_check_restart_at() - XXX
Lucio Andrés Illanes Albornoz 3e5303
# @_rspec_at:		in reference to restart build step list
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
# Calling convention:	in ref. @_rspec_at
Lucio Andrés Illanes Albornoz 3e5303
# Returns:		zero (0) on success, non-zero (>0) on failure
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
exp_pkg_check_restart_at() {
Lucio Andrés Illanes Albornoz 3e5303
	local _epcra_rspec_at="${1#\$}" _epcra_len="" _epcra_rc=0 _epcra_spec_at=""; _status=""
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
	if ! rtl_llift2 "${_epcra_rspec_at}" \$_epcra_spec_at "," " "\
Lucio Andrés Illanes Albornoz 3e5303
	|| ! rtl_lfilter3 \$_epcra_spec_at "${DEFAULT_BUILD_STEPS} ALL LAST"\
Lucio Andrés Illanes Albornoz 3e5303
	|| ! rtl_llength2 \$_epcra_spec_at \$_epcra_len; then
Lucio Andrés Illanes Albornoz 3e5303
		_epcra_rc=1;
Lucio Andrés Illanes Albornoz 3e5303
	elif [ "${_epcra_len}" -gt 0 ]; then
Lucio Andrés Illanes Albornoz 3e5303
		_status="unknown build step(s) \`${_epcra_spec_at}'"; _epcra_rc=1;
Lucio Andrés Illanes Albornoz 3e5303
	fi; return "${_epcra_rc}";
Lucio Andrés Illanes Albornoz 3e5303
};
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
# exp_pkg_expand_restart_at_spec() - XXX
Lucio Andrés Illanes Albornoz 3e5303
# @_rset:		in reference to restart virtual build step set
Lucio Andrés Illanes Albornoz 3e5303
# @_rspec_at:		inout reference to restart build step list
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
# Calling convention:	in ref. @_rset, inout ref. @_rspec_at
Lucio Andrés Illanes Albornoz 3e5303
# Returns:		zero (0) on success, non-zero (>0) on failure
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
exp_pkg_expand_restart_at_spec() {
Lucio Andrés Illanes Albornoz 3e5303
	local	_eperas_rset="${1#\$}" _eperas_rspec_at="${2#\$}" _eperas_at=""			\
Lucio Andrés Illanes Albornoz 3e5303
		_eperas_rc=0 _eperas_spec_at="" _eperas_spec_at_=""; _status="";
Lucio Andrés Illanes Albornoz 3e5303
	eval _eperas_spec_at='${'"${_eperas_rspec_at}"'}';
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
	case "${_eperas_spec_at}" in
Lucio Andrés Illanes Albornoz 3e5303
	ALL|LAST|"")
Lucio Andrés Illanes Albornoz 3e5303
		;;
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
	^*)
Lucio Andrés Illanes Albornoz 3e5303
		_eperas_spec_at="${_eperas_spec_at#^}";
Lucio Andrés Illanes Albornoz 3e5303
		if exp_pkg_expand_restart_at_virtual						\
Lucio Andrés Illanes Albornoz 3e5303
				"${_eperas_spec_at}" \$_eperas_spec_at				\
Lucio Andrés Illanes Albornoz 3e5303
				"${_eperas_rset}"						\
Lucio Andrés Illanes Albornoz 3e5303
		&& exp_pkg_check_restart_at \$_eperas_spec_at; then
Lucio Andrés Illanes Albornoz 3e5303
			rtl_llift2 \$DEFAULT_BUILD_STEPS "${_eperas_rspec_at}" " 	" ",";
Lucio Andrés Illanes Albornoz 3e5303
			rtl_llift2 \$_eperas_spec_at \$_eperas_spec_at_ "," " ";
Lucio Andrés Illanes Albornoz 3e5303
			for _eperas_at in ${_eperas_spec_at_}; do
Lucio Andrés Illanes Albornoz 3e5303
				rtl_lfilter3 "${_eperas_rspec_at}" "${_eperas_at}" ",";
Lucio Andrés Illanes Albornoz 3e5303
			done; rtl_lfilter3 "${_eperas_rspec_at}" "finish" ",";
Lucio Andrés Illanes Albornoz 3e5303
		else
Lucio Andrés Illanes Albornoz 3e5303
			_eperas_rc=1;
Lucio Andrés Illanes Albornoz 3e5303
		fi; ;;
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
	\<=*|\<*|\>=*|\>*)
Lucio Andrés Illanes Albornoz 3e5303
		exp_pkg_expand_restart_at_spec_cmp						\
Lucio Andrés Illanes Albornoz 3e5303
			"${_eperas_rset}" "${_eperas_rspec_at}"; _eperas_rc="${?}"; ;;
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
	*)
Lucio Andrés Illanes Albornoz 3e5303
		if ! exp_pkg_expand_restart_at_virtual						\
Lucio Andrés Illanes Albornoz 3e5303
				"${_eperas_spec_at}" "${_eperas_rspec_at}"			\
Lucio Andrés Illanes Albornoz 3e5303
				"${_eperas_rset}"; then
Lucio Andrés Illanes Albornoz 3e5303
			_eperas_rc=1;
Lucio Andrés Illanes Albornoz 3e5303
		fi; ;;
Lucio Andrés Illanes Albornoz 3e5303
	esac;
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
	if [ "${_eperas_rc}" -eq 0 ]; then
Lucio Andrés Illanes Albornoz 3e5303
		if ! exp_pkg_check_restart_at "${_eperas_rspec_at}"; then
Lucio Andrés Illanes Albornoz 3e5303
			_epprs_rc=1;
Lucio Andrés Illanes Albornoz 3e5303
		elif eval [ '"${'"${_eperas_rspec_at}"':+1}"' != 1 ]; then
Lucio Andrés Illanes Albornoz 3e5303
			_status="zero-length build step list"; _epprs_rc=1;
Lucio Andrés Illanes Albornoz 3e5303
		fi;
Lucio Andrés Illanes Albornoz 3e5303
	fi;
Lucio Andrés Illanes Albornoz 3e5303
	return "${_eperas_rc}";
Lucio Andrés Illanes Albornoz 3e5303
};
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
# exp_pkg_expand_restart_at_spec_cmp() - XXX
Lucio Andrés Illanes Albornoz 3e5303
# @_rset:		in reference to restart virtual build step set
Lucio Andrés Illanes Albornoz 3e5303
# @_rspec_at:		inout reference to restart build step list
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
# Calling convention:	in ref. @_rset, inout ref. @_rspec_at
Lucio Andrés Illanes Albornoz 3e5303
# Returns:		zero (0) on success, non-zero (>0) on failure
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
exp_pkg_expand_restart_at_spec_cmp() {
Lucio Andrés Illanes Albornoz 3e5303
	local	_eperasc_rset="${1#\$}" _eperasc_rspec_at="${2#\$}" _eperasc_at=""		\
Lucio Andrés Illanes Albornoz 3e5303
		_eperasc_eqfl="" _eperasc_foundfl="" _eperasc_ltfl="" _eperasc_rc=0		\
Lucio Andrés Illanes Albornoz 3e5303
		_eperasc_spec_at="" _eperasc_spec_at0="";
Lucio Andrés Illanes Albornoz 3e5303
	eval _eperasc_spec_at0='${'"${_eperasc_rspec_at}"'}';
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
	[ "${_eperasc_spec_at0#<}" = "${_eperasc_spec_at0}" ]; _eperasc_ltfl="${?}";
Lucio Andrés Illanes Albornoz 3e5303
	if [ "${_eperasc_spec_at0#[<>]=}" != "${_eperasc_spec_at0}" ]; then
Lucio Andrés Illanes Albornoz 3e5303
		_eperasc_spec_at0="${_eperasc_spec_at0#[<>]=}"; _eperasc_eqfl=1;
Lucio Andrés Illanes Albornoz 3e5303
	else
Lucio Andrés Illanes Albornoz 3e5303
		_eperasc_spec_at0="${_eperasc_spec_at0#[<>]}"; _eperasc_eqfl=0;
Lucio Andrés Illanes Albornoz 3e5303
	fi; _eperasc_spec_at="";
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
	if exp_pkg_expand_restart_at_virtual							\
Lucio Andrés Illanes Albornoz 3e5303
			"${_eperasc_spec_at0%%,*}" \$_eperasc_spec_at0				\
Lucio Andrés Illanes Albornoz 3e5303
			"${_eperasc_rset}"							\
Lucio Andrés Illanes Albornoz 3e5303
	&& exp_pkg_check_restart_at \$_eperasc_spec_at0; then
Lucio Andrés Illanes Albornoz 3e5303
		if [ \( "${_eperasc_eqfl}" -eq 1 \) -a \( "${_eperasc_ltfl}" -eq 1 \) ]\
Lucio Andrés Illanes Albornoz 3e5303
		|| [ \( "${_eperasc_eqfl}" -eq 0 \) -a \( "${_eperasc_ltfl}" -eq 0 \) ]; then
Lucio Andrés Illanes Albornoz 3e5303
			_eperasc_spec_at0="${_eperasc_spec_at0##*,}";
Lucio Andrés Illanes Albornoz 3e5303
		elif [ \( "${_eperasc_eqfl}" -eq 1 \) -a \( "${_eperasc_ltfl}" -eq 0 \) ]\
Lucio Andrés Illanes Albornoz 3e5303
		||   [ \( "${_eperasc_eqfl}" -eq 0 \) -a \( "${_eperasc_ltfl}" -eq 1 \) ]; then
Lucio Andrés Illanes Albornoz 3e5303
			_eperasc_spec_at0="${_eperasc_spec_at0%%,*}";
Lucio Andrés Illanes Albornoz 3e5303
		fi;
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
		_eperasc_foundfl=0; for _eperasc_at in ${DEFAULT_BUILD_STEPS}; do
Lucio Andrés Illanes Albornoz 3e5303
			if [ "${_eperasc_ltfl}" -eq 1 ]; then
Lucio Andrés Illanes Albornoz 3e5303
				if [ "${_eperasc_at}" = "${_eperasc_spec_at0%%,*}" ]; then
Lucio Andrés Illanes Albornoz 3e5303
					if [ "${_eperasc_eqfl}" -eq 1 ]; then
Lucio Andrés Illanes Albornoz 3e5303
						_eperasc_spec_at="${_eperasc_spec_at:+${_eperasc_spec_at},}${_eperasc_at}";
Lucio Andrés Illanes Albornoz 3e5303
					fi; break;
Lucio Andrés Illanes Albornoz 3e5303
				fi;
Lucio Andrés Illanes Albornoz 3e5303
			else
Lucio Andrés Illanes Albornoz 3e5303
				if [ "${_eperasc_at}" = "${_eperasc_spec_at0%%,*}" ]; then
Lucio Andrés Illanes Albornoz 3e5303
					_eperasc_foundfl=1; [ "${_eperasc_eqfl}" -eq 0 ] && continue;
Lucio Andrés Illanes Albornoz 3e5303
				fi; [ "${_eperasc_foundfl}" -eq 0 ] && continue;
Lucio Andrés Illanes Albornoz 3e5303
			fi;
Lucio Andrés Illanes Albornoz 3e5303
			_eperasc_spec_at="${_eperasc_spec_at:+${_eperasc_spec_at},}${_eperasc_at}";
Lucio Andrés Illanes Albornoz 3e5303
		done;
Lucio Andrés Illanes Albornoz 3e5303
	else
Lucio Andrés Illanes Albornoz 3e5303
		_eperasc_rc=1;
Lucio Andrés Illanes Albornoz 3e5303
	fi;
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
	eval ${_eperasc_rspec_at}='${_eperasc_spec_at}';
Lucio Andrés Illanes Albornoz 3e5303
	return "${_eperasc_rc}";
Lucio Andrés Illanes Albornoz 3e5303
};
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
# exp_pkg_expand_restart_at_virtual() - XXX
Lucio Andrés Illanes Albornoz 3e5303
# @_spec_at:		restart build step list
Lucio Andrés Illanes Albornoz 3e5303
# @_rspec_at_new:	out reference to new restart build step list
Lucio Andrés Illanes Albornoz 3e5303
# @_rset:		inout reference to restart virtual build step set
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
# Calling convention:	inout ref. @_rspec_recursive
Lucio Andrés Illanes Albornoz 3e5303
# Returns:		zero (0) on success, non-zero (>0) on failure
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
exp_pkg_expand_restart_at_virtual() {
Lucio Andrés Illanes Albornoz 3e5303
	local	_epera_spec_at="${1}" _epera_rspec_at_new="${2#\$}" _epera_rset="${3#\$}"	\
Lucio Andrés Illanes Albornoz 3e5303
		_epera_at="" _epera_IFS0="${IFS:- 	}" _epera_rc=0 _epera_spec_at_new=""	\
Lucio Andrés Illanes Albornoz 3e5303
		IFS; _status="";
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
	eval ${_epera_rspec_at_new}=;
Lucio Andrés Illanes Albornoz 3e5303
	IFS=","; set -- ${_epera_spec_at}; IFS="${_epera_IFS0}";
Lucio Andrés Illanes Albornoz 3e5303
	while [ "${#}" -gt 0 ]; do
Lucio Andrés Illanes Albornoz 3e5303
		_epera_at="${1}"; shift;
Lucio Andrés Illanes Albornoz 3e5303
		if [ "${_epera_at#@}" != "${_epera_at}" ]; then
Lucio Andrés Illanes Albornoz 3e5303
			_epera_at="${_epera_at#@}";
Lucio Andrés Illanes Albornoz 3e5303
			if [ "${_epera_at%[^0-9a-zA-Z_]*}" != "${_epera_at}" ]; then
Lucio Andrés Illanes Albornoz 3e5303
				_status="invalid virtual build step \`${_epera_at}'"; _epera_rc=1;
Lucio Andrés Illanes Albornoz 3e5303
			elif eval [ '"${'"${_epera_rset}${_epera_at}"':+1}"' = 1 ]; then
Lucio Andrés Illanes Albornoz 3e5303
				eval _epera_at='${'"${_epera_rset}${_epera_at}"'}';
Lucio Andrés Illanes Albornoz 3e5303
			else
Lucio Andrés Illanes Albornoz 3e5303
				_status="unknown virtual build step \`${_epera_at}'"; _epera_rc=1;
Lucio Andrés Illanes Albornoz 3e5303
			fi;
Lucio Andrés Illanes Albornoz 3e5303
		fi;
Lucio Andrés Illanes Albornoz 3e5303
		eval ${_epera_rspec_at_new}='${'"${_epera_rspec_at_new}"':+${'"${_epera_rspec_at_new}"'},}${_epera_at}';
Lucio Andrés Illanes Albornoz 3e5303
	done;
Lucio Andrés Illanes Albornoz 3e5303
	return "${_epera_rc}";
Lucio Andrés Illanes Albornoz 3e5303
};
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
# exp_pkg_expand_restart_recursive() - XXX
Lucio Andrés Illanes Albornoz 3e5303
# @_rspec:		inout reference to restart {specification,package name list}
Lucio Andrés Illanes Albornoz 3e5303
# @_rrecursive:		out reference to recursion flag
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
# Calling convention:	inout ref. @_rspec, out ref. @_rrecursive
Lucio Andrés Illanes Albornoz 3e5303
# Returns:		zero (0) on success, non-zero (>0) on failure
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
exp_pkg_expand_restart_recursive() {
Lucio Andrés Illanes Albornoz 3e5303
	local _eperr_rspec="${1#\$}" _eperr_rrecursive="${2#\$}" _eperr_spec=""; _status=""
Lucio Andrés Illanes Albornoz 3e5303
	eval _eperr_spec='${'"${_eperr_rspec}"'}';
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
	case "${_eperr_spec}" in
Lucio Andrés Illanes Albornoz 3e5303
	\*\*\*[a-zA-Z]*)
Lucio Andrés Illanes Albornoz 3e5303
			eval ${_eperr_rspec}='${_eperr_spec#\*\*\*}' ${_eperr_rrecursive}=3; ;;
Lucio Andrés Illanes Albornoz 3e5303
	\*\*[a-zA-Z]*)	eval ${_eperr_rspec}='${_eperr_spec#\*\*}' ${_eperr_rrecursive}=2; ;;
Lucio Andrés Illanes Albornoz 3e5303
	\*[a-zA-Z]*)	eval ${_eperr_rspec}='${_eperr_spec#\*}' ${_eperr_rrecursive}=1; ;;
Lucio Andrés Illanes Albornoz 3e5303
	ALL)		eval ${_eperr_rrecursive}=2; ;;
Lucio Andrés Illanes Albornoz 3e5303
	LAST)		eval ${_eperr_rrecursive}=0; ;;
Lucio Andrés Illanes Albornoz 3e5303
	esac;
Lucio Andrés Illanes Albornoz 3e5303
	return 0;
Lucio Andrés Illanes Albornoz 3e5303
};
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
# exp_pkg_expand_restart_spec() - XXX
Lucio Andrés Illanes Albornoz 3e5303
# @_rspec:		inout reference to restart {specification,package name list}
Lucio Andrés Illanes Albornoz 3e5303
# @_rspec_at:		out reference to restart build step list
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
# Calling convention:	inout ref. @_rspec, out ref. @_rspec_at, out ref. @_rrecursive
Lucio Andrés Illanes Albornoz 3e5303
# Returns:		zero (0) on success, non-zero (>0) on failure
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
exp_pkg_expand_restart_spec() {
Lucio Andrés Illanes Albornoz 3e5303
	local	_epers_rspec="${1#\$}" _epers_rspec_at="${2#\$}" _epers_last_pkg=""	\
Lucio Andrés Illanes Albornoz 3e5303
		_epers_rc=0 _epers_spec="" _epers_spec_at="" _epers_spec_at0="";
Lucio Andrés Illanes Albornoz 3e5303
	eval _epers_spec='${'"${_epers_rspec}"'}';
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
	case "${_epers_spec}" in
Lucio Andrés Illanes Albornoz ea574f
	"")	eval ${_epers_rspec_at}=; ;;
Lucio Andrés Illanes Albornoz 3e5303
	ALL)	eval ${_epers_rspec_at}=ALL; ;;
Lucio Andrés Illanes Albornoz 3e5303
	LAST|LAST:*)
Lucio Andrés Illanes Albornoz 3e5303
		case "${_epers_spec}" in
Lucio Andrés Illanes Albornoz 3e5303
		LAST)	eval ${_epers_rspec_at}=LAST; ;;
Lucio Andrés Illanes Albornoz 3e5303
		LAST:*)	eval ${_epers_rspec_at}='${_epers_spec#LAST:}'; ;;
Lucio Andrés Illanes Albornoz 3e5303
		esac;
Lucio Andrés Illanes Albornoz 3e5303
		if [ "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME:+1}" = 1 ]\
Lucio Andrés Illanes Albornoz 3e5303
		&& [ -e "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}" ]; then
Lucio Andrés Illanes Albornoz 3e5303
			if read -r _epers_last_pkg <"${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}"\
Lucio Andrés Illanes Albornoz 3e5303
			&& rtl_fileop rm "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}"; then
Lucio Andrés Illanes Albornoz 3e5303
				eval ${_epers_rspec}='${_epers_last_pkg}';
Lucio Andrés Illanes Albornoz 3e5303
			else
Lucio Andrés Illanes Albornoz 3e5303
				_status="failed to read or clear status of last failed package \`${_epers_last_pkg}'"; _epers_rc=1;
Lucio Andrés Illanes Albornoz 3e5303
			fi;
Lucio Andrés Illanes Albornoz 3e5303
		else
Lucio Andrés Illanes Albornoz 3e5303
			_status="cannot rebuild last failed package"; _epers_rc=1;
Lucio Andrés Illanes Albornoz 3e5303
		fi; ;;
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
	*:*)	eval ${_epers_rspec}='${_epers_spec%:*}' ${_epers_rspec_at}='${_epers_spec#*:}'; ;;
Lucio Andrés Illanes Albornoz 3e5303
	*)	eval ${_epers_rspec_at}= ${_epers_rspec_at}=ALL; ;;
Lucio Andrés Illanes Albornoz 3e5303
	esac;
Lucio Andrés Illanes Albornoz 3e5303
	return "${_epers_rc}";
Lucio Andrés Illanes Albornoz 3e5303
};
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
# exp_pkg_init_restart_at_virtual() - XXX
Lucio Andrés Illanes Albornoz 3e5303
# @_rset:		out reference to restart virtual build step set
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
# Calling convention:	out ref. @_rset
Lucio Andrés Illanes Albornoz 3e5303
# Returns:		zero (0) on success, non-zero (>0) on failure
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
exp_pkg_init_restart_at_virtual() {
Lucio Andrés Illanes Albornoz 3e5303
	local _eperav_rset="${1#\$}" _eperav_step="" _eperav_step_virtual="" _epera_steps="";
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
	rtl_lfilter2 \$DEFAULT_BUILD_STEPS \$_epera_steps "finish";
Lucio Andrés Illanes Albornoz 3e5303
	for _eperav_step in ${_epera_steps}; do
Lucio Andrés Illanes Albornoz 3e5303
		_eperav_step_virtual="${_eperav_step%%_*}";
Lucio Andrés Illanes Albornoz 3e5303
		if eval [ '"${'"${_eperav_rset}${_eperav_step_virtual}"':+1}"' != 1 ]; then
Lucio Andrés Illanes Albornoz 3e5303
			eval ${_eperav_rset}='"${'"${_eperav_rset}"':+${'"${_eperav_rset}"'},}${_eperav_step_virtual}"';
Lucio Andrés Illanes Albornoz 3e5303
		fi;
Lucio Andrés Illanes Albornoz 3e5303
		eval ${_eperav_rset}${_eperav_step_virtual}='"${'"${_eperav_rset}${_eperav_step_virtual}"':+${'"${_eperav_rset}${_eperav_step_virtual}"'},}${_eperav_step}"';
Lucio Andrés Illanes Albornoz 3e5303
	done; return 0;
Lucio Andrés Illanes Albornoz 3e5303
};
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
# ex_pkg_process_restart_spec() - XXX
Lucio Andrés Illanes Albornoz 3e5303
# @_rspec:		inout reference to restart {specification,package name list}
Lucio Andrés Illanes Albornoz 3e5303
# @_rspec_at:		out reference to restart build step list
Lucio Andrés Illanes Albornoz 3e5303
# @_rrecursive:		out reference to restart recursion flag
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
# Calling convention:	inout ref. @_rspec, out ref. @_rspec_at
Lucio Andrés Illanes Albornoz 3e5303
# Returns:		zero (0) on success, non-zero (>0) on failure
Lucio Andrés Illanes Albornoz 3e5303
#
Lucio Andrés Illanes Albornoz 3e5303
ex_pkg_process_restart_spec() {
Lucio Andrés Illanes Albornoz 3e5303
	local	_epprs_rspec="${1#\$}" _epprs_rspec_at="${2#\$}" _epprs_rrecursive="${3#\$}"	\
Lucio Andrés Illanes Albornoz 3e5303
		_epprs_at="" _epprs_rc=0 _epprs_spec_at_new="" _epprs_step="" _epprs_step1=""	\
Lucio Andrés Illanes Albornoz 3e5303
		_epprs_virtual_set=""; _status="";
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz ea574f
	if eval [ '"${'"${_epprs_rspec}"':+1}"' = 1 ]; then
Lucio Andrés Illanes Albornoz ea574f
		if exp_pkg_init_restart_at_virtual \$_epprs_virtual_set					\
Lucio Andrés Illanes Albornoz ea574f
		&& exp_pkg_expand_restart_spec "${_epprs_rspec}" \$_epprs_spec_at_new			\
Lucio Andrés Illanes Albornoz ea574f
		&& exp_pkg_expand_restart_recursive "${_epprs_rspec}" "${_epprs_rrecursive}"		\
Lucio Andrés Illanes Albornoz ea574f
		&& exp_pkg_expand_restart_at_spec \$_epprs_virtual_set \$_epprs_spec_at_new; then
Lucio Andrés Illanes Albornoz ea574f
			eval ${_epprs_rspec_at}=;
Lucio Andrés Illanes Albornoz ea574f
			case "${_epprs_spec_at_new}" in
Lucio Andrés Illanes Albornoz ea574f
			ALL|LAST)
Lucio Andrés Illanes Albornoz ea574f
				eval ${_epprs_rspec_at}='${_epprs_spec_at_new}'; ;;
Lucio Andrés Illanes Albornoz ea574f
			*)
Lucio Andrés Illanes Albornoz ea574f
				for _epprs_at in ${DEFAULT_BUILD_STEPS}; do
Lucio Andrés Illanes Albornoz ea574f
					if rtl_lmatch "${_epprs_at}" "${_epprs_spec_at_new}" ","; then
Lucio Andrés Illanes Albornoz ea574f
						eval ${_epprs_rspec_at}='${'"${_epprs_rspec_at}"':+${'"${_epprs_rspec_at}"'},}${_epprs_at}';
Lucio Andrés Illanes Albornoz ea574f
					fi;
Lucio Andrés Illanes Albornoz ea574f
				done;
Lucio Andrés Illanes Albornoz ea574f
				if eval [ '"${'"${_epprs_rspec_at}"'##*,}"' != "finish" ]; then
Lucio Andrés Illanes Albornoz ea574f
					rtl_lfilter2 "${_epprs_rspec_at}" \$_epprs_step "clean,finish" ","; _epprs_step="${_epprs_step##*,}";
Lucio Andrés Illanes Albornoz ea574f
					rtl_lfilter2 \$DEFAULT_BUILD_STEPS \$_epprs_step1 "clean finish"; _epprs_step1="${_epprs_step1##* }";
Lucio Andrés Illanes Albornoz ea574f
					if [ "${_epprs_step}" = "${_epprs_step1}" ]; then
Lucio Andrés Illanes Albornoz ea574f
						eval ${_epprs_rspec_at}='${'"${_epprs_rspec_at}"':+${'"${_epprs_rspec_at}"'},}finish';
Lucio Andrés Illanes Albornoz ea574f
					fi;
Lucio Andrés Illanes Albornoz ea574f
				fi; ;;
Lucio Andrés Illanes Albornoz ea574f
			esac;
Lucio Andrés Illanes Albornoz ea574f
		else
Lucio Andrés Illanes Albornoz ea574f
			_epprs_rc=1;
Lucio Andrés Illanes Albornoz ea574f
		fi;
Lucio Andrés Illanes Albornoz ea574f
		rtl_sunset \$_epprs_virtual_set;
Lucio Andrés Illanes Albornoz 3e5303
	fi;
Lucio Andrés Illanes Albornoz 3e5303
	return "${_epprs_rc}";
Lucio Andrés Illanes Albornoz 3e5303
};
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
# vim:filetype=sh