From fde6151641a8bb62029040e1a84775de3b5bd333 Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Thu, 23 Jan 2020 02:15:32 +1100 Subject: install_deps.sh: fix versions such as 1.6_RC2 failing to compare This is stripped off since it causes an error when evaluating the strings as numbers. --- build_files/build_environment/install_deps.sh | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) (limited to 'build_files') diff --git a/build_files/build_environment/install_deps.sh b/build_files/build_environment/install_deps.sh index d4f05c4bab2..33572ddb183 100755 --- a/build_files/build_environment/install_deps.sh +++ b/build_files/build_environment/install_deps.sh @@ -993,14 +993,22 @@ download() { fi } +# Remove suffix such as '1.3_RC2', keeping only '1.3'. +# Needed for numeric comparisons. +version_sanitize() { + echo "$(sed -r 's/^([^_]+).*/\1/' <<< \"$1\")" +} + # Return 0 if $1 = $2 (i.e. 1.01.0 = 1.1, but 1.1.1 != 1.1), else 1. # $1 and $2 should be version numbers made of numbers only. version_eq() { local IFS='.' + local VER_1=$(version_sanitize "$1") + local VER_2=$(version_sanitize "$2") # Split both version numbers into their numeric elements. - arr1=( $1 ) - arr2=( $2 ) + arr1=( $VER_1 ) + arr2=( $VER_2 ) ret=1 @@ -1010,8 +1018,8 @@ version_eq() { _t=$count1 count1=$count2 count2=$_t - arr1=( $2 ) - arr2=( $1 ) + arr1=( $VER_2 ) + arr2=( $VER_1 ) fi ret=0 @@ -1062,10 +1070,12 @@ version_ge_lt() { # $1 should be at least as long as $2! version_match() { local IFS='.' + local VER_1=$(version_sanitize "$1") + local VER_2=$(version_sanitize "$2") # Split both version numbers into their numeric elements. - arr1=( $1 ) - arr2=( $2 ) + arr1=( $VER_1 ) + arr2=( $VER_2 ) ret=1 -- cgit v1.2.3