add function to check version

This commit is contained in:
Dmitry Shibanov
2020-10-01 11:03:39 +03:00
parent e32091634e
commit 89bf727a19

View File

@@ -9,16 +9,20 @@ set -e
# Source the helpers for use with the script # Source the helpers for use with the script
source $HELPER_SCRIPTS/os.sh source $HELPER_SCRIPTS/os.sh
verlte() {
sortedVersion=$(echo -e "$1\n$2" | sort -V | head -n1)
[ "$1" = "$sortedVersion" ]
}
function install_android_packages { function install_android_packages {
minimumVersion=$( echo "$1" | sed 's/\.//g' ) minimumVersion=$1
shift shift
toolsArr=("$@") toolsArr=("$@")
for item in ${toolsArr[@]} for item in ${toolsArr[@]}
do do
version=$(echo "${item##*[-;]}" | sed 's/\.//g') version=$(echo "${item##*[-;]}")
echo "version is $version" if verlte $minimumVersion $version
if (( $version >= $minimumVersion ))
then then
echo "Start installing $item" echo "Start installing $item"
echo "y" | ${ANDROID_SDK_ROOT}/tools/bin/sdkmanager $item echo "y" | ${ANDROID_SDK_ROOT}/tools/bin/sdkmanager $item