Move dependency check function to script
This commit is contained in:
parent
8d86599ae0
commit
8debf78e21
2 changed files with 29 additions and 31 deletions
31
build.sh
31
build.sh
|
@ -7,7 +7,6 @@ export PASSWORD='password'
|
|||
|
||||
export BASE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
export SCRIPT_DIR="$BASE_DIR/scripts"
|
||||
export FUNCTIONS_DIR="$BASE_DIR/functions"
|
||||
export DEPLOY_DIR="$BASE_DIR/deploy"
|
||||
export ROOTFS_DIR="$BASE_DIR/rootfs"
|
||||
export MOUNT_DIR="$BASE_DIR/mnt"
|
||||
|
@ -21,7 +20,35 @@ export QUILT_NO_DIFF_INDEX=1
|
|||
export QUILT_NO_DIFF_TIMESTAMPS=1
|
||||
export QUILT_REFRESH_ARGS='-p ab'
|
||||
|
||||
source "$FUNCTIONS_DIR/dependencies_check.sh"
|
||||
# dependencies_check
|
||||
# $@ 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).
|
||||
dependencies_check() {
|
||||
local missing
|
||||
|
||||
if [[ -f "$1" ]]; then
|
||||
for dep in $(cat "$1"); do
|
||||
if ! hash ${dep%:*} 2>/dev/null; then
|
||||
missing="${missing:+$missing }${dep#*:}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ "$missing" ]]; then
|
||||
tput setaf 1 # Red color
|
||||
echo 'Reqired dependencies not installed.'
|
||||
echo 'This can be resolved on Debian/Raspbian systems by installing the following packages:'
|
||||
for package_name in $missing; do
|
||||
echo " * $package_name"
|
||||
done
|
||||
tput sgr0 # No color
|
||||
|
||||
false
|
||||
fi
|
||||
}
|
||||
|
||||
on_chroot() {
|
||||
local proc_fs="$ROOTFS_DIR/proc"
|
||||
|
|
|
@ -1,29 +0,0 @@
|
|||
# dependencies_check
|
||||
# $@ 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).
|
||||
dependencies_check() {
|
||||
local missing
|
||||
|
||||
if [[ -f "$1" ]]; then
|
||||
for dep in $(cat "$1"); do
|
||||
if ! hash ${dep%:*} 2>/dev/null; then
|
||||
missing="${missing:+$missing }${dep#*:}"
|
||||
fi
|
||||
done
|
||||
fi
|
||||
|
||||
if [[ "$missing" ]]; then
|
||||
tput setaf 1 # Red color
|
||||
echo 'Reqired dependencies not installed.'
|
||||
echo 'This can be resolved on Debian/Raspbian systems by installing the following packages:'
|
||||
for package_name in $missing; do
|
||||
echo " * $package_name"
|
||||
done
|
||||
tput sgr0 # No color
|
||||
|
||||
false
|
||||
fi
|
||||
}
|
Reference in a new issue