From a37fef136b62de345eea3fd7c184c14f930f8d4b Mon Sep 17 00:00:00 2001 From: Marcel Date: Mon, 14 Jul 2014 18:56:54 +0200 Subject: [PATCH 1/3] check if variables are empty to be more failsafe --- bootstrap.sh | 48 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 15 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index ffbb01537..425530e2a 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -21,6 +21,24 @@ TOX_CORE_DIR=libtoxcore-latest # if this script gets the parameter -t or --tox TOX_ONLY=false +if [ -z "$BASE_DIR" ]; then + echo "internal error detected!" + echo "BASE_DIR should not be empty... aborting" + exit 1 +fi + +if [ -z "$SODIUM_DIR" ]; then + echo "internal error detected!" + echo "SODIUM_DIR should not be empty... aborting" + exit 1 +fi + +if [ -z "$TOX_CORE_DIR" ]; then + echo "internal error detected!" + echo "TOX_CORE_DIR should not be empty... aborting" + exit 1 +fi + ########## check input parameters ########## @@ -34,27 +52,27 @@ if [ $# -ge 1 ] ; then fi # print help - echo "Use this script to install/update libsodium and libtoxcore in ${INSTALL_DIR}" - echo "" - echo "usage:" - echo " ${0} [-t|--tox|-h|--help]" - echo "" - echo "parameters:" - echo " -h|--help: displays this help" - echo " -t|--tox : only install/update libtoxcore" - echo " requires an already installed libsodium" - echo "" - echo "example usages:" - echo " ${0} -- to install libsodium and libtoxcore" - echo " ${0} -t -- to update already installed libtoxcore" - exit 1 + echo "Use this script to install/update libsodium and libtoxcore in ${INSTALL_DIR}" + echo "" + echo "usage:" + echo " ${0} [-t|--tox|-h|--help]" + echo "" + echo "parameters:" + echo " -h|--help: displays this help" + echo " -t|--tox : only install/update libtoxcore" + echo " requires an already installed libsodium" + echo "" + echo "example usages:" + echo " ${0} -- to install libsodium and libtoxcore" + echo " ${0} -t -- to update already installed libtoxcore" + exit 1 fi fi ############### prepare step ############### -# create INSTALL_DIR directory if necessary +# create BASE_DIR directory if necessary mkdir -p ${BASE_DIR} # maybe an earlier run of this script failed From 0572d44622b9d29a38bf8e646155064bfe5f0030 Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 15 Jul 2014 00:16:20 +0200 Subject: [PATCH 2/3] use osx compatible command to get absolute path of script --- bootstrap.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/bootstrap.sh b/bootstrap.sh index 425530e2a..8fc29574b 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -2,8 +2,7 @@ ################ parameters ################ # directory where the script is located -SCRIPT_NAME=$(readlink -f $0) -SCRIPT_DIR=`dirname $SCRIPT_NAME` +SCRIPT_DIR=$( cd $(dirname $0); pwd -P) # directory where dependencies will be installed INSTALL_DIR=libs From b501f772d89548a37a8a86a3f7158ea113d997de Mon Sep 17 00:00:00 2001 From: Marcel Date: Tue, 15 Jul 2014 08:20:08 +0200 Subject: [PATCH 3/3] fixed names of variables --- bootstrap.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bootstrap.sh b/bootstrap.sh index 8fc29574b..cc25129f8 100755 --- a/bootstrap.sh +++ b/bootstrap.sh @@ -78,7 +78,7 @@ mkdir -p ${BASE_DIR} # thus we should remove the cloned repositories # if exists, otherwise cloning them may fail rm -rf ${BASE_DIR}/${SODIUM_DIR} -rm -rf ${SBASE_DIR}/${TOX_CORE} +rm -rf ${BASE_DIR}/${TOX_CORE_DIR}