Skip to content

Commit

Permalink
standalone-installer-unix: Use new aarch64 builds for macOS
Browse files Browse the repository at this point in the history
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.

¹ <#357>
² <#359>
  • Loading branch information
tsibley committed Feb 2, 2024
1 parent 3fd478f commit 4ed2952
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
1 change: 1 addition & 0 deletions .github/workflows/standalone-installers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ jobs:
- ubuntu-22.04
- macos-11
- macos-12
- macos-14 # (aarch64)
- windows-2019
- windows-2022

Expand Down
36 changes: 30 additions & 6 deletions bin/standalone-installer-unix
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
;;
Expand All @@ -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

Expand Down

0 comments on commit 4ed2952

Please sign in to comment.