aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/dependencies_check
blob: 375512b75153b4b67ee18a347c3b96cca675e4f7 (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
# dependencies_check
# $@	Dependency files to check
#
# Each dependency is in the form of a tool to test for, optionally followed by
# a : and the name of a package if the package on a Debian-ish system is not
# named for the tool (i.e., qemu-user-static).
dependencies_check()
{
	local depfile deps missing

	for depfile in "$@"; do
		if [[ -e "$depfile" ]]; then
			deps="$(sed -f "${SCRIPT_DIR}/remove-comments.sed" < "${BASE_DIR}/depends")"

		fi
		for dep in $deps; do
			if ! hash "${dep%:*}" 2>/dev/null; then
				missing="${missing:+$missing }${dep#*:}"
			fi
		done
	done

	if [[ "$missing" ]]; then
		echo "Required dependencies not installed"
		echo
		echo "This can be resolved on Debian/Raspbian systems by installing:"
		echo "$missing"
		false
	fi


	if ! grep -q "/proc/sys/fs/binfmt_misc" /proc/mounts; then
		echo "Module binfmt_misc not loaded in host"
		echo "Please run:"
		echo "  sudo modprobe binfmt_misc"
		exit 1
	fi
}