From 2e24801fe352343083d46230e9b44a2efb5c7278 Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Fri, 16 Sep 2016 01:29:17 -0700 Subject: [PATCH] Cosmetic renaming 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. --- build.sh | 6 +++--- scripts/check_deps.sh | 33 +++++++++++++++++++++++++++++++++ scripts/{common => common.sh} | 2 ++ scripts/dependencies_check | 30 ------------------------------ 4 files changed, 38 insertions(+), 33 deletions(-) mode change 100755 => 100644 scripts/check_deps.sh rename scripts/{common => common.sh} (99%) delete mode 100644 scripts/dependencies_check diff --git a/build.sh b/build.sh index c6abdae..672d98c 100755 --- a/build.sh +++ b/build.sh @@ -156,11 +156,11 @@ export QUILT_NO_DIFF_INDEX=1 export QUILT_NO_DIFF_TIMESTAMPS=1 export QUILT_REFRESH_ARGS="-p ab" -source ${SCRIPT_DIR}/common -source ${SCRIPT_DIR}/dependencies_check +source ${SCRIPT_DIR}/common.sh +source ${SCRIPT_DIR}/check_deps.sh -dependencies_check ${BASE_DIR}/depends +check_deps ${BASE_DIR}/depends mkdir -p ${WORK_DIR} log "Begin ${BASE_DIR}" diff --git a/scripts/check_deps.sh b/scripts/check_deps.sh old mode 100755 new mode 100644 index e69de29..e13ff8e --- a/scripts/check_deps.sh +++ b/scripts/check_deps.sh @@ -0,0 +1,33 @@ +# 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 diff --git a/scripts/common b/scripts/common.sh similarity index 99% rename from scripts/common rename to scripts/common.sh index 6db58e2..0d2e837 100644 --- a/scripts/common +++ b/scripts/common.sh @@ -1,3 +1,5 @@ +# bash # + log (){ date +"[%T] $@" | tee -a ${LOG_FILE} } diff --git a/scripts/dependencies_check b/scripts/dependencies_check deleted file mode 100644 index 4817561..0000000 --- a/scripts/dependencies_check +++ /dev/null @@ -1,30 +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 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 -}