summaryrefslogtreecommitdiffhomepage
path: root/subr/pre_setup_env.subr
blob: d5de2772eea1cacadf84856686f8a0732f41d6a1 (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
#
# set -o errexit -o noglob are assumed.
#

pre_setup_env() {
	local __;
	if [ -z "${BUILD_CPUS}" ]\
	&& [ -e /proc/cpuinfo ]; then
		BUILD_CPUS=$(awk '/^processor/{cpus++} END{print cpus}' /proc/cpuinfo);
	fi;
	for __ in ${HOME}/midipix_build.vars ../midipix_build.vars ./vars/build.vars; do
		[ -e ${__} ] && . ${__};
	done;
	if [ ${ARG_IPV4_ONLY:-0} -eq 1 ]; then
		WGET_ARGS="-4${WGET_ARGS:+ ${WGET_ARGS}}";
	elif [ ${ARG_IPV6_ONLY:-0} -eq 1 ]; then
		WGET_ARGS="-6${WGET_ARGS:+ ${WGET_ARGS}}";
	fi;
	for __ in $(export | sed -e 's/^export //' -e 's/=.*$//'); do
		if ! lmatch "${CLEAR_ENV_VARS_EXCEPT}" " " "${__}"; then
			unset "${__}";
		fi;
	done;
};

# vim:filetype=sh