CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
orangepi-xunlong

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

GitHub Repository: orangepi-xunlong/orangepi-build
Path: blob/next/external/packages/raspi/scripts/dependencies_check
Views: 3959
# 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 we're building on a native arm platform, we don't need to check for
    # binfmt_misc or require it to be loaded.

	binfmt_misc_required=1

	case $(uname -m) in
		aarch64)
			binfmt_misc_required=0
			;;
		arm*)
			binfmt_misc_required=0
			;;
	esac

	if [[ "${binfmt_misc_required}" == "1" ]]; then
		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
	fi
}