Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
BUILD_ARGS_SPEC="
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_IPV4_ONLY:-4
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_IPV6_ONLY:-6
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARCH:arg:-a
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	BUILD:arg:-b
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_CLEAN:-c
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_DEBUG_MINIPIX:--debug-minipix
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_IGNORE_SHA256SUMS:-i
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_OFFLINE:-N
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_RELAXED:-R
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_RESTART:arg:-r
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_TARBALL:selfarg:-t
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_TARBALL:selfarg:-t.bz2
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_TARBALL:selfarg:-t.gz
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_TARBALL:selfarg:-t.xz
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_VERBOSE:-v
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	ARG_XTRACE:-x";
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
ex_setup_args() {
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	local _spec="${BUILD_ARGS_SPEC}" _spec_arg _found;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		if [ "${1#-}" = "${1}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			break;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		for _spec_arg in ${_spec}; do
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			case "${_spec_arg}" in
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			*:${1})	case "${_spec_arg#*:}" in
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
				arg:*)
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
					ex_set_var_unsafe "${_spec_arg%%:*}" "${2}"; shift; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
				selfarg:*)
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
					ex_set_var_unsafe "${_spec_arg%%:*}" "${1}"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
				*)
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
					ex_set_var_unsafe "${_spec_arg%%:*}" 1; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
				esac; _found=1; break; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			*)	_found=0; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			esac;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		done;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		if [ "${_found:-0}" -eq 0 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			exec cat etc/build.usage;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		else
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			shift;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	if [ -n "${ARG_TARBALL}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		if [ "${ARG_TARBALL#-t.}" != "${ARG_TARBALL}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			TARBALL_SUFFIX="${ARG_TARBALL#-t.}";
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		else
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			TARBALL_SUFFIX=xz;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	if [ "${ARG_XTRACE:-0}" -eq 1 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		set -o xtrace;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	if [ -n "${ARG_RESTART}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		if [ "${ARG_RESTART%:*}" != "${ARG_RESTART}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
			ARG_RESTART_AT="${ARG_RESTART#*:}"; ARG_RESTART="${ARG_RESTART%:*}";
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		BUILD_PACKAGES_RESTART="$(echo ${ARG_RESTART} | sed "s/,/ /g")";
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	case "${1}" in
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
	*=*)	ex_set_var_unsafe "${1%%=*}" "${1#*=}"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	*)	BUILD_TARGETS_META="${BUILD_TARGETS_META:+${BUILD_TARGETS_META} }${1}"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
	esac; shift; done;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
};
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
# vim:filetype=sh