midipix / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame build.subr

Lucio Andrés Illanes Albornoz (arab, vxp) 6e940c
#
Lucio Andrés Illanes Albornoz (arab, vxp) 31dc75
# . ./build.vars and set -o errexit are assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
# See warning at the top of build.vars.
Lucio Andrés Illanes Albornoz (arab, vxp) 6e940c
#
Lucio Andrés Illanes Albornoz (arab, vxp) 6e940c
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
date() { command date +"${1:-${TIMESTAMP_FMT}}"; };
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
fetch_git() { [ -d ${1} ] && (cd ${1} && git pull origin main) || git clone ${3} ${2} ${1}; };
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
get_basename() { set -- $(get_name_without_slash ${1}); echo "${1##*/}"; };
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
get_var() { eval echo \${${1}}; }; # XXX
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
set_var() { eval ${1}=\"${2}\"; }; # XXX
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
get_name_without_slash() { while [ "x${1%/}" != "x${1}" ]; do set -- ${1%/}; done; echo ${1}; };
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
get_postfix_lrg() { echo "${1##*${2}}"; };
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
get_prefix_lrg() { echo "${1%%${2}*}"; };
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
get_postfix() { echo "${1#*${2}}"; };
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
get_prefix() { echo "${1%${2}*}"; };
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
match_any() { [ "x${1#*${2}*}" != "x${1}" ]; };
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
match_start() { [ "x${1#${2}}" != "x${1}" ]; };
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
push_IFS() { _pI_IFS="${IFS}"; IFS="${1}"; };
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
pop_IFS() { IFS="${_pI_IFS}"; unset _pI_IFS; };
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
set_build_dir() { PKG_BUILD_DIR=${1}-${2}-${TARGET}; };
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
split() { push_IFS "${1}"; set -- ${2}; pop_IFS; echo "${*}"; };
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
test_cmd() { command -v "${1}" >/dev/null; };
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
unsplit() { push_IFS "${1}"; shift; set -- "${@}"; echo "${*}"; pop_IFS; };
lalbornoz 340f4c
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
export_vars_subst() {
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	_evs_pfx=${1}; _evs_pfx_new=${2}; shift 2;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		if [ -n "${_evs_vval:=$(get_var ${_evs_pfx}${1})}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			export "${_evs_pfx_new}${1}=${_evs_vval}";
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		fi; unset _evs_vval; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	done; unset _evs_pfx _evs_pfx_new;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
};
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
rm_if_exists() {
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	set_flag_vars_from_args "$@"; shift ${_sfvfa_nshift:-0};
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	[ -d ${1} ] && rm -rf ${1}; [ -f ${1} ] && rm -f ${1};
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	[ ${_arg_m:-0} -eq 1 ] && mkdir ${1};
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	[ ${_arg_c:-0} -eq 1 ] && cd ${1};
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	unset_flag_vars_from_args;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
};
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
set_flag_vars_from_args() {
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	unset _sfvfa_flag_vars _sfvfa_nshift;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	while [ ${#} -gt 1 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		if [ "x${1%[a-z]}" = "x-" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
			set_var _arg_${1#-} 1;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			_sfvfa_flag_vars="${_sfvfa_flag_vars:+${_sfvfa_flag_vars} }_arg_${1#-}";
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			: $((_sfvfa_nshift+=1));
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		fi; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
};
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
unset_flag_vars_from_args() {
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	set -- ${_sfvfa_flag_vars}; while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		unset ${1}; shift; done; unset _sfvfa_flag_vars _sfvfa_nshift;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
};
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
set_env_vars() {
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	_sev_val_new="${1}"; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	while [ ${#} -gt 1 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		[ -z "${_sev_val_new}" ] && unset ${1} ||\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			export "${1}=${_sev_val_new}"; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	done; unset _sev_val_new;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
};
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
# Download GNU bash-style patch sets into ${2}-patches-extra and
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
# apply them to ${2} in the correct order.
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
apply_patches() {
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	(rm_if_exists -m -c ${2}-patches-extra;
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
	wget -c -nd -np -r -R \*.htm\* -R \*.sig ${1};
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	for _ap_patch_fname in		\
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
			$(find . -type f -not -iname \*.sig | sort); do
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		patch -b -d ../${2} -p0 < ${_ap_patch_fname};
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	done; unset _ap_patch_fname);
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
};
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
# Check whether all supplied arguments contain non-empty valid values.
Lucio Andrés Illanes Albornoz (arab, vxp) d30b8f
check_path_vars() {
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		if [ -z "${_cpv_val:=$(get_var "${1}")}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
			log_msg failexit "Error: variable \`${1}' is empty or unset.";
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		elif match_any "${_cpv_val}" " "; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
			log_msg failexit "Error: variable \`${1}' contains one or more whitespace characters.";
Lucio Andrés Illanes Albornoz (arab, vxp) d30b8f
		else
Lucio Andrés Illanes Albornoz (arab, vxp) d30b8f
			shift;
Lucio Andrés Illanes Albornoz (arab, vxp) d30b8f
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		unset _cpv_val;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) d30b8f
};
Lucio Andrés Illanes Albornoz (arab, vxp) d30b8f
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
# Check whether all supplied command names resolve.
Lucio Andrés Illanes Albornoz (arab, vxp) f5eeee
check_prereqs() {
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		if ! command -v ${1} >/dev/null; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
			log_msg failexit "Error: missing prerequisite command \`${1}'.";
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		fi; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) f5eeee
};
Lucio Andrés Illanes Albornoz (arab, vxp) f5eeee
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
# Clear the environment by unsetting each exported variable except
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
# for those named by the caller. 
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
clear_env_with_except() {
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	_cewe_vfilter="${*}"; _cewe_unset_cmds="$(mktemp -q)";
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	export | while read _cewe_vspec; do
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		set -- ${_cewe_vspec}; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		if ! match_list "${_cewe_vfilter}" " "	\
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
				$(get_prefix_lrg ${1} =); then
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			echo unset $(get_prefix_lrg ${1} =) >> ${_cewe_unset_cmds};
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	done; . "${_cewe_unset_cmds}"; rm -f "${_cewe_unset_cmds}" 2>/dev/null;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	unset _cewe_vfilter _cewe_vspec;
lalbornoz 340f4c
};
lalbornoz 340f4c
lalbornoz 340f4c
fetch() {
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	wget ${WGET_ARGS} ${1};
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	if [ ${#} -eq 2 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		set -- $(get_basename ${1}) "$(compare_hash $(get_basename ${1}) ${2})" ${2};
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		if [ -n "${2}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
			log_msg failexit "Error: hash mismatch for URL \`${1}' (is: ${2}, should be: ${3}.)";
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		fi;
lalbornoz 340f4c
	fi;
lalbornoz 340f4c
};
lalbornoz 340f4c
Lucio Andrés Illanes Albornoz (arab, vxp) 6e940c
compare_hash() {
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	# Push the output of dgst(1SSL) and the caller-supplied hash
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	# value to compare the former with on the pseudo-stack and
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	# shift off# all but the last two positional parameters.
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	# This corresponds to the hash output and caller-supplied
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	# hash values.
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	set -- $(openssl dgst -sha256 ${1}) ${2}; shift $((${#}-2));
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	[ "x${1}" = "x${2}" ] || echo "${1}";
Lucio Andrés Illanes Albornoz (arab, vxp) 6e940c
};
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
compare_hash_manifest() {
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
		if ! compare_hash ${1} ${2}; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
			log_msg failexit "Error: hash mismatch for patch file \`${1}'.";
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		fi; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
	done; return 0;
Lucio Andrés Illanes Albornoz (arab, vxp) f9c386
};
Lucio Andrés Illanes Albornoz (arab, vxp) 6e940c
lalbornoz 340f4c
is_build_script_done() {
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	if [ -n "${ARG_BUILD_STEPS}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		if [ "${ARG_BUILD_STEPS}" = "finish" ]\
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		|| [ -z "${ARG_BUILD_STEPS#ALL}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
			return 1;	# Build
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		elif ! match_list ${ARG_BUILD_STEPS} , ${1}; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
			return 0;	# Skip
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		else
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
			return 1;	# Build
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	elif [ -f ${WORKDIR}/.${2:-$(get_basename ${SCRIPT_FNAME%.build})}.${1} ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		return 0;		# Skip
Lucio Andrés Illanes Albornoz (arab, vxp) f5eeee
	else
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		return 1;		# Build
Lucio Andrés Illanes Albornoz (arab, vxp) f5eeee
	fi;
lalbornoz 340f4c
};
lalbornoz 340f4c
set_build_script_done() {
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	_sbsd_script_fname=${SCRIPT_FNAME##*/};
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	_sbsd_done_fname=${WORKDIR}/.${_sbsd_script_fname%.build};
lalbornoz 340f4c
	while [ $# -ge 1 ]; do
lalbornoz 340f4c
		if [ "x${1#-}" != "x${1}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			rm -f ${_sbsd_done_fname}.${1#-};
lalbornoz 340f4c
		else
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			touch ${_sbsd_done_fname}.${1};
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			log_msg info "Finished build step ${1} of build script \`${_sbsd_script_fname}'.";
lalbornoz 340f4c
		fi; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	done; unset _sbsd_script_fname _sbsd_done_fname;
lalbornoz 340f4c
};
lalbornoz 340f4c
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
log_env_vars() {
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	log_msg info "Variables for this build:";
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	while [ ${_lev_nvar:=0} -lt ${#} ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		_lev_arg="$(eval echo \${${_lev_nvar}})";
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		_lev_arg="${_lev_arg%%=*}";
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		if [ ${#_lev_arg} -gt ${_lev_arg_len_max:=0} ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			_lev_arg_len_max=${#_lev_arg};
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		fi; : $((_lev_nvar+=1));
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	done; unset _lev_nvar _lev_arg;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		log_msg info "$(printf					\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			"%${_lev_arg_len_max}.${_lev_arg_len_max}s=%s"	\
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
			"${1%%=*}" "$(get_var ${1#*=})")";
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		shift;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	done; unset _lev_arg_len_max;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
};
lalbornoz 340f4c
log_msg() {
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	_lm_lvl=${1}; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	case ${_lm_lvl} in
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		failexit) printf "\033[${LOG_MSG_FAIL_COLOUR}m"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 31dc75
		fail) printf "\033[${LOG_MSG_FAIL_COLOUR}m"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 31dc75
		info) printf "\033[${LOG_MSG_INFO_COLOUR}m"; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 31dc75
		succ) printf "\033[${LOG_MSG_SUCC_COLOUR}m"; ;;
lalbornoz 340f4c
	esac;
lalbornoz 340f4c
	if [ $# -gt 1 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) d30b8f
		printf "==> %s %s %s\033[0m\n" "$(date "${TIMESTAMP_FMT}")" "${1}" "$*";
lalbornoz 340f4c
	else
Lucio Andrés Illanes Albornoz (arab, vxp) d30b8f
		printf "==> %s %s\033[0m\n" "$(date "${TIMESTAMP_FMT}")" "${1}";
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	fi; [ ${_lm_lvl} = failexit ] && exit 1 || unset _lm_lvl;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
};
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
match_list() {
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	_ml_cmp="${3}"; push_IFS "${2}"; set -- ${1}; pop_IFS;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		if [ "x${1}" = "x${_ml_cmp}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			unset _ml_cmp; return 0;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		fi; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	done; unset _ml_cmp; return 1;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
};
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
parse_args_into_vars() {
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	_paiv_arg0="${1}"; _paiv_args_valid="${2}"; shift 2;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
	while [ $# -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		case "${1}" in
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		--*)	_paiv_aname="${1#--}";
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			if ! match_list "${_paiv_args_valid}" , "${_paiv_aname%%=*}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
				log_msg failexit "Unknown parameter --${_paiv_aname%%=*} specified.";
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			elif match_start "${_paiv_aname}" "*="; then
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
				_paiv_aval="$(get_postfix "${_paiv_aname}" =)";
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
				_paiv_aname="$(get_prefix_lrg "${_paiv_aname}" =)";
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
			else
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
				_paiv_aval=1;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
			fi;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			set_var $(echo arg_${_paiv_aname} | tr a-z- A-Z_) "${_paiv_aval}";
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
			shift; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		*=*)	set_var "$(get_prefix_lrg "${1}" =)"\
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
				"$(get_postfix "${1}" =)"; shift; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		*)	log_msg failexit "Invalid or unknown command line argument \`${1}'."; ;;
Lucio Andrés Illanes Albornoz (arab, vxp) 1d0876
		esac;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	done; unset _paiv_arg0 _paiv_args_valid _paiv_aname _paiv_aval;
lalbornoz 340f4c
};
lalbornoz 340f4c
lalbornoz 340f4c
parse_with_pkg_name() {
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	PKG_LVL=${1}; PKG_NAME=${2}; shift 2;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	while [ ${#} -ge 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) 75a203
		if [ "x${PKG_NAME}" = "x${1}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			export_vars_subst PKG_LVL${PKG_LVL}_ PKG_ ${PKG_BUILD_VARS};
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			export_vars_subst PKG_$(echo ${PKG_NAME} | tr a-z A-Z)_ PKG_ ${PKG_BUILD_VARS};
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			[ -z "${PKG_URL}" ] && return 1;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			[ -z "${PKG_FNAME}" ] && PKG_FNAME=${PKG_URL##*/};
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			[ -z "${PKG_SUBDIR}" ] && PKG_SUBDIR=${PKG_FNAME%%.tar*};
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			[ -n "${PKG_ENV_VARS_EXTRA}" ] && export ${PKG_ENV_VARS_EXTRA};
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			return 0;
Lucio Andrés Illanes Albornoz (arab, vxp) c49754
		fi; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) c49754
	done; return 1;
lalbornoz 340f4c
};
lalbornoz 340f4c
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
run_cmd_unsplit() {
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	_rcu_cmd=${1}; shift;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	while [ ${#} -gt 0 ]; do
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		[ -n "${1}" ] &&\
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
			_rcu_cmdline="${_rcu_cmdline:+${_rcu_cmdline},}${1}";
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
		shift;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	push_IFS ,; ${_rcu_cmd} ${_rcu_cmdline}; _rcu_rc=$?; pop_IFS;
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
	unset _rcu_cmd _rcu_cmdline; return ${_rcu_rc};
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
};
Lucio Andrés Illanes Albornoz (arab, vxp) 392fef
lalbornoz 340f4c
# vim:filetype=sh