Handle dependencies using a loop
authorSofian Brabez <sofian.brabez@gonitro.com>
Fri, 25 Jan 2019 12:03:35 +0000 (12:03 +0000)
committerSofian Brabez <sofian.brabez@gonitro.com>
Fri, 25 Jan 2019 12:55:30 +0000 (12:55 +0000)
release.sh

index ffa513de727614026386bf6eda9c1420cc5a9ad8..a9d81a753847033ec58ed9b35d14383e1cc86e32 100755 (executable)
@@ -1,16 +1,22 @@
 #!/bin/bash
 
-set -e
+set -o errexit
+set -o nounset
+set -o pipefail
 
-[ ! -f `which gpg` ] && {
-    echo 2>&1 "You need to install gnupg: brew install gnupg"
+die() {
+    echo "$1" >&2
     exit 2
 }
 
-[ ! -f `which deb-s3` ] && {
-    echo 2>&1 "You need to install deb-s3: gem install deb-s3"
-    exit 2
-}
+declare -a deps=(gpg deb-s3)
+
+for dep in ${deps[*]}
+do
+    [[ ! -f `which $dep` ]] && {
+        die "You need to install: $dep"
+    }
+done
 
 COMMIT=`(cd docker-gc && git rev-parse --short HEAD)`
 VERSION="2:`cat ${PWD}/docker-gc/version.txt`~${COMMIT}"