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