Skip to content

Commit

Permalink
fix(MongoBinaryDownloadUrl): add support for ubuntu-arm64
Browse files Browse the repository at this point in the history
fixes #443
  • Loading branch information
hasezoey committed Mar 8, 2021
1 parent de5859d commit c432e24
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,13 @@ export default class MongoBinaryDownloadUrl {
const majorVer: number = parseInt(ubuntuVer[0], 10);
// const minorVer: string = ubuntuVer[1];

// 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';
}

if (os.release === '12.04') {
name += '1204';
} else if (os.release === '14.04') {
Expand Down Expand Up @@ -366,17 +373,23 @@ export default 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';
}
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');
switch (arch) {
case 'ia32':
if (mongoPlatform === 'linux') {
return 'i686';
} else if (mongoPlatform === 'win32') {
return 'i386';
}

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}"`);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe('MongoBinaryDownloadUrl', () => {
});
});

it('for ubuntu', async () => {
it('for ubuntu x64', async () => {
const du = new MongoBinaryDownloadUrl({
platform: 'linux',
arch: 'x64',
Expand All @@ -64,6 +64,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 81 for 3.6.3', async () => {
const du = new MongoBinaryDownloadUrl({
platform: 'linux',
Expand Down

0 comments on commit c432e24

Please sign in to comment.