Lucio Andrés Illanes Albornoz c6d6e0
#
Lucio Andrés Illanes Albornoz c6d6e0
# set +o errexit -o noglob is assumed.
Lucio Andrés Illanes Albornoz c6d6e0
#
Lucio Andrés Illanes Albornoz 6c3660
Lucio Andrés Illanes Albornoz c3bcd7
buildp_init_args() {
Lucio Andrés Illanes Albornoz ebda8b
	local _last_pkg=""; _status="";
Lucio Andrés Illanes Albornoz c3bcd7
	if [ "${ARG_AS_NEEDED:-0}" -eq 1 ]\
Lucio Andrés Illanes Albornoz c3bcd7
	&& [ -e "${PREFIX}/build.gitref" ]\
Lucio Andrés Illanes Albornoz c3bcd7
	&& [ "$(git rev-parse HEAD)" = "$(cat "${PREFIX}/build.gitref")" ]; then
Lucio Andrés Illanes Albornoz c3bcd7
		_status="Git repository has not changed since last build and --as-needed was specified.";
Lucio Andrés Illanes Albornoz c3bcd7
	fi;
Lucio Andrés Illanes Albornoz ebda8b
	if [ -n "${ARG_RESTART}" ]; then
Lucio Andrés Illanes Albornoz ebda8b
		if [ "${ARG_RESTART#\*\*}" != "${ARG_RESTART}" ]; then
Lucio Andrés Illanes Albornoz ebda8b
			ARG_RESTART="${ARG_RESTART#\*\*}"; ARG_RESTART_RECURSIVE=2;
Lucio Andrés Illanes Albornoz ebda8b
		elif [ "${ARG_RESTART#\*}" != "${ARG_RESTART}" ]; then
Lucio Andrés Illanes Albornoz ebda8b
			ARG_RESTART="${ARG_RESTART#\*}"; ARG_RESTART_RECURSIVE=1;
Lucio Andrés Illanes Albornoz ebda8b
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	fi;
Lucio Andrés Illanes Albornoz c3bcd7
	case "${ARG_RESTART}" in
Lucio Andrés Illanes Albornoz c6d6e0
	ALL)	ARG_RESTART_AT=ALL; ARG_RESTART_RECURSIVE=2; ;;
Lucio Andrés Illanes Albornoz c6d6e0
	LAST)	ARG_RESTART_AT=ALL; ARG_RESTART_RECURSIVE=0; ;;
Lucio Andrés Illanes Albornoz c3bcd7
	"")	;;
Lucio Andrés Illanes Albornoz c3bcd7
	*:*)	ARG_RESTART_AT="${ARG_RESTART#*:}"; ARG_RESTART="${ARG_RESTART%:*}"; ;;
Lucio Andrés Illanes Albornoz c3bcd7
	*)	ARG_RESTART="$(echo "${ARG_RESTART}" | sed "s/,/ /g")"; ARG_RESTART_AT=ALL; ;;
Lucio Andrés Illanes Albornoz c3bcd7
	esac;
Lucio Andrés Illanes Albornoz c3bcd7
	if [ "${ARG_RESTART}" = "LAST" ]; then
Lucio Andrés Illanes Albornoz c3bcd7
		if [ -n "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}" ]\
Lucio Andrés Illanes Albornoz c3bcd7
		&& [ -e "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}" ]; then
Lucio Andrés Illanes Albornoz c3bcd7
			_last_pkg="$(cat "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}")";
Lucio Andrés Illanes Albornoz c6d6e0
			rtl_fileop rm "${DEFAULT_BUILD_LAST_FAILED_PKG_FNAME}";
Lucio Andrés Illanes Albornoz c6d6e0
			rtl_state_clear "${BUILD_WORKDIR}" "${_last_pkg}";
Lucio Andrés Illanes Albornoz c6d6e0
			ARG_RESTART="${_last_pkg}";
Lucio Andrés Illanes Albornoz c3bcd7
		fi;
Lucio Andrés Illanes Albornoz c3bcd7
	fi;
Lucio Andrés Illanes Albornoz c6d6e0
	rtl_log_set_vnfo_lvl "${ARG_VERBOSE:-0}";
Lucio Andrés Illanes Albornoz c6d6e0
	case "${ARG_FETCH_FORCE}" in
Lucio Andrés Illanes Albornoz c6d6e0
	ipv4)	DEFAULT_GIT_ARGS="$(rtl_lconcat "-4" "${DEFAULT_GIT_ARGS}")";
Lucio Andrés Illanes Albornoz c6d6e0
		DEFAULT_WGET_ARGS="$(rtl_lconcat "-4" "${DEFAULT_GIT_ARGS}")"; ;;
Lucio Andrés Illanes Albornoz c6d6e0
	ipv6)	DEFAULT_GIT_ARGS="$(rtl_lconcat "-6" "${DEFAULT_GIT_ARGS}")";
Lucio Andrés Illanes Albornoz c6d6e0
		DEFAULT_WGET_ARGS="$(rtl_lconcat "-6" "${DEFAULT_GIT_ARGS}")"; ;;
Lucio Andrés Illanes Albornoz c6d6e0
	esac;
Lucio Andrés Illanes Albornoz c3bcd7
	return 0;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
};
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
Lucio Andrés Illanes Albornoz c6d6e0
buildp_init_defaults() {
Lucio Andrés Illanes Albornoz c6d6e0
	local _rc=0; _status="";
Lucio Andrés Illanes Albornoz c6d6e0
Lucio Andrés Illanes Albornoz c6d6e0
	# Command-line arguments
Lucio Andrés Illanes Albornoz c6d6e0
	ARCH="nt64"; BUILD="debug";
Lucio Andrés Illanes Albornoz c6d6e0
	ARG_AS_NEEDED=0; ARG_CLEAN_BUILDS=""; ARG_DEBUG_MINIPIX=0; ARG_DIST="";
Lucio Andrés Illanes Albornoz c6d6e0
	ARG_FETCH_FORCE=0; ARG_PARALLEL=1; ARG_RELAXED=0; ARG_RESTART=""; ARG_VERBOSE=0;
Lucio Andrés Illanes Albornoz c6d6e0
Lucio Andrés Illanes Albornoz c6d6e0
	# Build parameters & state
Lucio Andrés Illanes Albornoz c6d6e0
	BUILD_DLCACHEDIR="";BUILD_HNAME=""; BUILD_IS_PARENT=1; BUILD_GROUPS=""; BUILD_TARGET=""; BUILD_USER=""; BUILD_WORKDIR="";
Lucio Andrés Illanes Albornoz c6d6e0
	MIDIPIX_BUILD_PWD=""; PREFIX=""; PREFIX_RPM="";
Lucio Andrés Illanes Albornoz c6d6e0
Lucio Andrés Illanes Albornoz c6d6e0
	# Global defaults
Lucio Andrés Illanes Albornoz c6d6e0
	DEFAULT_BUILD_CPUS=1;
Lucio Andrés Illanes Albornoz c6d6e0
	DEFAULT_BUILD_LAST_FAILED_PKG_FNAME=""
Lucio Andrés Illanes Albornoz c6d6e0
	DEFAULT_BUILD_LOG_FNAME="";
Lucio Andrés Illanes Albornoz c6d6e0
	DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME="";
Lucio Andrés Illanes Albornoz c6d6e0
	DEFAULT_BUILD_STEPS="";
Lucio Andrés Illanes Albornoz c6d6e0
	DEFAULT_BUILD_VARS="";
Lucio Andrés Illanes Albornoz c6d6e0
	DEFAULT_CLEAR_PREFIX_PATHS="";
Lucio Andrés Illanes Albornoz c6d6e0
	DEFAULT_GIT_ARGS="";
Lucio Andrés Illanes Albornoz c6d6e0
	DEFAULT_GITROOT_HEAD="";
Lucio Andrés Illanes Albornoz c6d6e0
	DEFAULT_LOG_ENV_VARS="";
Lucio Andrés Illanes Albornoz c6d6e0
	DEFAULT_TARGET="";
Lucio Andrés Illanes Albornoz c6d6e0
	DEFAULT_WGET_ARGS="";
Lucio Andrés Illanes Albornoz c6d6e0
Lucio Andrés Illanes Albornoz c6d6e0
	return "${_rc}";
Lucio Andrés Illanes Albornoz c3bcd7
};
Lucio Andrés Illanes Albornoz c3bcd7
Lucio Andrés Illanes Albornoz c3bcd7
buildp_init_env() {
Lucio Andrés Illanes Albornoz c6d6e0
	local _cmd="" _cmds_missing="" _fname="" _rc=0; _status="";
Lucio Andrés Illanes Albornoz c6d6e0
	if ! cd "$(dirname "${0}")" || ! umask 022; then
Lucio Andrés Illanes Albornoz c6d6e0
		_rc=1; _status="Error: failed to setup environment";
Lucio Andrés Illanes Albornoz c6d6e0
	else 	for _cmd in	\
Lucio Andrés Illanes Albornoz c6d6e0
				awk bunzip2 cat chmod cmake cp date find flock g++	\
Lucio Andrés Illanes Albornoz c6d6e0
				gcc git grep gunzip gzip hostname install kill		\
Lucio Andrés Illanes Albornoz c6d6e0
				ln lzip make mkdir mkfifo mv paste patch perl		\
Lucio Andrés Illanes Albornoz c6d6e0
				pgrep pkill printf readlink rm sed seq sha256sum	\
Lucio Andrés Illanes Albornoz c6d6e0
				sort stat tail tar test touch tr wget xz zip; do
Lucio Andrés Illanes Albornoz c6d6e0
			if ! which "${_cmd}" >/dev/null 2>&1; then
Lucio Andrés Illanes Albornoz 3f2cba
				_cmds_missing="${_cmds_missing:+${_cmds_missing} }${_cmd}";
Lucio Andrés Illanes Albornoz c6d6e0
			fi;
Lucio Andrés Illanes Albornoz c6d6e0
		done;
Lucio Andrés Illanes Albornoz c6d6e0
		if [ -n "${_cmds_missing}" ]; then
Lucio Andrés Illanes Albornoz c6d6e0
			_rc=1; _status="Error: missing prerequisite package(s): ${_cmds_missing}";
Lucio Andrés Illanes Albornoz c6d6e0
		elif ! awk -V 2>/dev/null | grep -q "^GNU Awk "; then
Lucio Andrés Illanes Albornoz c6d6e0
			_rc=1; _status="Error: awk(1) in \$PATH must be GNU Awk.";
Lucio Andrés Illanes Albornoz c6d6e0
		elif ! sed --version 2>/dev/null | grep -q "^GNU sed "; then
Lucio Andrés Illanes Albornoz c6d6e0
			_rc=1; _status="Error: sed(1) in \$PATH must be GNU sed.";
Lucio Andrés Illanes Albornoz c6d6e0
		else for _fname in $(find subr -name *.subr); do
Lucio Andrés Illanes Albornoz c6d6e0
			if ! . "${_fname}"; then
Lucio Andrés Illanes Albornoz c6d6e0
				_rc=1; _status="Error: failed to source \`${_fname}'."; break;
Lucio Andrés Illanes Albornoz c6d6e0
			fi;
Lucio Andrés Illanes Albornoz c6d6e0
		done; fi;
Lucio Andrés Illanes Albornoz c3bcd7
	fi;
Lucio Andrés Illanes Albornoz c3bcd7
	return "${_rc}";
Lucio Andrés Illanes Albornoz c3bcd7
};
Lucio Andrés Illanes Albornoz c3bcd7
Lucio Andrés Illanes Albornoz c3bcd7
buildp_init_files() {
Lucio Andrés Illanes Albornoz c3bcd7
	local _log_last_fname="" _log_last_ts="" _rc=0; _status=""
Lucio Andrés Illanes Albornoz c6d6e0
	if ! rtl_fileop mkdir "${BUILD_DLCACHEDIR}" "${BUILD_WORKDIR}"\
Lucio Andrés Illanes Albornoz c6d6e0
	|| rtl_lmatch "${ARG_DIST}" "rpm" ","\
Lucio Andrés Illanes Albornoz c6d6e0
	&& ! rtl_fileop mkdir "${PREFIX_RPM}"; then
Lucio Andrés Illanes Albornoz c6d6e0
		_rc=1; _status="Error: cannot create build directories.";
Lucio Andrés Illanes Albornoz 2b85d0
	elif [ -e "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}" ]; then
Lucio Andrés Illanes Albornoz c6d6e0
		_rc=1; _status="Error: another build targeting this architecture and build type is currently in progress.";
Lucio Andrés Illanes Albornoz c6d6e0
	elif ! rtl_clean_env "${DEFAULT_CLEAR_ENV_VARS_EXCEPT}"; then
Lucio Andrés Illanes Albornoz c6d6e0
		_rc=1; _status="Error: failed to clean environment.";
Lucio Andrés Illanes Albornoz c6d6e0
	elif ! rtl_check_path_vars "${DEFAULT_CHECK_PATH_VARS}"; then
Lucio Andrés Illanes Albornoz c6d6e0
		_rc=1; _status="Error: one or more variable containing pathname(s) contains whitespace character(s).";
Lucio Andrés Illanes Albornoz c3bcd7
	else
Lucio Andrés Illanes Albornoz c3bcd7
		touch "${DEFAULT_BUILD_STATUS_IN_PROGRESS_FNAME}";
Lucio Andrés Illanes Albornoz c3bcd7
		if [ -e "${DEFAULT_BUILD_LOG_FNAME}" ]; then
Lucio Andrés Illanes Albornoz c3bcd7
			_log_last_ts="$(stat -c %Y "${DEFAULT_BUILD_LOG_FNAME}")";
Lucio Andrés Illanes Albornoz c3bcd7
			_log_last_ts="$(awk 'BEGIN {printf(strftime("%Y-%m-%d-%H-%M-%S", '"${_log_last_ts}"'))}')";
Lucio Andrés Illanes Albornoz c3bcd7
			_log_last_fname="${DEFAULT_BUILD_LOG_FNAME}.${_log_last_ts}";
Lucio Andrés Illanes Albornoz c6d6e0
			rtl_fileop mv "${DEFAULT_BUILD_LOG_FNAME}" "${_log_last_fname}";
Lucio Andrés Illanes Albornoz c6d6e0
			rtl_fileop ln_symbolic "${_log_last_fname}" "${DEFAULT_BUILD_LOG_LAST_FNAME}";
Lucio Andrés Illanes Albornoz c6d6e0
		fi;
Lucio Andrés Illanes Albornoz c6d6e0
		rtl_fileop touch "${DEFAULT_BUILD_LOG_FNAME}";
Lucio Andrés Illanes Albornoz c6d6e0
		if rtl_lmatch "${ARG_CLEAN_BUILDS}" "prefix" ","; then
Lucio Andrés Illanes Albornoz c6d6e0
			rtl_log_msg info "-C prefix specified, cleaning prefix...";
Lucio Andrés Illanes Albornoz c6d6e0
			for _pname in ${DEFAULT_CLEAR_PREFIX_PATHS}; do
Lucio Andrés Illanes Albornoz c6d6e0
				if ! rtl_fileop rm "${PREFIX}/${_pname}"; then
Lucio Andrés Illanes Albornoz c6d6e0
					_rc=1; _status="Error: failed to remove \`${PREFIX}/${_pname}'."; break;
Lucio Andrés Illanes Albornoz c6d6e0
				fi;
Lucio Andrés Illanes Albornoz c6d6e0
			done;
Lucio Andrés Illanes Albornoz c3bcd7
		fi;
Lucio Andrés Illanes Albornoz c6d6e0
		export PATH="${PREFIX}/bin${PATH:+:${PATH}}";
Lucio Andrés Illanes Albornoz c3bcd7
	fi;
Lucio Andrés Illanes Albornoz c3bcd7
	return "${_rc}";
Lucio Andrés Illanes Albornoz c3bcd7
};
Lucio Andrés Illanes Albornoz c3bcd7
Lucio Andrés Illanes Albornoz c3bcd7
buildp_init_getopts() {
Lucio Andrés Illanes Albornoz c6d6e0
	local _opt="" _rc=0 _shiftfl=0 OPTIND=0; _status="";
Lucio Andrés Illanes Albornoz c3bcd7
	while [ "${#}" -gt 0 ]; do
Lucio Andrés Illanes Albornoz c3bcd7
		case "${1}" in
Lucio Andrés Illanes Albornoz c3bcd7
		--as-needed)	ARG_AS_NEEDED=1; _shiftfl=1; ;;
Lucio Andrés Illanes Albornoz c3bcd7
		--debug-minipx)	ARG_DEBUG_MINIPIX=1; _shiftfl=1; ;;
Lucio Andrés Illanes Albornoz c3bcd7
		-v*)		_opt="${1#-}"; while [ -n "${_opt}" ]; do
Lucio Andrés Illanes Albornoz c3bcd7
					: $((ARG_VERBOSE+=1)); _opt="${_opt#?}";
Lucio Andrés Illanes Albornoz c3bcd7
				done; _shiftfl=1; ;;
Lucio Andrés Illanes Albornoz c3bcd7
		*)		_shiftfl=0; ;;
Lucio Andrés Illanes Albornoz c3bcd7
		esac;
Lucio Andrés Illanes Albornoz c3bcd7
		if [ "${_shiftfl}" -gt 0 ]; then
Lucio Andrés Illanes Albornoz c3bcd7
			shift "${_shiftfl}"; continue;
Lucio Andrés Illanes Albornoz 8f50a3
		elif getopts a:b:C:D:Fhp:Pr:R _opt; then
Lucio Andrés Illanes Albornoz c3bcd7
			case "${_opt}" in
Lucio Andrés Illanes Albornoz c3bcd7
			a)	ARCH="${OPTARG}"; ;;
Lucio Andrés Illanes Albornoz c3bcd7
			b)	BUILD="${OPTARG}"; ;;
Lucio Andrés Illanes Albornoz c3bcd7
			C)	ARG_CLEAN_BUILDS="${OPTARG}"; ;;
Lucio Andrés Illanes Albornoz c3bcd7
			D)	ARG_DIST="${OPTARG}"; ;;
Lucio Andrés Illanes Albornoz c3bcd7
			F)	ARG_FETCH_FORCE=1; ;;
Lucio Andrés Illanes Albornoz c3bcd7
			h)	cat etc/build.usage; exit 0; ;;
Lucio Andrés Illanes Albornoz 8f50a3
			p)	ARG_PARALLEL="${OPTARG}"; ;;
Lucio Andrés Illanes Albornoz 8f50a3
			P)	ARG_PARALLEL="auto"; ;;
Lucio Andrés Illanes Albornoz c3bcd7
			r)	ARG_RESTART="${OPTARG}"; ;;
Lucio Andrés Illanes Albornoz c3bcd7
			R)	ARG_RELAXED=1; ;;
Lucio Andrés Illanes Albornoz c3bcd7
			*)	cat etc/build.usage; exit 1; ;;
Lucio Andrés Illanes Albornoz 8f50a3
			esac; shift $((${OPTIND}-1)); OPTIND=1;
Lucio Andrés Illanes Albornoz c3bcd7
		else
Lucio Andrés Illanes Albornoz c240c2
			break;
Lucio Andrés Illanes Albornoz c3bcd7
		fi;
Lucio Andrés Illanes Albornoz c3bcd7
	done;
Lucio Andrés Illanes Albornoz 8f50a3
	if [ "${_rc}" -eq 0 ]; then
Lucio Andrés Illanes Albornoz 8f50a3
		while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz 8f50a3
		case "${1}" in
Lucio Andrés Illanes Albornoz c6d6e0
		*=*)		rtl_set_var_unsafe "${1%%=*}" "${1#*=}"; ;;
Lucio Andrés Illanes Albornoz c6d6e0
		[^a-zA-Z]*)	_rc=1; _status="Error: build group names must start with [a-zA-Z]."; ;;
Lucio Andrés Illanes Albornoz c6d6e0
		*[^_a-zA-Z]*)	_rc=1; _status="Error: build group names must not contain [^_a-zA-Z]."; ;;
Lucio Andrés Illanes Albornoz c6d6e0
		*)		BUILD_GROUPS="$(rtl_lconcat "${BUILD_GROUPS}" "${1}")";
Lucio Andrés Illanes Albornoz 8f50a3
		esac; shift; done;
Lucio Andrés Illanes Albornoz 8f50a3
	fi;
Lucio Andrés Illanes Albornoz ae3ff0
	return "${_rc}";
Lucio Andrés Illanes Albornoz c3bcd7
};
Lucio Andrés Illanes Albornoz c3bcd7
Lucio Andrés Illanes Albornoz c3bcd7
buildp_init_vars() {
Lucio Andrés Illanes Albornoz 4dc514
	local _default_build_groups="" _fname="" _group="" _groups="" _rc=0; _status="";
Lucio Andrés Illanes Albornoz c6d6e0
	if ! rtl_lmatch "${ARCH}" "nt32 nt64"; then
Lucio Andrés Illanes Albornoz c6d6e0
		_rc=1; _status="Error: invalid architecture \`${ARCH}'.";
Lucio Andrés Illanes Albornoz c6d6e0
	elif ! rtl_lmatch "${BUILD}" "debug release"; then
Lucio Andrés Illanes Albornoz c6d6e0
		_rc=1; _status="Error: unknown build type \`${BUILD}'.";
Lucio Andrés Illanes Albornoz c6d6e0
	elif [ -n "${ARG_PARALLEL}" ] &&  [ "${ARG_PARALLEL}" != "auto" ]\
Lucio Andrés Illanes Albornoz c6d6e0
	&&   ! rtl_isnumber "${ARG_PARALLEL}"; then
Lucio Andrés Illanes Albornoz c6d6e0
		_rc=1; _status="Error: invalid jobs count \`${ARG_PARALLEL}'.";
Lucio Andrés Illanes Albornoz c6d6e0
	else
Lucio Andrés Illanes Albornoz c6d6e0
		case "${ARCH}" in
Lucio Andrés Illanes Albornoz c6d6e0
		nt32)	DEFAULT_TARGET="i686-nt32-midipix"; ;;
Lucio Andrés Illanes Albornoz c6d6e0
		nt64)	DEFAULT_TARGET="x86_64-nt64-midipix"; ;;
Lucio Andrés Illanes Albornoz c6d6e0
		esac;
Lucio Andrés Illanes Albornoz c6d6e0
		if [ -e "/proc/cpuinfo" ]; then
Lucio Andrés Illanes Albornoz b6e66a
			DEFAULT_BUILD_CPUS="$(awk '/^processor/{cpus++} END{print cpus}' /proc/cpuinfo)";
Lucio Andrés Illanes Albornoz c6d6e0
			if [ "${ARG_PARALLEL}" = "auto" ]\
Lucio Andrés Illanes Albornoz c6d6e0
			&& [ "${DEFAULT_BUILD_CPUS}" -gt 1 ]; then
Lucio Andrés Illanes Albornoz c6d6e0
				ARG_PARALLEL=$((${DEFAULT_BUILD_CPUS}/2));
Lucio Andrés Illanes Albornoz c6d6e0
			fi;
Lucio Andrés Illanes Albornoz b6e66a
		fi;
Lucio Andrés Illanes Albornoz c6d6e0
		rtl_fileop source_opt							\
Lucio Andrés Illanes Albornoz c6d6e0
			"${HOME}/midipix_build.vars" "${HOME}/.midipix_build.vars"	\
Lucio Andrés Illanes Albornoz 1c6fee
			../midipix_build.vars ./midipix.env;
Lucio Andrés Illanes Albornoz c6d6e0
		if [ -z "${PREFIX}" ]; then
Lucio Andrés Illanes Albornoz c6d6e0
			_rc=1; _status="Error: \${PREFIX} empty or unset.";
Lucio Andrés Illanes Albornoz c6d6e0
		else
Lucio Andrés Illanes Albornoz c6d6e0
			for _fname in $(find ./groups -name *.group | sort); do
Lucio Andrés Illanes Albornoz c6d6e0
				rtl_fileop source_opt "${_fname}";
Lucio Andrés Illanes Albornoz 1c6c04
				if [ -n "${GROUP_TARGET}" ]; then
Lucio Andrés Illanes Albornoz 4dc514
					_group="${GROUP_TARGET}"; unset GROUP_TARGET;
Lucio Andrés Illanes Albornoz c6d6e0
				else
Lucio Andrés Illanes Albornoz 4dc514
					_group="${_fname##*/}"; _group="${_group%.group}"; _group="${_group#*.}";
Lucio Andrés Illanes Albornoz c6d6e0
				fi;
Lucio Andrés Illanes Albornoz 4dc514
				if ! rtl_lmatch "${_groups}" "${_group}"; then
Lucio Andrés Illanes Albornoz 4dc514
					_groups="$(rtl_lconcat "${_groups}" "${_group}")";
Lucio Andrés Illanes Albornoz 4dc514
					if [ -n "${GROUP_AUTO}" ]; then
Lucio Andrés Illanes Albornoz 4dc514
						if [ "${GROUP_AUTO:-0}" -ne 0 ]; then
Lucio Andrés Illanes Albornoz 4dc514
							_default_build_groups="$(rtl_lconcat "${_default_build_groups}" "${_group}")";
Lucio Andrés Illanes Albornoz 4dc514
						fi;
Lucio Andrés Illanes Albornoz 4dc514
						unset GROUP_AUTO;
Lucio Andrés Illanes Albornoz 4dc514
					else
Lucio Andrés Illanes Albornoz 4dc514
						_default_build_groups="$(rtl_lconcat "${_default_build_groups}" "${_group}")";
Lucio Andrés Illanes Albornoz 2f7577
					fi;
Lucio Andrés Illanes Albornoz 2f7577
				fi;
Lucio Andrés Illanes Albornoz c6d6e0
			done;
Lucio Andrés Illanes Albornoz 1c6c04
			_default_build_groups="$(rtl_uniq "${_default_build_groups}")";
Lucio Andrés Illanes Albornoz c6d6e0
			if ! rtl_lmatch "${ARG_DIST}" "rpm" ","; then
Lucio Andrés Illanes Albornoz c6d6e0
				_default_build_groups="$(rtl_lfilter "${_default_build_groups}" "host_deps_rpm")";
Lucio Andrés Illanes Albornoz c6d6e0
			fi;
Lucio Andrés Illanes Albornoz c6d6e0
			if [ -z "${BUILD_GROUPS}" ]; then
Lucio Andrés Illanes Albornoz c6d6e0
				BUILD_GROUPS="${_default_build_groups}";
Lucio Andrés Illanes Albornoz c6d6e0
			fi;
Lucio Andrés Illanes Albornoz efeeb0
			if [ -n "${ARG_DIST}" ]; then
Lucio Andrés Illanes Albornoz efeeb0
				BUILD_GROUPS="$(rtl_lconcat "$(rtl_lfilter "${BUILD_GROUPS}" "dist")" "dist")";
Lucio Andrés Illanes Albornoz efeeb0
			fi;
Lucio Andrés Illanes Albornoz 4dc514
			for _group in ${BUILD_GROUPS}; do
Lucio Andrés Illanes Albornoz 4dc514
				if ! rtl_lmatch "${_groups}" "${_group}"; then
Lucio Andrés Illanes Albornoz 4dc514
					_rc=1; _status="Error: unknown build group \`${_group}'."; break;
Lucio Andrés Illanes Albornoz 4dc514
				fi;
Lucio Andrés Illanes Albornoz 4dc514
			done;
Lucio Andrés Illanes Albornoz 12508d
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 9ad97c
	fi;
Lucio Andrés Illanes Albornoz c3bcd7
	return "${_rc}";
Lucio Andrés Illanes Albornoz c3bcd7
};
Lucio Andrés Illanes Albornoz c3bcd7
Lucio Andrés Illanes Albornoz c3bcd7
build_init() {
Lucio Andrés Illanes Albornoz c6d6e0
	local _fname="" _rc=0 _status="";
Lucio Andrés Illanes Albornoz c6d6e0
	if ! buildp_init_env		\
Lucio Andrés Illanes Albornoz c6d6e0
	|| ! buildp_init_defaults	\
Lucio Andrés Illanes Albornoz c3bcd7
	|| ! buildp_init_getopts "${@}"	\
Lucio Andrés Illanes Albornoz c3bcd7
	|| ! buildp_init_vars		\
Lucio Andrés Illanes Albornoz c3bcd7
	|| ! buildp_init_args		\
Lucio Andrés Illanes Albornoz c6d6e0
	|| ! buildp_init_files; then
Lucio Andrés Illanes Albornoz c6d6e0
		_rc="${?}"; rtl_log_msg fail "${_status}"; exit "${_rc}";
Lucio Andrés Illanes Albornoz c3bcd7
	elif [ -n "${_status}" ]; then
Lucio Andrés Illanes Albornoz c6d6e0
		rtl_log_msg info "${_status}"; exit 0;
Lucio Andrés Illanes Albornoz (arab, vxp) ec19f0
	else
Lucio Andrés Illanes Albornoz c3bcd7
		return "${_rc}";
Lucio Andrés Illanes Albornoz ed4109
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) e2fea1
};
Lucio Andrés Illanes Albornoz (arab, vxp) e2fea1
Lucio Andrés Illanes Albornoz (arab, vxp) e2fea1
# vim:filetype=sh