Skip to content

Commit

Permalink
Fix Apple Silicon detection in install.sh and sys library
Browse files Browse the repository at this point in the history
  • Loading branch information
corbindavenport committed Nov 15, 2021
1 parent 646552a commit bc1e260
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 5 additions & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ ARCH=$(uname -m)
BASEURL="https://github.com/corbindavenport/nexus-tools"
DOWNLOAD=''
PARAMS="$@"
ROSETTA_STATUS=$(/bin/launchctl list | /usr/bin/grep "com.apple.oahd-root-helper")
ROSETTA_FOLDER="/Library/Apple/usr/share/rosetta"

_run_executable() {
cd $DIR
Expand Down Expand Up @@ -36,12 +38,12 @@ mkdir -p $DIR
if [ "$OS" = "Darwin" ]; then # macOS
# Install Rosetta x86 emulation layer if needed
if [ "$ARCH" = "arm64" ]; then
if [[ ! -f "/Library/Apple/System/Library/LaunchDaemons/com.apple.oahd.plist" ]]; then
if [[ -e "${ROSETTA_FOLDER}" && "${ROSETTA_STATUS}" != "" ]]; then
echo "[ OK ] Rosetta compatibility layer is already installed."
else
echo "[WARN] Apple Rosetta compatibility layer must be installed. Press ENTER to install or X to cancel."
read -sn1 input
[ "$input" = "" ] && /usr/sbin/softwareupdate --install-rosetta --agree-to-license || exit
else
echo "[ OK ] Rosetta compatibility layer is already installed."
fi
fi
DOWNLOAD="$BASEURL/releases/latest/download/nexustools-macos-x64.zip"
Expand Down
2 changes: 1 addition & 1 deletion lib/sys.dart
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ Future<String> getCPUArchitecture() async {
if (cpu == 'x86_64') {
// Check if running under Rosetta 2
var rosetta = await io.Process.run('sysctl', ['-in', 'sysctl.proc_translated']);
var rosettaStr = rosetta.stdout.toString();
var rosettaStr = rosetta.stdout.toString().replaceAll('\n', '');
// This command will run '1' if we're running under Rosetta 2
if (rosettaStr == '1') {
cpu = 'arm64';
Expand Down

0 comments on commit bc1e260

Please sign in to comment.