mirror of
https://github.com/LCPQ/quantum_package
synced 2025-01-03 18:16:12 +01:00
Beter version handle
This commit is contained in:
parent
626f4aafbd
commit
63315d459c
@ -13,14 +13,38 @@ export LIBRARY_PATH="${QP_ROOT}"/lib:"${LIBRARY_PATH}"
|
|||||||
export LD_LIBRARY_PATH="${QP_ROOT}"/lib:"${LD_LIBRARY_PATH}"
|
export LD_LIBRARY_PATH="${QP_ROOT}"/lib:"${LD_LIBRARY_PATH}"
|
||||||
|
|
||||||
# return 0 if program version is equal or greater than check version
|
# return 0 if program version is equal or greater than check version
|
||||||
check_version()
|
check_version () {
|
||||||
{
|
if [[ $1 == $2 ]]
|
||||||
local version=$1 check=$2
|
then
|
||||||
local winner=$(echo -e "$version\n$check" | sed '/^$/d' | sort -nr | head -1)
|
return 0
|
||||||
[[ "$winner" = "$version" ]] && return 0
|
fi
|
||||||
return 1
|
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)
|
i=$(gcc -dumpversion)
|
||||||
|
|
||||||
check_version i 4.6
|
check_version i 4.6
|
||||||
|
Loading…
Reference in New Issue
Block a user