From 3866e8752a06524d5ff4faf0c96cd3b8224ebbe5 Mon Sep 17 00:00:00 2001 From: mxmehl Date: Thu, 19 Jan 2017 19:19:53 +0100 Subject: [PATCH] adding dependency check; improve help display --- fsfe-preview.sh | 27 ++++++++++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/fsfe-preview.sh b/fsfe-preview.sh index 8f70461..59c28fb 100755 --- a/fsfe-preview.sh +++ b/fsfe-preview.sh @@ -25,6 +25,24 @@ # ####################################################################### +# Check dependencies (stolen from build_main.sh) +deperrors='' +for depend in realpath rsync xsltproc xmllint sed find egrep grep wc make tee date iconv; do + if ! which "$depend" >/dev/null 2>&1; then + deperrors="$depend $deperrors" + fi +done +if [ -n "$deperrors" ]; then + printf '\033[1;31m' + cat <<-EOF + The build script depends on some other programs to function. + Not all of those programs could be located on your system. + Please use your package manager to install the following programs: + EOF + printf '\n\033[0;31m%s\n' "$deperrors" + exit 1 +fi >>/dev/stderr + ROOT=$(dirname "$(readlink -f "$0")") if [ ! -e "$ROOT"/config.cfg ]; then echo "Missing config.cfg file. Edit and rename config.cfg.sample"; exit 1; fi source "$ROOT"/config.cfg @@ -37,12 +55,15 @@ if [ "$1" = "" ]; then echo "Usage: " echo echo "$self file.en.xhtml" - echo " -- build single XHTML file from your source to the local web directory" - echo " the destination will be on the same relative level of the selected XHTML file" + echo " -- build single XHTML file from your source to the local web " + echo " directory" + echo " The destination will be on the same relative level of the " + echo " selected XHTML file" echo " If not a XHTML file, it will be copied to the web directory" echo echo "$self --copy picture.png look/style.css" - echo " -- Just copies several files to the local web directory without even trying to build them" + echo " -- Just copies several files to the local web directory without " + echo " even trying to build them" exit 0 fi