Blame subr/build_args.subr

Lucio Andrés Illanes Albornoz (arab, vxp) 0185bc
#
Lucio Andrés Illanes Albornoz (arab, vxp) 0185bc
# set -o noglob is assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) 0185bc
#
Lucio Andrés Illanes Albornoz (arab, vxp) 0185bc
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
BUILD_ARGS_SPEC="
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_IPV4_ONLY:-4:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_IPV6_ONLY:-6:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARCH:arg:-a:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	BUILD:arg:-b:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_CLEAN:-c:
Lucio Andrés Illanes Albornoz (arab, vxp) 19ab70
	ARG_CLEAN_BUILDS:arg:-C:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_DEBUG_MINIPIX:--debug-minipix:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_OFFLINE:-N:
Lucio Andrés Illanes Albornoz (arab, vxp) 19ab70
	ARG_PACKAGE:-p:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_PARALLEL:optarg:-P:auto
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_RELAXED:-R:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_RESTART:arg:-r:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_TARBALL:selfarg:-t:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_TARBALL:selfarg:-t.bz2;
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_TARBALL:selfarg:-t.gz:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_TARBALL:selfarg:-t.xz:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_VERBOSE:selfarg:-v:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_VERBOSE:selfarg:-vv:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_VERBOSE:selfarg:-vvv:
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
	ARG_XTRACE:-x:";
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
build_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) cbc8e0
			*:${1}:*)
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
				case "${_spec_arg#*:}" in
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
				arg:*)
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
					ex_rtl_set_var_unsafe "${_spec_arg%%:*}" "${2}"; shift; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
				optarg:*)
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
					if [ -n "${2}" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
					&& [ "x${2#-}" = "x${2}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
						ex_rtl_set_var_unsafe "${_spec_arg%%:*}" "${2}";
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
						shift;
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
					else
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
						ex_rtl_set_var_unsafe "${_spec_arg%%:*}"	\
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
							"${_spec_arg##*:}";
Lucio Andrés Illanes Albornoz (arab, vxp) cbc8e0
					fi; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
				selfarg:*)
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
					ex_rtl_set_var_unsafe "${_spec_arg%%:*}" "${1}"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
				*)
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
					ex_rtl_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) 19ab70
	if [ -n "${ARG_CLEAN_BUILDS}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 19ab70
		ARG_CLEAN_BUILDS="$(echo "${ARG_CLEAN_BUILDS}" | sed "s/,/ /g")";
Lucio Andrés Illanes Albornoz (arab, vxp) 19ab70
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 19ab70
	if [ -n "${ARG_CLEAN_BUILDS}" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 19ab70
	|| [ "${ARG_PACKAGE:-0}" -eq 1 ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 19ab70
	&& [ -n "${ARG_TARBALL}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 19ab70
		unset ARG_TARBALL;
Lucio Andrés Illanes Albornoz (arab, vxp) 19ab70
	elif [ -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) ec19f0
	case "${ARG_VERBOSE}" in
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	-v)	ARG_VERBOSE=1; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	-vv)	ARG_VERBOSE=2; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	-vvv)	ARG_VERBOSE=3; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	esac;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	if [ "${ARG_XTRACE:-0}" -eq 1 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
		ARG_VERBOSE=2;
Lucio Andrés Illanes Albornoz (arab, vxp) 648b81
	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) ec19f0
		else
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
			ARG_RESTART_AT=ALL;
Lucio Andrés Illanes Albornoz (arab, vxp) f6a5cb
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 19ab70
		ARG_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) ec19f0
	*=*)	ex_rtl_set_var_unsafe "${1%%=*}" "${1#*=}"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 1dfec6
	*)	BUILD_TARGETS="${BUILD_TARGETS:+${BUILD_TARGETS} }${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