burrow-pi-img/scripts/dependencies_check
Daniel F. Dickinson 9efaea5036 Enable syntax highlighting/linting for scriptlets
Various editors depend on the shebang line to determine what language
to use for syntax highlighting and/or linting.  Therefore add one.  It
is ignored when sourcing and the scriplets are not executable so the
shebang will never be used.

Signed-off-by: Daniel F. Dickinson <cshored@thecshore.com>
2020-01-16 10:44:46 -05:00

41 lines
958 B
Bash

#!/bin/bash
# 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
}