From de01946ae16cbcb8cb67b419c3d2c2402badddf3 Mon Sep 17 00:00:00 2001 From: andytson-inviqa Date: Fri, 19 Nov 2021 17:29:07 +0000 Subject: [PATCH] Fetch the correct architecture mutagen binary for the host (#10) In MacOS M1's case though arm64 is the host architecture, but support linux aarch64 still (MacOS intel is x86_64) --- harness/scripts/latest-mutagen-release.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/harness/scripts/latest-mutagen-release.php b/harness/scripts/latest-mutagen-release.php index b5ace9c..aa84bbb 100644 --- a/harness/scripts/latest-mutagen-release.php +++ b/harness/scripts/latest-mutagen-release.php @@ -22,9 +22,19 @@ throw new Exception('Could not find latest stable release.'); } +$goArchMap = [ + 'i386' => '386', + 'x86_64' => 'amd64', + 'aarch64' => 'arm64', + 'armv7l' => 'arm', + 'armv6l' => 'arm', +]; + $osFamily = strtolower(PHP_OS_FAMILY); -$releaseAssets = array_filter($latestStableRelease['assets'], function ($asset) use ($osFamily) { - return preg_match("/^mutagen_.*${osFamily}.*amd64.*/", $asset['name']) > 0; +$hostArch = php_uname('m'); +$goArch = $goArchMap[php_uname('m')] ?? $hostArch; +$releaseAssets = array_filter($latestStableRelease['assets'], function ($asset) use ($osFamily, $goArch) { + return preg_match("/^mutagen_.*${osFamily}.*${goArch}.*/", $asset['name']) > 0; }); $releaseAsset = reset($releaseAssets); if (!$releaseAsset) {