install-cmake-test.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #!/usr/bin/env bash
  2. source="${BASH_SOURCE[0]}"
  3. scriptroot="$( cd -P "$( dirname "$source" )" && pwd )"
  4. . $scriptroot/common-library.sh
  5. base_uri=
  6. install_path=
  7. version=
  8. clean=false
  9. force=false
  10. download_retries=5
  11. retry_wait_time_seconds=30
  12. while (($# > 0)); do
  13. lowerI="$(echo $1 | tr "[:upper:]" "[:lower:]")"
  14. case $lowerI in
  15. --baseuri)
  16. base_uri=$2
  17. shift 2
  18. ;;
  19. --installpath)
  20. install_path=$2
  21. shift 2
  22. ;;
  23. --version)
  24. version=$2
  25. shift 2
  26. ;;
  27. --clean)
  28. clean=true
  29. shift 1
  30. ;;
  31. --force)
  32. force=true
  33. shift 1
  34. ;;
  35. --downloadretries)
  36. download_retries=$2
  37. shift 2
  38. ;;
  39. --retrywaittimeseconds)
  40. retry_wait_time_seconds=$2
  41. shift 2
  42. ;;
  43. --help)
  44. echo "Common settings:"
  45. echo " --baseuri <value> Base file directory or Url wrom which to acquire tool archives"
  46. echo " --installpath <value> Base directory to install native tool to"
  47. echo " --clean Don't install the tool, just clean up the current install of the tool"
  48. echo " --force Force install of tools even if they previously exist"
  49. echo " --help Print help and exit"
  50. echo ""
  51. echo "Advanced settings:"
  52. echo " --downloadretries Total number of retry attempts"
  53. echo " --retrywaittimeseconds Wait time between retry attempts in seconds"
  54. echo ""
  55. exit 0
  56. ;;
  57. esac
  58. done
  59. tool_name="cmake-test"
  60. tool_os=$(GetCurrentOS)
  61. tool_folder="$(echo $tool_os | tr "[:upper:]" "[:lower:]")"
  62. tool_arch="x86_64"
  63. tool_name_moniker="$tool_name-$version-$tool_os-$tool_arch"
  64. tool_install_directory="$install_path/$tool_name/$version"
  65. tool_file_path="$tool_install_directory/$tool_name_moniker/bin/$tool_name"
  66. shim_path="$install_path/$tool_name.sh"
  67. uri="${base_uri}/$tool_folder/$tool_name/$tool_name_moniker.tar.gz"
  68. # Clean up tool and installers
  69. if [[ $clean = true ]]; then
  70. echo "Cleaning $tool_install_directory"
  71. if [[ -d $tool_install_directory ]]; then
  72. rm -rf $tool_install_directory
  73. fi
  74. echo "Cleaning $shim_path"
  75. if [[ -f $shim_path ]]; then
  76. rm -rf $shim_path
  77. fi
  78. tool_temp_path=$(GetTempPathFileName $uri)
  79. echo "Cleaning $tool_temp_path"
  80. if [[ -f $tool_temp_path ]]; then
  81. rm -rf $tool_temp_path
  82. fi
  83. exit 0
  84. fi
  85. # Install tool
  86. if [[ -f $tool_file_path ]] && [[ $force = false ]]; then
  87. echo "$tool_name ($version) already exists, skipping install"
  88. exit 0
  89. fi
  90. DownloadAndExtract $uri $tool_install_directory $force $download_retries $retry_wait_time_seconds
  91. if [[ $? != 0 ]]; then
  92. Write-PipelineTelemetryError -category 'NativeToolsBootstrap' 'Installation failed'
  93. exit 1
  94. fi
  95. # Generate Shim
  96. # Always rewrite shims so that we are referencing the expected version
  97. NewScriptShim $shim_path $tool_file_path true
  98. if [[ $? != 0 ]]; then
  99. Write-PipelineTelemetryError -category 'NativeToolsBootstrap' 'Shim generation failed'
  100. exit 1
  101. fi
  102. exit 0