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`.
  • Loading branch information
tsibley committed Feb 2, 2024
1 parent 81c24e3 commit 3ccbd10
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 8 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
9 changes: 7 additions & 2 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,13 @@ development source code and as such may not be routinely kept up to date.
## Improvements

* We now produce standalone installation archives for macOS running on aarch64
hardware (aka arm64, Apple Silicon, M1/M2).
([#357](https://github.com/nextstrain/cli/pull/357))
hardware (aka arm64, Apple Silicon, M1/M2). The standalone installer will
use these archives starting with this release. Rosetta 2 is still required
by our Conda runtime (and recommended for our Docker runtime), but checks
that it's enabled are now performed during runtime setup instead of at
installation.
([#357](https://github.com/nextstrain/cli/pull/357),
[#358](https://github.com/nextstrain/cli/pull/358))

* The Conda and Docker runtime checks performed by `nextstrain setup` and
`nextstrain check-setup` now test if Rosetta 2 is enabled for macOS on
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 3ccbd10

Please sign in to comment.