├── .editorconfig ├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ ├── bug_report.md │ └── feature_request.md ├── PULL_REQUEST │ └── pull_request_template.md ├── dependabot.yml └── workflows │ ├── build.yml │ ├── lint.yml │ ├── release.yml │ └── semantic-pr.yml ├── .tool-versions ├── CHANGELOG.md ├── CONTRIBUTING.md ├── LICENSE ├── README.md ├── asdf-awscli.code-workspace ├── bin ├── download ├── install └── list-all ├── lib └── utils.bash └── scripts ├── format.bash └── lint.bash /.editorconfig: -------------------------------------------------------------------------------- 1 | root = true 2 | 3 | [*] 4 | indent_style = space 5 | indent_size = 2 6 | charset = utf-8 7 | trim_trailing_whitespace = true 8 | insert_final_newline = true 9 | 10 | [*.bash] 11 | indent_style = tab 12 | -------------------------------------------------------------------------------- /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: [MetricMike] 2 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "" 5 | labels: bug 6 | assignees: "" 7 | --- 8 | 9 | **Describe the bug** 10 | 11 | 12 | 13 | **Steps to reproduce** 14 | 15 | 16 | 17 | **Expected behavior** 18 | 19 | 20 | 21 | **Screenshots** 22 | 23 | 24 | 25 | **Additional context** 26 | 27 | 28 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "" 5 | labels: enhancement 6 | assignees: "" 7 | --- 8 | 9 | **Is your feature request related to a problem? Please describe.** 10 | 11 | 12 | 13 | **Describe the solution you'd like** 14 | 15 | 16 | 17 | **Describe alternatives you've considered** 18 | 19 | 20 | 21 | **Additional context** 22 | 23 | 24 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST/pull_request_template.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | ## Description 4 | 5 | 6 | 7 | ## Motivation and Context 8 | 9 | 10 | 11 | 12 | ## Types of changes 13 | 14 | 15 | 16 | - [ ] Bug fix (non-breaking change which fixes an issue) 17 | - [ ] New feature (non-breaking change which adds functionality) 18 | - [ ] Breaking change (fix or feature that would cause existing functionality to change) 19 | 20 | ## Usage examples 21 | 22 | 23 | 24 | ## How Has This Been Tested? 25 | 26 | 27 | 28 | ## Checklist: 29 | 30 | 31 | 32 | 33 | - [ ] I have updated the documentation accordingly. 34 | - [ ] I have added tests to cover my changes. 35 | -------------------------------------------------------------------------------- /.github/dependabot.yml: -------------------------------------------------------------------------------- 1 | # .github/dependabot.yml 2 | version: 2 3 | updates: 4 | - package-ecosystem: "github-actions" 5 | directory: "/" 6 | schedule: 7 | interval: "weekly" # Check for updates to GitHub Actions every week 8 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Build 2 | 3 | on: 4 | pull_request: 5 | paths-ignore: 6 | - "**.md" 7 | push: 8 | branches: 9 | - main 10 | paths-ignore: 11 | - "**.md" 12 | schedule: 13 | - cron: "0 0 * * 0" # weekly at midnight on sundays (ish) 14 | 15 | env: 16 | ASDF_CONCURRENCY: 2 17 | 18 | jobs: 19 | build: 20 | strategy: 21 | matrix: 22 | os: 23 | - ubuntu-latest 24 | - macos-latest 25 | # - windows-latest In theory this should work, but ASDF requires bash and friends 26 | python-version: 27 | - "3.8" 28 | - "3.11" 29 | cli-version: 30 | - "latest:1" 31 | - "latest:2" 32 | - "source" 33 | include: 34 | - os: macos-latest 35 | coreutils: 36 | - default 37 | - latest 38 | runs-on: ${{ matrix.os }} 39 | steps: 40 | - name: Setup homebrew if using latest coreutils 41 | if: matrix.coreutils == 'latest' 42 | uses: Homebrew/actions/setup-homebrew@master 43 | 44 | - name: Try installing latest GNU coreutils 45 | if: matrix.coreutils == 'latest' 46 | run: | 47 | brew update 48 | brew install coreutils 49 | echo "$(brew --prefix)/opt/coreutils/libexec/gnubin" >> "${GITHUB_PATH}" 50 | 51 | - name: Set up Python 52 | uses: actions/setup-python@v4 53 | with: 54 | python-version: ${{ matrix.python-version }} 55 | 56 | - name: Check paths and coreutils version if using latest 57 | if: matrix.coreutils == 'latest' 58 | run: | 59 | which cp 60 | cp --version 61 | which python 62 | python --version 63 | "${pythonLocation}/bin/python" --version 64 | echo "${GITHUB_PATH}" 65 | echo "${PATH}" 66 | 67 | - name: asdf_plugin_test 68 | uses: asdf-vm/actions/plugin-test@v3 69 | with: 70 | command: aws --version 71 | version: ${{ matrix.cli-version }} 72 | 73 | - name: Retrieve latest version (source) 74 | if: matrix.cli-version == 'source' 75 | run: | 76 | echo "AWSCLI_VERSION=ref:$(asdf latest awscli 2)" >> "${GITHUB_ENV}" 77 | 78 | - name: Retrieve latest version (binary) 79 | if: matrix.cli-version != 'source' 80 | run: | 81 | echo "AWSCLI_VERSION=$(asdf latest awscli 2)" >> "${GITHUB_ENV}" 82 | 83 | - name: asdf_plugin_test 84 | uses: asdf-vm/actions/plugin-test@v3 85 | with: 86 | command: aws --version 87 | 88 | version: ${{ env.AWSCLI_VERSION || '' }} 89 | -------------------------------------------------------------------------------- /.github/workflows/lint.yml: -------------------------------------------------------------------------------- 1 | name: Lint 2 | 3 | on: 4 | pull_request: 5 | paths-ignore: 6 | - "**.md" 7 | push: 8 | branches: 9 | - main 10 | paths-ignore: 11 | - "**.md" 12 | schedule: 13 | - cron: "0 0 * * 0" # weekly at midnight on sundays (ish) 14 | 15 | jobs: 16 | lint: 17 | runs-on: ubuntu-latest 18 | steps: 19 | - uses: actions/checkout@v4 20 | - uses: asdf-vm/actions/install@v3 21 | - run: scripts/lint.bash 22 | 23 | actionlint: 24 | runs-on: ubuntu-latest 25 | steps: 26 | - uses: actions/checkout@v4 27 | - name: Check workflow files 28 | uses: docker://rhysd/actionlint:1.6.23 29 | with: 30 | args: -color 31 | -------------------------------------------------------------------------------- /.github/workflows/release.yml: -------------------------------------------------------------------------------- 1 | name: Release 2 | 3 | on: 4 | push: 5 | branches: 6 | - main 7 | 8 | permissions: 9 | contents: write 10 | pull-requests: write 11 | 12 | jobs: 13 | release-please: 14 | runs-on: ubuntu-latest 15 | steps: 16 | - uses: GoogleCloudPlatform/release-please-action@v3 17 | with: 18 | release-type: simple 19 | -------------------------------------------------------------------------------- /.github/workflows/semantic-pr.yml: -------------------------------------------------------------------------------- 1 | name: SemanticPR 2 | 3 | on: 4 | pull_request_target: 5 | types: 6 | - opened 7 | - edited 8 | - synchronize 9 | 10 | jobs: 11 | semantic-pr: 12 | runs-on: ubuntu-latest 13 | steps: 14 | - uses: amannn/action-semantic-pull-request@v5.4.0 15 | env: 16 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 17 | with: 18 | validateSingleCommit: true 19 | -------------------------------------------------------------------------------- /.tool-versions: -------------------------------------------------------------------------------- 1 | shellcheck 0.10.0 2 | shfmt 3.9.0 3 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | ## [1.0.1](https://github.com/MetricMike/asdf-awscli/compare/v1.0.0...v1.0.1) (2023-06-13) 4 | 5 | 6 | ### Bug Fixes 7 | 8 | * resolve coreutils/macos incompatiblity ([#29](https://github.com/MetricMike/asdf-awscli/issues/29)) ([485a11e](https://github.com/MetricMike/asdf-awscli/commit/485a11e88822d98e235aa3077a64fccea0d07616)) 9 | 10 | ## 1.0.0 (2023-04-25) 11 | 12 | 13 | ### Features 14 | 15 | * bundled installers for all, source installers for v2 ([#21](https://github.com/MetricMike/asdf-awscli/issues/21)) ([9ddb657](https://github.com/MetricMike/asdf-awscli/commit/9ddb657d89b56ad80417a972ea3b4e6a345125fa)) 16 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | # Contributing 2 | 3 | Testing Locally: 4 | 5 | ```shell 6 | # asdf plugin test [--asdf-tool-version ] [--asdf-plugin-gitref ] [test-command*] 7 | 8 | asdf plugin test awscli https://github.com//asdf-awscli.git "aws --version" 9 | ``` 10 | 11 | Tests are automatically run in GitHub Actions on push and PR. 12 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Michael Weigle 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |
2 | 3 | # asdf-awscli ![Build](https://github.com/MetricMike/asdf-awscli/workflows/Build/badge.svg) ![Lint](https://github.com/MetricMike/asdf-awscli/workflows/Lint/badge.svg) 4 | 5 | [awscli](https://github.com/MetricMike/asdf-awscli) plugin for the [asdf version manager](https://asdf-vm.com). 6 | 7 |
8 | 9 | # Build History 10 | [![Build history](https://buildstats.info/github/chart/MetricMike/asdf-awscli?branch=main)](https://github.com/MetricMike/asdf-awscli/actions) 11 | 12 | # Contents 13 | 14 | - [Dependencies](#dependencies) 15 | - [Install](#install) 16 | - [Contributing](#contributing) 17 | - [License](#license) 18 | 19 | # Dependencies 20 | 21 | - `curl`, `git`: Required by [asdf](https://asdf-vm.com/guide/getting-started.html#_1-install-dependencies) 22 | - `bash`, `tar`, `unzip`, `coreutils`: generic POSIX utilities. These should be installed by default on most operating systems. 23 | - Python 3.8+ (v1, v2 when building from source) https://aws.amazon.com/blogs/developer/python-support-policy-updates-for-aws-sdks-and-tools/ 24 | - `make/autotools` (v2 when building from source) 25 | - `Rosetta 2` (v2 when using the pre-built installers on Apple Silicon) 26 | 27 | # Install 28 | 29 | Plugin: 30 | 31 | ```shell 32 | asdf plugin add awscli 33 | # or 34 | asdf plugin add awscli https://github.com/MetricMike/asdf-awscli.git 35 | ``` 36 | 37 | awscli: 38 | 39 | ```shell 40 | # Show all installable versions 41 | asdf list all awscli 42 | 43 | # Install the latest version (optionally with a version prefix) 44 | asdf install awscli latest # 2.11.15 45 | asdf install awscli latest:2 # 2.11.15 46 | asdf install awscli latest:1 # 1.27.119 47 | 48 | # Install a specific version 49 | asdf install awscli 2.11.15 50 | asdf install awscli 1.27.119 51 | 52 | # Build and install v2 from from source 53 | asdf install awscli ref:2.11.15 54 | asdf install awscli "ref:$(asdf latest awscli 2)" # 2.11.15 55 | 56 | # Set a version globally (on your ~/.tool-versions file) 57 | (cd ~; asdf set awscli latest) 58 | 59 | # Now awscli commands are available 60 | aws --version 61 | ``` 62 | 63 | ### v1 - Linux/MacOS/Windows 64 | 65 | Only the pre-built installer is supported by this plugin for AWS CLI v1. If you need to build from source, install via `pip`. 66 | 67 | Note: The pre-built installers require a Python 3.8+ distribution at install-time **and this Python must remain installed** as they're just creating an isolated virtualenv and copying their site-packages over. Refer to the [AWS CLI v1 Python version support matrix](https://docs.aws.amazon.com/cli/v1/userguide/cli-chap-install.html#cli-chap-install-python) for which Pythons support which AWS CLI versions. If you remove the Python distribution used at install-time, **you must reinstall AWS CLI**. 68 | 69 | ### v2 - [Pre-built Installers](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-version.html) 70 | 71 | The macOS flavor only provides an x86_64 binary. You *must* install Rosetta 2 if using Apple Silicon (M1/M2/arm64). 72 | 73 | The Linux flavor provides both x86_64 and aarch64 binaries, but has dependencies on glibc, groff, and less. Alpine/musl users should build from source. 74 | 75 | The Windows flavor technically works, but ASDF's support for Windows isn't 100% yet. 76 | 77 | ### v2 - [Build and install from source](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-source-install.html) 78 | 79 | This is only supported starting from [v2.10.0 / 2023-02-15](https://github.com/aws/aws-cli/pull/7668) 80 | 81 | Building and installing from source requires a Python 3.8+ distribution at build-time. This plugin uses the `--with-install-type=portable-exe` and `--with-download-deps` flags to download all required Python dependencies and freeze a static copy of the build-time Python distribution. After a successful installation, there are no dependencies to your build time environment, and the ASDF installs folder could be shared with another air-gapped system that did not have a Python installation. 82 | 83 | --- 84 | 85 | Check [asdf](https://github.com/asdf-vm/asdf) readme for more instructions on how to 86 | install & manage versions. 87 | 88 | # Contributing 89 | 90 | Contributions of any kind welcome! See the [contributing guide](contributing.md). 91 | 92 | [Thanks goes to these contributors](https://github.com/MetricMike/asdf-awscli/graphs/contributors)! 93 | 94 | # License 95 | 96 | See [LICENSE](LICENSE) © [Michael Weigle](https://github.com/MetricMike/) 97 | -------------------------------------------------------------------------------- /asdf-awscli.code-workspace: -------------------------------------------------------------------------------- 1 | { 2 | "folders": [ 3 | { 4 | "path": "." 5 | } 6 | ], 7 | "settings": {} 8 | } 9 | -------------------------------------------------------------------------------- /bin/download: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | current_script_path=${BASH_SOURCE[0]} 6 | plugin_dir=$(dirname "$(dirname "${current_script_path}")") 7 | 8 | # shellcheck source=../lib/utils.bash 9 | . "${plugin_dir}/lib/utils.bash" 10 | 11 | TOOL_NAME="awscli" 12 | CURL_OPTS=(-fsSL) 13 | 14 | mkdir -p "${ASDF_DOWNLOAD_PATH}" 15 | 16 | download_source() { 17 | local version download_path major_version 18 | version="$1" 19 | download_path="$2" 20 | major_version="${version:0:1}" 21 | 22 | if [[ "${major_version}" = "2" ]]; then 23 | source_url="https://awscli.amazonaws.com/awscli-${version}.tar.gz" 24 | filename="awscli.tar.gz" 25 | source_file="${download_path}/${filename}" 26 | curl "${CURL_OPTS[@]}" -o "${source_file}" -C - "${source_url}" || fail "Could not download ${source_url}" 27 | tar -xzf "${source_file}" -C "${download_path}" --strip-components=1 || fail "Could not extract ${source_file}" 28 | rm "${source_file}" 29 | else 30 | fail "asdf-${TOOL_NAME} does not support downloading from source for major version v${major_version}" 31 | fi 32 | } 33 | 34 | download_release() { 35 | local version download_path major_version 36 | version="$1" 37 | download_path="$2" 38 | major_version="${version:0:1}" 39 | 40 | if [[ "${major_version}" = "1" ]]; then 41 | release_url="https://s3.amazonaws.com/aws-cli/awscli-bundle-${version}.zip" 42 | filename="awscli-bundle.zip" 43 | elif [[ "${major_version}" = "2" ]]; then 44 | if [[ "${OS_NAME}" = "Linux" ]]; then 45 | if [[ "${OS_ARCH}" = "x86_64" || "${OS_ARCH}" = "aarch64" ]]; then 46 | release_url="https://awscli.amazonaws.com/awscli-exe-linux-${OS_ARCH}-${version}.zip" 47 | filename="awscliv2.zip" 48 | else 49 | fail "asdf-${TOOL_NAME} does not support ${OS_ARCH} on ${OS_NAME}" 50 | fi 51 | elif [[ "${OS_NAME}" = "Darwin" ]]; then 52 | release_url="https://awscli.amazonaws.com/AWSCLIV2-${version}.pkg" 53 | filename="AWSCLIV2.pkg" 54 | elif [[ "${OS_NAME}" = "Windows_NT" ]]; then 55 | release_url="https://awscli.amazonaws.com/AWSCLIV2-${version}.msi" 56 | filename="AWSCLIV2.msi" 57 | else 58 | fail "asdf-${TOOL_NAME} does not support OS distribution ${OS_NAME}" 59 | fi 60 | else 61 | fail "asdf-${TOOL_NAME} does not support major version v${version}" 62 | fi 63 | 64 | release_file="${download_path}/${filename}" 65 | curl "${CURL_OPTS[@]}" -o "${release_file}" "${release_url}" || fail "Could not download ${release_url}" 66 | if [[ "${release_file: -3}" = "zip" ]]; then 67 | unzip -oq "${release_file}" -d "${download_path}" 68 | rm "${release_file}" 69 | fi 70 | } 71 | 72 | if [ "${ASDF_INSTALL_TYPE}" = "version" ]; then 73 | download_release "${ASDF_INSTALL_VERSION}" "${ASDF_DOWNLOAD_PATH}" 74 | elif [ "${ASDF_INSTALL_TYPE}" = "ref" ]; then 75 | download_source "${ASDF_INSTALL_VERSION}" "${ASDF_DOWNLOAD_PATH}" 76 | fi 77 | -------------------------------------------------------------------------------- /bin/install: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | current_script_path=${BASH_SOURCE[0]} 6 | plugin_dir=$(dirname "$(dirname "${current_script_path}")") 7 | 8 | # shellcheck source=../lib/utils.bash 9 | . "${plugin_dir}/lib/utils.bash" 10 | 11 | TOOL_NAME="awscli" 12 | TOOL_CMD="aws" 13 | 14 | install_source() { 15 | local version download_path install_path major_version make_concurrency 16 | version="$1" 17 | download_path="$2" 18 | install_path="$3" 19 | make_concurrency="$4" 20 | major_version="${version:0:1}" 21 | 22 | ( 23 | if [[ "${major_version}" = "2" ]]; then 24 | if [[ "${OS_NAME}" = "Linux" || "${OS_NAME}" = "Darwin" ]]; then 25 | pushd "${download_path}" 26 | ./configure --prefix="${install_path}" --with-download-deps --with-install-type=portable-exe 27 | make --jobs "${make_concurrency}" 28 | make install 29 | popd 30 | else 31 | fail "asdf-${TOOL_NAME} does not support installing from source for OS distribution ${OS_NAME}" 32 | fi 33 | else 34 | fail "asdf-${TOOL_NAME} does not support installing from source for major version v${major_version}" 35 | fi 36 | 37 | test -x "${install_path}/bin/${TOOL_CMD}" || fail "Expected ${install_path}/bin/${TOOL_CMD} to be executable." 38 | printfn "asdf-${TOOL_NAME} ${version} installation was successful!" 39 | ) || ( 40 | rm -rf "${install_path}" 41 | fail "An error ocurred while installing awscli ${version}." 42 | ) 43 | } 44 | 45 | install_release() { 46 | local version download_path install_path major_version 47 | version="$1" 48 | download_path="$2" 49 | install_path="$3" 50 | major_version="${version:0:1}" 51 | 52 | ( 53 | if [[ "${major_version}" = "1" ]]; then 54 | install_v1_bundled_installer "${download_path}" "${install_path}" 55 | elif [[ "${major_version}" = "2" ]]; then 56 | if [[ "${OS_NAME}" = "Linux" ]]; then 57 | if [[ "${OS_ARCH}" = "x86_64" || "${OS_ARCH}" = "aarch64" ]]; then 58 | install_v2_linux_bundled_installer "${download_path}" "${install_path}" 59 | else 60 | fail "asdf-${TOOL_NAME} does not support ${OS_ARCH} on ${OS_NAME}" 61 | fi 62 | elif [[ "${OS_NAME}" = "Darwin" ]]; then 63 | install_v2_macos_bundled_installer "${download_path}" "${install_path}" 64 | elif [[ "${OS_NAME}" = "Windows_NT" ]]; then 65 | install_v2_windows_bundled_installer "${download_path}" "${install_path}" 66 | else 67 | fail "asdf-${TOOL_NAME} does not support OS distribution ${OS_NAME}" 68 | fi 69 | else 70 | fail "asdf-${TOOL_NAME} does not support major version v${major_version}" 71 | fi 72 | 73 | test -x "${install_path}/bin/${TOOL_CMD}" || fail "Expected ${install_path}/bin/${TOOL_CMD} to be executable." 74 | printfn "asdf-${TOOL_NAME} ${version} installation was successful!" 75 | ) || ( 76 | rm -rf "${install_path}" 77 | fail "An error ocurred while installing awscli ${version}." 78 | ) 79 | } 80 | 81 | install_v1_bundled_installer() { 82 | local download_path install_path 83 | download_path="$1" 84 | install_path="$2" 85 | # requires python 3.8+ https://aws.amazon.com/blogs/developer/python-support-policy-updates-for-aws-sdks-and-tools/ 86 | "${download_path}"/awscli-bundle/install --install-dir "${install_path}" 87 | } 88 | 89 | install_v2_linux_bundled_installer() { 90 | local download_path install_path 91 | download_path="$1" 92 | install_path="$2" 93 | # requires glibc, groff, less 94 | rm -rf "{$install_path}" 95 | "${download_path}"/aws/install --install-dir "${install_path}" --bin-dir "${install_path}/bin" 96 | } 97 | 98 | # The official AWS CLI directions suggest using installer and a choices.xml 99 | # but I was unable to find a deterministic way to make that work 100 | # so copypasta 101 | install_v2_macos_bundled_installer() { 102 | local download_path install_path 103 | download_path="$1" 104 | install_path="$2" 105 | # requires rosetta on M1 macs 106 | 107 | pkgutil --expand-full "${download_path}/AWSCLIV2.pkg" "${download_path}/tmp-awscliv2" 108 | cp -LR "${download_path}/tmp-awscliv2/aws-cli.pkg/Payload/aws-cli/"* "${install_path}" 109 | mkdir -p "${install_path}/bin" 110 | ln -snf "${install_path}/aws" "${install_path}/bin/aws" 111 | ln -snf "${install_path}/aws_completer" "${install_path}/bin/aws_completer" 112 | rm -rf "${download_path}/tmp-awscliv2" 113 | } 114 | 115 | install_v2_windows_bundled_installer() { 116 | local download_path install_path 117 | download_path="$1" 118 | install_path="$2" 119 | 120 | # requires curl, msiexec 121 | msiexec.exe /i "${download_path}/AWSCLIV2.msi" "INSTALLDIR=${ASDF_INSTALL_PATH}" MSIINSTALLPERUSER=1 122 | } 123 | 124 | # Preserve compatibilty with older ASDF versions 125 | # https://github.com/asdf-vm/asdf/pull/669#issuecomment-600330467 126 | if [ -z "${ASDF_DOWNLOAD_PATH:-}" ]; then 127 | tmp_download_dir=$(mktemp -d -t asdf_asdf-awscli_XXXXXX) 128 | trap 'rm -rf "${tmp_download_dir}"' EXIT 129 | printfn "run download script for older versions of asdf" 130 | export ASDF_DOWNLOAD_PATH="${tmp_download_dir}" 131 | 132 | # download 133 | bash "$(dirname "$0")/download" 134 | fi 135 | 136 | if [ "${ASDF_INSTALL_TYPE}" = "version" ]; then 137 | install_release "${ASDF_INSTALL_VERSION}" "${ASDF_DOWNLOAD_PATH}" "${ASDF_INSTALL_PATH}" 138 | elif [ "${ASDF_INSTALL_TYPE}" = "ref" ]; then 139 | install_source "${ASDF_INSTALL_VERSION}" "${ASDF_DOWNLOAD_PATH}" "${ASDF_INSTALL_PATH}" "${ASDF_CONCURRENCY}" 140 | fi 141 | -------------------------------------------------------------------------------- /bin/list-all: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | set -euo pipefail 4 | 5 | current_script_path=${BASH_SOURCE[0]} 6 | plugin_dir=$(dirname "$(dirname "${current_script_path}")") 7 | 8 | # shellcheck source=../lib/utils.bash 9 | . "${plugin_dir}/lib/utils.bash" 10 | 11 | GH_REPO="https://github.com/aws/aws-cli" 12 | # shellcheck disable=2207 13 | GIT_VERSION_STRING=($(git --version)) 14 | # shellcheck disable=2206 15 | GIT_VERSION=(${GIT_VERSION_STRING[2]//./ }) 16 | GIT_MAJOR_VERSION="${GIT_VERSION[0]}" 17 | GIT_MINOR_VERSION="${GIT_VERSION[1]}" 18 | 19 | # need git 2.18.0+ for version sorting 20 | if [ "${GIT_MAJOR_VERSION}" -ge 2 ] && [ "${GIT_MINOR_VERSION}" -ge 18 ]; then 21 | GIT_SUPPORTS_SORT=0 22 | else 23 | GIT_SUPPORTS_SORT=1 24 | GIT_REMINDER_FILE="$(mktemp -t asdf_asdf-awscli_upgradegit_XXXXXX)" 25 | GIT_REMINDER_FILE_FUZZY="${GIT_REMINDER_FILE%_*}" 26 | if [ ! -f "${GIT_REMINDER_FILE_FUZZY}" ]; then 27 | printfn "consider upgrading git to a version >= 2.18.0 for faster asdf - you have v${GIT_VERSION_STRING[2]}" 28 | touch "${GIT_REMINDER_FILE_FUZZY}" 29 | fi 30 | fi 31 | 32 | # NOTE: This is a fallback for if the user's installed version of git doesn't support sorting. 33 | sort_versions() { 34 | sed 'h; s/[+-]/./g; s/.p\([[:digit:]]\)/.z\1/; s/$/.z/; G; s/\n/ /' | 35 | LC_ALL=C sort -t. -k 1,1 -k 2,2n -k 3,3n -k 4,4n -k 5,5n | awk '{print $2}' 36 | } 37 | 38 | list_remote_tags() { 39 | if [ "${GIT_SUPPORTS_SORT}" -eq 0 ]; then 40 | git -c 'versionsort.suffix=a' -c 'versionsort.suffix=b' \ 41 | -c 'versionsort.suffix=r' -c 'versionsort.suffix=p' \ 42 | -c 'versionsort.suffix=-' -c 'versionsort.suffix=_' \ 43 | ls-remote --exit-code --tags --refs --sort="version:refname" "${GH_REPO}" | 44 | awk -F'[/v]' '$NF ~ /^[0-9]+.*/ { printf "%s%s", (NR==1 ? "" : " "), $NF } END { print "" }' || fail "no releases found" 45 | else 46 | git ls-remote --exit-code --tags --refs "${GH_REPO}" | 47 | awk -F'[/v]' '$NF ~ /^[0-9]+.*/ { print $NF }' || fail "no releases found" 48 | fi 49 | } 50 | 51 | list_all_versions() { 52 | if [ "${GIT_SUPPORTS_SORT}" -eq 0 ]; then 53 | list_remote_tags 54 | else 55 | list_remote_tags | sort_versions 56 | fi 57 | } 58 | 59 | list_all_versions 60 | -------------------------------------------------------------------------------- /lib/utils.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | # shellcheck disable=SC2034 3 | 4 | set -euo pipefail 5 | 6 | fail() { 7 | printfn "$*" 8 | exit 1 9 | } 10 | 11 | printfn() { 12 | printf "asdf-awscli: %s\\n" "$*" 13 | } 14 | 15 | OS_INFO="$(uname -sm)" 16 | OS_NAME="${OS_INFO% *}" 17 | OS_ARCH="${OS_INFO#* }" 18 | -------------------------------------------------------------------------------- /scripts/format.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | shfmt --language-dialect bash --write \ 4 | ./**/* 5 | -------------------------------------------------------------------------------- /scripts/lint.bash: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | shellcheck --shell=bash --external-sources \ 4 | bin/* --source-path=lib/ \ 5 | lib/* \ 6 | scripts/* 7 | 8 | shfmt --language-dialect bash --diff \ 9 | ./**/* 10 | --------------------------------------------------------------------------------