@@ -6,7 +6,127 @@ current_script_path=${BASH_SOURCE[0]}
66plugin_dir=$( dirname " $( dirname " ${current_script_path} " ) " )
77
88# shellcheck source=../lib/utils.bash
9- source " ${plugin_dir} /lib/utils.bash"
9+ . " ${plugin_dir} /lib/utils.bash"
10+
11+ TOOL_NAME=" awscli"
12+ TOOL_TEST=" aws --version"
13+
14+ install_source () {
15+ local version download_path install_path major_version os_distribution make_concurrency tool_cmd
16+ version=" $1 "
17+ download_path=" $2 "
18+ install_path=" $3 "
19+ make_concurrency=" $4 "
20+ major_version=" ${version: 0: 1} "
21+ tool_cmd=" $( echo " ${TOOL_TEST} " | cut -d' ' -f1) "
22+
23+ (
24+ if [[ " ${major_version} " = " 2" ]]; then
25+ os_distribution=" $( uname -s) "
26+
27+ if [[ " ${os_distribution} " = " Linux" || " ${os_distribution} " = " Darwin" ]]; then
28+ pushd " ${download_path} "
29+ ./configure --prefix=" ${install_path} " --with-download-deps --with-install-type=portable-exe
30+ make --jobs " ${make_concurrency} "
31+ make install
32+ popd
33+ else
34+ fail " asdf-${TOOL_NAME} does not support installing from source for OS distribution ${os_distribution} "
35+ fi
36+ else
37+ fail " asdf-${TOOL_NAME} does not support installing from source for major version v${major_version} "
38+ fi
39+
40+ test -x " ${install_path} /bin/${tool_cmd} " || fail " Expected ${install_path} /bin/${tool_cmd} to be executable."
41+ echo " asdf-${TOOL_NAME} ${version} installation was successful!"
42+ ) || (
43+ rm -rf " ${install_path} "
44+ fail " An error ocurred while installing awscli ${version} ."
45+ )
46+ }
47+
48+ install_release () {
49+ local version download_path install_path major_version os_distribution os_arch
50+ version=" $1 "
51+ download_path=" $2 "
52+ install_path=" $3 "
53+ major_version=" ${version: 0: 1} "
54+
55+ (
56+ if [[ " ${major_version} " = " 1" ]]; then
57+ install_v1_bundled_installer " ${download_path} " " ${install_path} "
58+ elif [[ " ${major_version} " = " 2" ]]; then
59+ os_distribution=" $( uname -s) "
60+ os_arch=" $( uname -m) "
61+
62+ if [[ " ${os_distribution} " = " Linux" ]]; then
63+ if [[ " ${os_arch} " = " x86_64" || " ${os_arch} " = " aarch64" ]]; then
64+ install_v2_linux_bundled_installer " ${download_path} " " ${install_path} "
65+ else
66+ fail " asdf-${TOOL_NAME} does not support ${os_arch} on ${os_distribution} "
67+ fi
68+ elif [[ " ${os_distribution} " = " Darwin" ]]; then
69+ install_v2_macos_bundled_installer " ${download_path} " " ${install_path} "
70+ elif [[ " ${os_distribution} " = " Windows_NT" ]]; then
71+ install_v2_windows_bundled_installer " ${download_path} " " ${install_path} "
72+ else
73+ fail " asdf-${TOOL_NAME} does not support OS distribution ${os_distribution} "
74+ fi
75+ else
76+ fail " asdf-${TOOL_NAME} does not support major version v${major_version} "
77+ fi
78+
79+ local tool_cmd
80+ tool_cmd=" $( echo " ${TOOL_TEST} " | cut -d' ' -f1) "
81+ test -x " ${install_path} /bin/${tool_cmd} " || fail " Expected ${install_path} /bin/${tool_cmd} to be executable."
82+ echo " asdf-${TOOL_NAME} ${version} installation was successful!"
83+ ) || (
84+ rm -rf " ${install_path} "
85+ fail " An error ocurred while installing awscli ${version} ."
86+ )
87+ }
88+
89+ install_v1_bundled_installer () {
90+ local download_path install_path
91+ download_path=" $1 "
92+ install_path=" $2 "
93+ # requires python 3.7+ https://docs.aws.amazon.com/cli/v1/userguide/cli-chap-install.html#cli-chap-install-python
94+ " ${download_path} " /awscli-bundle/install --install-dir " ${install_path} "
95+ }
96+
97+ install_v2_linux_bundled_installer () {
98+ local download_path install_path
99+ download_path=" $1 "
100+ install_path=" $2 "
101+ # requires glibc, groff, less
102+ " ${download_path} " /aws/install --install-dir " ${install_path} " --bin-dir " ${install_path} /bin"
103+ }
104+
105+ # The official AWS CLI directions suggest using installer and a choices.xml
106+ # but I was unable to find a deterministic way to make that work
107+ # so copypasta
108+ install_v2_macos_bundled_installer () {
109+ local download_path install_path
110+ download_path=" $1 "
111+ install_path=" $2 "
112+ # requires rosetta on M1 macs
113+
114+ mkdir -p " ${install_path} /bin"
115+ pkgutil --expand-full " ${download_path} /AWSCLIV2.pkg" " ${download_path} /tmp-awscliv2"
116+ cp -a " ${download_path} /tmp-awscliv2/aws-cli.pkg/Payload/aws-cli/" " ${install_path} "
117+ ln -snf " ${install_path} /aws" " ${install_path} /bin/aws"
118+ ln -snf " ${install_path} /aws_completer" " ${install_path} /bin/aws_completer"
119+ rm -rf " ${download_path} /tmp-awscliv2"
120+ }
121+
122+ install_v2_windows_bundled_installer () {
123+ local download_path install_path
124+ download_path=" $1 "
125+ install_path=" $2 "
126+
127+ # requires curl, msiexec
128+ msiexec.exe /i " ${download_path} /AWSCLIV2.msi" " INSTALLDIR=${ASDF_INSTALL_PATH} " MSIINSTALLPERUSER=1
129+ }
10130
11131# Preserve compatibilty with older ASDF versions
12132# https://github.com/asdf-vm/asdf/pull/669#issuecomment-600330467
0 commit comments