summaryrefslogtreecommitdiffhomepage
path: root/subr/build_checks.subr
blob: 1955d585fe6961a4870c970b9040876aa811919a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#
# set -o noglob is assumed.
#

build_checks() {
	local __="" _exit="" _pname="";
	for __ in ${DEFAULT_CHECK_PATH_VARS}; do
		if [ -z "${___:=$(ex_rtl_get_var_unsafe "${__}")}" ]; then
			ex_rtl_log_msg failexit "Error: variable \`${__}' is empty or unset.";
		elif [ "${___#* *}" != "${___}" ]; then
			ex_rtl_log_msg failexit "Error: variable \`${__}' contains one or more whitespace characters.";
		fi;
	done;
	for __ in ${DEFAULT_CHECK_PREREQ_CMDS} $(eval echo ${DEFAULT_CHECK_PREREQ_FILES_DYNAMIC}) ${DEFAULT_CHECK_PREREQ_FILES}; do
		if [ "${__#/}" != "${__}" ]; then
			if [ ! -e "${__}" ]; then
				ex_rtl_log_msg fail "Error: missing prerequisite file \`${__}'.";
				_exit=1;
			fi;
		else
			if ! ex_rtl_test_cmd "${__}"; then
				ex_rtl_log_msg fail "Error: missing prerequisite command \`${__}'.";
				_exit=1;
			fi;
		fi;
	done;
	for __ in ${DEFAULT_CHECK_PREREQ_PERL_MODULES}; do
		if ! perl -M"${__}" -e "" 2>/dev/null; then
			ex_rtl_log_msg fail "Error: missing prerequisite Perl module \`${__}'.";
			_exit=1;
		fi;
	done;
	if [ ${_exit:-0} = 1 ]; then
		exit 1;
	fi;
	if ex_rtl_lmatch "${ARG_CLEAN_BUILDS}" , prefix; then
		ex_rtl_log_msg info "-C prefix specified, cleaning prefix...";
		for _pname in ${DEFAULT_CLEAR_PREFIX_PATHS}; do
			ex_rtl_fileop rm ${PREFIX}/${_pname};
		done;
	fi;
};

# vim:filetype=sh