Skip to content

Commit

Permalink
feat(MongoBinaryDownloadUrl): add support for ubuntu-arm64
Browse files Browse the repository at this point in the history
fixes #443
  • Loading branch information
hasezoey committed Feb 24, 2021
1 parent e0216a0 commit 5733a0f
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 13 deletions.
5 changes: 4 additions & 1 deletion docs/guides/supported-systems.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ Should just work out of the box
## MacOS

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`
On Arm64 systems, the architecture needs to be overwritten with `MONGOMS_ARCH=x64`, only exception being (and based on) `ubuntu`

## Linux

Expand All @@ -39,6 +39,9 @@ Highest version (default to) is `2004`
:::note
Lower Versions than `2004` may be used if mongodb dosnt provide binaries for an lower version of mongodb for an higher version of ubuntu
:::
:::note
For Arm64 MongoDB only provides binaries for `ubuntu1604`
:::

### Debian

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,13 @@ export class MongoBinaryDownloadUrl {
dist: 'ubuntu',
};

// this is, because currently mongodb only really provides arm64 binaries for "ubuntu1604"
if (this.arch === 'arm64') {
log('getUbuntuVersionString: architecture "arm64" detected, using ubuntu1604');

return 'ubuntu1604';
}

// "id_like" processing (version conversion) [this is an block to be collapsible]
{
if (/^linux\s?mint\s*$/i.test(os.dist)) {
Expand Down Expand Up @@ -374,18 +381,23 @@ export class MongoBinaryDownloadUrl {
* @param platform The Platform to translate
*/
translateArch(arch: string, mongoPlatform: string): string {
if (arch === 'ia32') {
if (mongoPlatform === 'linux') {
return 'i686';
} else if (mongoPlatform === 'win32') {
return 'i386';
}
switch (arch) {
case 'ia32':
if (mongoPlatform === 'linux') {
return 'i686';
} else if (mongoPlatform === 'win32') {
return 'i386';
}

throw new Error('unsupported architecture');
} else if (arch === 'x64') {
return 'x86_64';
} else {
throw new Error('unsupported architecture, ia32 and x64 are the only valid options');
throw new Error(
`Unsupported Architecture-Platform combination: arch: "${arch}", platform: "${mongoPlatform}"`
);
case 'x64':
return 'x86_64';
case 'arm64':
return 'arm64';
default:
throw new Error(`Unsupported Architecture: arch: "${arch}"`);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ describe('MongoBinaryDownloadUrl', () => {
});

describe('for linux', () => {
it('for ubuntu', async () => {
it('for ubuntu x64', async () => {
const du = new MongoBinaryDownloadUrl({
platform: 'linux',
arch: 'x64',
Expand All @@ -71,6 +71,22 @@ describe('MongoBinaryDownloadUrl', () => {
);
});

it('for ubuntu arm64', async () => {
const du = new MongoBinaryDownloadUrl({
platform: 'linux',
arch: 'arm64',
version: '4.0.20',
os: {
os: 'linux',
dist: 'Ubuntu Linux',
release: '20.04',
},
});
expect(await du.getDownloadUrl()).toBe(
'https://fastdl.mongodb.org/linux/mongodb-linux-arm64-ubuntu1604-4.0.20.tgz'
);
});

it('for debian', async () => {
const du = new MongoBinaryDownloadUrl({
platform: 'linux',
Expand Down

0 comments on commit 5733a0f

Please sign in to comment.