-
-
Save briansmith/dd06e8dfeac46d1032d974000dac1fa6 to your computer and use it in GitHub Desktop.
#!/bin/bash | |
# "Bash Strict Mode with logging" | |
set -eux -o pipefail | |
IFS=$'\n\t' | |
case $(uname -p) in | |
arm) | |
;; | |
*) | |
echo This has only been tested with a native ARM shell. | |
exit 1 | |
;; | |
esac | |
if (file $(which rustup) | grep "arm64"); then | |
exit 0 | |
fi | |
# Adapted from | |
# https://github.com/rust-lang/rustup/issues/2413#issuecomment-729140037 | |
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | arch --x86_64 sh -s -- \ | |
-y \ | |
--default-host aarch64-apple-darwin \ | |
--default-toolchain nightly-2020-11-18 | |
rustup_tempdir=$(mktemp -d) | |
pushd $rustup_tempdir | |
source ~/.cargo/env | |
# Adapted from | |
# https://github.com/rust-lang/rustup/issues/2413#issuecomment-729173518 and | |
# https://github.com/rust-lang/rustup/issues/2413#issuecomment-729216870 | |
git clone https://github.com/rust-lang/rustup/ . | |
git checkout 5674652a45ecf9066128df32fbc51e965586e4b2 | |
RUSTC=$(rustup which rustc) $(rustup which cargo) build | |
RUSTC=$(rustup which rustc) $(rustup which cargo) dev-install | |
popd | |
rm -Rf $rustup_tempdir | |
if ! (file $(which rustup) | grep -q "arm64"); then | |
echo rustup did not get converted to ARM64 for some reason. | |
exit 1 | |
fi |
I'd love some assistance with the following points:
-
How could I change the above script so that it works even if the shell is running under Rosetta?
-
How can I force the installation of Rosetta 2, ideally from the command line, without signing into the App Store?
-
Even better, how can I use Xcode, targetting macOS and iOS, and with the simulators available, without installing Rosetta 2?
-
How can I script the any of the steps 1-4 above so they could be done over SSH?
The above is no longer necessary. curl https://sh.rustup.rs -sSf | sh -s -- -y --default-toolchain nightly-2020-11-25
worked for me today. See https://blog.rust-lang.org/2020/11/27/Rustup-1.23.0.html#support-for-apple-m1-devices for more info. (Today's Rust Nightly is broken because of briansmith/ring#1130; tomorrow's should work.)
These steps require you to use the GUI:
The rest can be done remotely via SSH if you wish:
FYI: I use a non-Apple USB-A keyboard/mouse (ThinkPad Compact Keyboard with TrackPoint). I found that the USB-A ports stopped working at one point. As a result, I couldn't use the keyboard to wake up the screen and log into the locked machine. I was able to tap the power button on the back of the box (M1 Mac Mini) to wake up the screen, but the USB-A ports never turned on, so I had to power the machine off and on to get the keyboard/mouse working. Probably the machine went into deep sleep and never woke up the USB-A ports. Or maybe it was a fluke. IDK. I developed everything on another machine and used Clion's SSH support to copy the files to the Mac over SSH as I edited them, and SSHed in to build. In other words, I pretty much treat my Mac as a headless server. So, I don't have any tips to share regarding normal Mac stuff.