Blame subr/ex_setup_checks.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) 32ad21
ex_setup_checks() {
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) 32ad21
		if [ -z "${___:=$(ex_get_var_unsafe "${__}")}" ]; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
			ex_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) 32ad21
			ex_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) 32ad21
				ex_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) 32ad21
			if ! ex_test_cmd "${__}"; then
Lucio Andrés Illanes Albornoz (arab, vxp) 32ad21
				ex_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) 32ad21
			ex_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