2e24801fe3
Renamed function dependencies_check to check_deps. Also renamed files in scripts/ to have a .sh suffix which are bash shell snippits: dependencies_check -> check_deps.sh common -> common.sh Note check_deps.sh already existed in the tree but was an empty file probably intended for the function now contained within. Also added a comment at the top of the .sh files which are sourced so that syntax-highlighting editors which distinguish between different /bin/sh syntaxes have a clue to use the bash variant.
34 lines
775 B
Bash
34 lines
775 B
Bash
# bash #
|
|
|
|
# check_deps
|
|
# $@ Dependnecy 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).
|
|
check_deps()
|
|
{
|
|
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 "Reqired dependencies not installed"
|
|
echo
|
|
echo "This can be resolved on Debian/Raspbian systems by installing:"
|
|
echo "$missing"
|
|
false
|
|
fi
|
|
}
|
|
export -f check_deps
|