From 42613a384f285df6535d6d5dca877ae5c9eae157 Mon Sep 17 00:00:00 2001 From: Anthony Scemama Date: Thu, 14 Jan 2016 18:15:54 +0100 Subject: [PATCH] install_ocaml.sh corrected --- install/scripts/install_ocaml.sh | 43 ++++++++++++++++++++++++-------- 1 file changed, 32 insertions(+), 11 deletions(-) diff --git a/install/scripts/install_ocaml.sh b/install/scripts/install_ocaml.sh index 3f48b4b3..65a0f70e 100755 --- a/install/scripts/install_ocaml.sh +++ b/install/scripts/install_ocaml.sh @@ -13,18 +13,42 @@ export LIBRARY_PATH="${QP_ROOT}"/lib:"${LIBRARY_PATH}" export LD_LIBRARY_PATH="${QP_ROOT}"/lib:"${LD_LIBRARY_PATH}" # return 0 if program version is equal or greater than check version -check_version() -{ - local version=$1 check=$2 - local winner=$(echo -e "$version\n$check" | sed '/^$/d' | sort -nr | head -1) - [[ "$winner" = "$version" ]] && return 0 - return 1 +check_version () { + if [[ $1 == $2 ]] + then + return 0 + fi + local IFS=. + local i ver1=($1) ver2=($2) + # fill empty fields in ver1 with zeros + for ((i=${#ver1[@]}; i<${#ver2[@]}; i++)) + do + ver1[i]=0 + done + for ((i=0; i<${#ver1[@]}; i++)) + do + if [[ -z ${ver2[i]} ]] + then + # fill empty fields in ver2 with zeros + ver2[i]=0 + fi + if ((10#${ver1[i]} > 10#${ver2[i]})) + then + return 1 + fi + if ((10#${ver1[i]} < 10#${ver2[i]})) + then + return 2 + fi + done + return 0 } + i=$(gcc -dumpversion) -check_version i 4.6 -if [[ $? -ne 0 ]] +check_version 4.6 $i +if [[ $? == 1 ]] then echo "GCC version $(gcc -dumpversion) too old. GCC >= 4.6 required." exit 1 @@ -53,6 +77,3 @@ NCPUs=$(cat /proc/cpuinfo | grep -i MHz | wc -l) ${QP_ROOT}/bin/opam install -j ${NCPUs} ${PACKAGES} -y -q || exit 1 rm -f ../_build/ocaml.log -exit 0 - -