From 4ed29522e2b09838f53135922d1632c95e6706d4 Mon Sep 17 00:00:00 2001 From: Thomas Sibley Date: Thu, 1 Feb 2024 11:26:42 -0800 Subject: [PATCH] standalone-installer-unix: Use new aarch64 builds for macOS MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Conditions on the Nextstrain CLI version being requested, as aarch64 builds¹ will only be available going forward for new releases. Assumes the next release will be 8.2.0! Disables Rosetta check when using an aarch64 build, as the checks will be done at the runtime-level instead by `nextstrain setup` and `nextstrain check-setup`.² We must wait to merge this until after the first release (i.e. 8.2.0) of the changes it depends on above. ¹ ² --- .github/workflows/standalone-installers.yaml | 1 + bin/standalone-installer-unix | 36 ++++++++++++++++---- 2 files changed, 31 insertions(+), 6 deletions(-) diff --git a/.github/workflows/standalone-installers.yaml b/.github/workflows/standalone-installers.yaml index e1114fd3..a522677c 100644 --- a/.github/workflows/standalone-installers.yaml +++ b/.github/workflows/standalone-installers.yaml @@ -39,6 +39,7 @@ jobs: - ubuntu-22.04 - macos-11 - macos-12 + - macos-14 # (aarch64) - windows-2019 - windows-2022 diff --git a/bin/standalone-installer-unix b/bin/standalone-installer-unix index 155d8cc9..e5fa9749 100755 --- a/bin/standalone-installer-unix +++ b/bin/standalone-installer-unix @@ -20,17 +20,17 @@ shopt -s failglob # Globals declared here to make them more obvious, but set by main() to avoid # source ordering requirements and delay execution until the full file is # parsed. -declare KERNEL TARGET DESTINATION VERSION +declare VERSION KERNEL TARGET DESTINATION # Wrap everything in a function which we call at the end to avoid execution of # a partially-downloaded program. main() { + VERSION="${1:-${VERSION:-latest}}" + KERNEL="${KERNEL:-$(uname -s)}" TARGET="${TARGET:-$(target-triple)}" DESTINATION="${DESTINATION:-${NEXTSTRAIN_HOME:-$HOME/.nextstrain}/cli-standalone}" - VERSION="${1:-${VERSION:-latest}}" - local archive archive_url tmp archive="standalone-${TARGET}.tar.gz" @@ -115,9 +115,23 @@ target-triple() { ;; Darwin) - [[ "$machine" == x86_64 || "$machine" == arm64 ]] || die "unsupported architecture: $machine" - [[ "$machine" != arm64 ]] || pgrep -qU _oahd 2>/dev/null || die "Rosetta 2 not enabled. Please run:"$'\n\n'" softwareupdate --install-rosetta"$'\n\n'"and then retry this installation of Nextstrain CLI." - machine=x86_64 + # Rosetta 2 will not be needed for the standalone version of + # Nextstrain CLI itself as of 8.2.0. The Conda runtime still + # requires it and the Docker runtime can benefit from it, but we + # now check for it in their setup instead. + # -trs, 1 Feb 2024 + version-gte 8.2.0 \ + || [[ "$machine" != arm64 ]] \ + || pgrep -qU _oahd 2>/dev/null \ + || die "Rosetta 2 not enabled. Please run:"$'\n\n'" softwareupdate --install-rosetta"$'\n\n'"and then retry this installation of Nextstrain CLI." + + # aarch64 builds will only be available starting with 8.2.0. Older + # versions only provide x86_64, which will run under Rosetta. + case "$machine" in + x86_64) ;; + arm64) version-gte 8.2.0 && machine=aarch64 || machine=x86_64;; + *) die "unsupported architecture: $machine";; + esac vendor=apple os=darwin ;; @@ -129,6 +143,16 @@ target-triple() { echo "$machine-$vendor-$os" } +version-gte() { + local minimum="$1" + + # If $minimum sorts before $VERSION, then $VERSION is at least ≥$minimum. + # Note that non-numeric values sort by byte order, so "latest" and + # "pr-build/123" and so on end up after (greater than) a numeric value like + # 8.1.0. Both macOS/BSD sort and GNU sort support -V. + [[ $(printf '%s\n%s\n' "$minimum" "$VERSION" | sort -V | head -n1) == "$minimum" ]] +} + default-shell() { local shell