Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

standalone-installer-unix: Use new aarch64 builds for macOS #358

Merged
merged 1 commit into from
Feb 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading