midipix / build / midipix_build

Forked from build/midipix_build 4 years ago
Clone

Blame subr/pre_check.subr

Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
#
Lucio Andrés Illanes Albornoz (arab, vxp) 802215
# set -o errexit -o noglob are assumed.
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
#
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
Lucio Andrés Illanes Albornoz (arab, vxp) c27bea
pre_check() {
Lucio Andrés Illanes Albornoz (arab, vxp) 802215
	local __ _exit;
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
	for __ in ${CHECK_PATH_VARS}; do
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
		if [ -z "${___:=$(get_var_unsafe "${__}")}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
			log_msg failexit "Error: variable \`${__}' is empty or unset.";
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
		elif [ "${___#* *}" != "${___}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
			log_msg failexit "Error: variable \`${__}' contains one or more whitespace characters.";
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
	for __ in ${CHECK_PREREQ_CMDS} $(eval echo ${CHECK_PREREQ_FILES_DYNAMIC}) ${CHECK_PREREQ_FILES}; do
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
		if [ "${__#/}" != "${__}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
			if [ ! -e "${__}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
				log_msg fail "Error: missing prerequisite file \`${__}'.";
Lucio Andrés Illanes Albornoz (arab, vxp) 802215
				_exit=1;
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
			fi;
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
		else
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
			if ! test_cmd "${__}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
				log_msg fail "Error: missing prerequisite command \`${__}'.";
Lucio Andrés Illanes Albornoz (arab, vxp) 802215
				_exit=1;
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
			fi;
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
	for __ in ${CHECK_PREREQ_PERL_MODULES}; do
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
		if ! perl -M"${__}" -e "" 2>/dev/null; then
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
			log_msg fail "Error: missing prerequisite Perl module \`${__}'.";
Lucio Andrés Illanes Albornoz (arab, vxp) 802215
			_exit=1;
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
		fi;
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
	done;
Lucio Andrés Illanes Albornoz (arab, vxp) 802215
	if [ ${_exit:-0} = 1 ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
		exit 1;
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
	fi;
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
};
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
Lucio Andrés Illanes Albornoz (arab, vxp) d1adc7
# vim:filetype=sh