Skip to content

Commit

Permalink
feat(MongoBinaryDownloadUrl): support native macos arm64 binaries for…
Browse files Browse the repository at this point in the history
… 6.0.0 and up

fixes #714
  • Loading branch information
hasezoey committed Nov 9, 2022
1 parent 3ca338f commit 9b0dfb1
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 4 deletions.
4 changes: 3 additions & 1 deletion docs/guides/supported-systems.md
Expand Up @@ -40,7 +40,9 @@ Should just work out of the box
<span class="badge badge--success">Supported</span>

On x64 systems, it should work right out of the box<br/>
On Arm64 systems, the architecture needs to be overwritten with `MONGOMS_ARCH=x64`, only exception being (and based on) `ubuntu`
Since Mongodb 6.0.0, they have `arm64` binaries<br/>
Uses `arm64` binaries for all versions above or equal to `6.0.0`, for older versions falls back to using `x86_64` binaries (requires Rosetta)<br/>
Usage of the `x86_64` binary can be forced with [`MONGOMS_ARCH=x64`](../api/config-options.md#arch) (or equal in `package.json`)

## Linux

Expand Down
Expand Up @@ -130,9 +130,19 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
name = `mongodb-macos`; // somehow these files are not listed in https://www.mongodb.org/dl/osx
}

// mongodb has native arm64
if (this.arch === 'aarch64') {
log('getArchiveNameOsx: Arch is "aarch64", using x64 binary');
this.arch = 'x86_64';
// force usage of "x86_64" binary for all versions below than 6.0.0
if (!isNullOrUndefined(version) && semver.lt(version, '6.0.0')) {
log('getArchiveNameOsx: Arch is "aarch64" and version is below 6.0.0, using x64 binary');
this.arch = 'x86_64';
} else {
log(
'getArchiveNameOsx: Arch is "aarch64" and version is above or equal to 6.0.0, using arm64 binary'
);
// naming for macos is still "arm64" instead of "aarch64"
this.arch = 'arm64';
}
}

name += `-${this.arch}-${this.version}.tgz`;
Expand Down
Expand Up @@ -71,7 +71,7 @@ describe('MongoBinaryDownloadUrl', () => {
);
});

it('arm64 should use the x64 binary', async () => {
it('arm64 should use the x64 binary for versions below 6.0.0', async () => {
const du = new MongoBinaryDownloadUrl({
platform: 'darwin',
arch: 'arm64',
Expand All @@ -81,6 +81,17 @@ describe('MongoBinaryDownloadUrl', () => {
'https://fastdl.mongodb.org/osx/mongodb-macos-x86_64-4.4.0.tgz'
);
});

it('arm64 should use the arm64 binary for versions above and equal to 6.0.0', async () => {
const du = new MongoBinaryDownloadUrl({
platform: 'darwin',
arch: 'arm64',
version: '6.0.0',
});
expect(await du.getDownloadUrl()).toBe(
'https://fastdl.mongodb.org/osx/mongodb-macos-arm64-6.0.0.tgz'
);
});
});

describe('for linux', () => {
Expand Down

0 comments on commit 9b0dfb1

Please sign in to comment.