Lucio Andrés Illanes Albornoz 3e5303
#
8d7a8a
# Copyright (c) 2016, 2017, 2018, 2019, 2020, 2021, 2022, 2023 LucĂ­a Andrea Illanes Albornoz <lucia@luciaillanes.de>
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
#
0903bb
# exp_pkg_check_restart_at() - check restart (-r) specification for unknown build steps
e9fa07
# @_rstatus:		out reference to status string
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
# 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() {
e9fa07
	local	_epcra_rstatus="${1#\$}" _epcra_rspec_at="${2#\$}"	\
e9fa07
		_epcra_len=0 _epcra_rc=0 _epcra_spec_at="";
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
	if ! rtl_llift2 "${_epcra_rspec_at}" \$_epcra_spec_at "," " "\
e9fa07
	|| ! rtl_lfilter \$_epcra_spec_at "${DEFAULT_BUILD_STEPS} ALL LAST"\
e9fa07
	|| ! rtl_llength \$_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
e9fa07
		_epcra_rc=1;
e9fa07
		rtl_setrstatus "${_epcra_rstatus}" 'unknown build step(s) \`'"${_epcra_spec_at}"''\''';
e9fa07
	fi;
e9fa07
e9fa07
	return "${_epcra_rc}";
Lucio Andrés Illanes Albornoz 3e5303
};
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
#
0903bb
# exp_pkg_expand_restart_at_spec() - expand list of virtual build steps and list of build steps into list of build steps w/ operator subspecifications and virtual build steps expanded
e9fa07
# @_rstatus:		out reference to status string
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
# 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() {
e9fa07
	local	_eperas_rstatus="${1#\$}" _eperas_rset="${2#\$}" _eperas_rspec_at="${3#\$}"	\
e9fa07
		_eperas_at="" _eperas_rc=0 _eperas_spec_at="" _eperas_spec_at_="";
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#^}";
e9fa07
		if exp_pkg_expand_restart_at_virtual			\
e9fa07
				"${_eperas_rstatus}"			\
e9fa07
				"${_eperas_spec_at}" \$_eperas_spec_at	\
e9fa07
				"${_eperas_rset}"			\
e9fa07
		&& exp_pkg_check_restart_at "${_eperas_rstatus}" \$_eperas_spec_at;
e9fa07
		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
e9fa07
				rtl_lfilter "${_eperas_rspec_at}" "${_eperas_at}" ",";
e9fa07
			done; rtl_lfilter "${_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
	\<=*|\<*|\>=*|\>*)
e9fa07
		exp_pkg_expand_restart_at_spec_cmp	\
f0f37f
			"${_eperas_rstatus}"		\
f0f37f
			"${_eperas_rset}" "${_eperas_rspec_at}";
f0f37f
		_eperas_rc="${?}"; ;;
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
	*)
e9fa07
		if ! exp_pkg_expand_restart_at_virtual				\
e9fa07
				"${_eperas_rstatus}"				\
e9fa07
				"${_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
e9fa07
		if ! exp_pkg_check_restart_at "${_eperas_rstatus}" "${_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
e9fa07
			_epprs_rc=1;
e9fa07
			rtl_setrstatus "${_eperas_rstatus}" 'zero-length build step list';
Lucio Andrés Illanes Albornoz 3e5303
		fi;
Lucio Andrés Illanes Albornoz 3e5303
	fi;
e9fa07
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
#
0903bb
# exp_pkg_expand_restart_at_spec_cmp() - expand list of virtual build steps and list of build steps into list of build steps w/ operator subspecifications expanded
e9fa07
# @_rstatus:		out reference to status string
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
# 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() {
e9fa07
	local	_eperasc_rstatus="${1#\$}" _eperasc_rset="${2#\$}" _eperasc_rspec_at="${3#\$}"		\
e9fa07
		_eperasc_at="" _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
e9fa07
	if exp_pkg_expand_restart_at_virtual				\
e9fa07
			"${_eperasc_rstatus}"				\
e9fa07
			"${_eperasc_spec_at0%%,*}" \$_eperasc_spec_at0	\
e9fa07
			"${_eperasc_rset}"				\
e9fa07
	&& exp_pkg_check_restart_at "${_eperasc_rstatus}" \$_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
#
0903bb
# exp_pkg_expand_restart_at_virtual() - expand list of build steps into list of build steps w/ expansion of virtual build steps
e9fa07
# @_rstatus:		out reference to status string
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
0903bb
# @_rset:		in reference to restart virtual build step set
Lucio Andrés Illanes Albornoz 3e5303
#
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() {
e9fa07
	local	_epera_rstatus="${1#\$}" _epera_spec_at="${2}" _epera_rspec_at_new="${3#\$}"	\
e9fa07
		_epera_rset="${4#\$}"								\
Lucio Andrés Illanes Albornoz 3e5303
		_epera_at="" _epera_IFS0="${IFS:- 	}" _epera_rc=0 _epera_spec_at_new=""	\
e9fa07
		IFS;
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 a7ecdc
			if [ "${_epera_at%[!0-9a-zA-Z_]*}" != "${_epera_at}" ]; then
e9fa07
				_epera_rc=1;
80900b
				rtl_setrstatus "${_epera_rstatus}" 'invalid virtual build step \`'"${_epera_at}"''\''';
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
e9fa07
				_epera_rc=1;
e9fa07
				rtl_setrstatus "${_epera_rstatus}" 'unknown virtual build step \`'"${_epera_at}"''\''';
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;
e9fa07
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
#
0903bb
# exp_pkg_expand_restart_recursive() - expand restart (-r) specification into recursion flag
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
# 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() {
e9fa07
	local _eperr_rspec="${1#\$}" _eperr_rrecursive="${2#\$}" _eperr_spec="";
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
e9fa07
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; ;;
e9fa07
Lucio Andrés Illanes Albornoz 3e5303
	esac;
e9fa07
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
#
0903bb
# exp_pkg_expand_restart_spec() - expand restart (-r) specification into list of build steps
e9fa07
# @_rstatus:		out reference to status string
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
# 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() {
e9fa07
	local	_epers_rstatus="${1#\$}" _epers_rspec="${2#\$}" _epers_rspec_at="${3#\$}"	\
e9fa07
		_epers_last_pkg="" _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
e9fa07
				_epers_rc=1;
e9fa07
				rtl_setrstatus "${_epers_rstatus}" 'failed to read or clear status of last failed package \`'"${_epers_last_pkg}"''\''';
Lucio Andrés Illanes Albornoz 3e5303
			fi;
Lucio Andrés Illanes Albornoz 3e5303
		else
e9fa07
			_epers_rc=1;
e9fa07
			rtl_setrstatus "${_epers_rstatus}" 'cannot rebuild last failed package';
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;
e9fa07
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
#
0903bb
# exp_pkg_init_restart_at_virtual() - produce list of virtual build step set in default build steps
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
# 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}"';
e9fa07
	done;
e9fa07
e9fa07
	return 0;
Lucio Andrés Illanes Albornoz 3e5303
};
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz 3e5303
#
0903bb
# ex_pkg_process_restart_spec() - process restart (-r) specification into list of build steps and recursion flag
e9fa07
# @_rstatus:		out reference to status string
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
# 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() {
e9fa07
	local	_epprs_rstatus="${1#\$}" _epprs_rspec="${2#\$}" _epprs_rspec_at="${3#\$}"	\
e9fa07
		_epprs_rrecursive="${4#\$}"							\
Lucio Andrés Illanes Albornoz 3e5303
		_epprs_at="" _epprs_rc=0 _epprs_spec_at_new="" _epprs_step="" _epprs_step1=""	\
e9fa07
		_epprs_virtual_set="";
Lucio Andrés Illanes Albornoz 3e5303
Lucio Andrés Illanes Albornoz ea574f
	if eval [ '"${'"${_epprs_rspec}"':+1}"' = 1 ]; then
e9fa07
		if exp_pkg_init_restart_at_virtual \$_epprs_virtual_set						\
e9fa07
		&& exp_pkg_expand_restart_spec "${_epprs_rstatus}" "${_epprs_rspec}" \$_epprs_spec_at_new	\
e9fa07
		&& exp_pkg_expand_restart_recursive "${_epprs_rspec}" "${_epprs_rrecursive}"			\
e9fa07
		&& exp_pkg_expand_restart_at_spec "${_epprs_rstatus}" \$_epprs_virtual_set \$_epprs_spec_at_new;
e9fa07
		then
e9fa07
Lucio Andrés Illanes Albornoz ea574f
			eval ${_epprs_rspec_at}=;
Lucio Andrés Illanes Albornoz ea574f
			case "${_epprs_spec_at_new}" in
e9fa07
Lucio Andrés Illanes Albornoz ea574f
			ALL|LAST)
Lucio Andrés Illanes Albornoz ea574f
				eval ${_epprs_rspec_at}='${_epprs_spec_at_new}'; ;;
e9fa07
Lucio Andrés Illanes Albornoz ea574f
			*)
Lucio Andrés Illanes Albornoz ea574f
				for _epprs_at in ${DEFAULT_BUILD_STEPS}; do
e9fa07
					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 b9a715
				fi; ;;
e9fa07
e9fa07
			esac;
e9fa07
			rtl_llift "${_epprs_rspec}" "," " " || _epprs_rc=1;
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;
e9fa07
Lucio Andrés Illanes Albornoz 3e5303
	return "${_epprs_rc}";
Lucio Andrés Illanes Albornoz 3e5303
};
Lucio Andrés Illanes Albornoz 3e5303
64844b
# vim:filetype=sh textwidth=0