Skip to content

Commit 39b0a3d

Browse files
committed
feat(MongoBinaryDownloadUrl): add archive generation for gentoo
re #639
1 parent 20eff46 commit 39b0a3d

File tree

3 files changed

+61
-1
lines changed

3 files changed

+61
-1
lines changed

docs/guides/supported-systems.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,15 @@ There are no official mongodb builds for Arch Distributions, but the `ubuntu` bi
126126
Because Arch* dosnt base on ubuntu, there is no specific ubuntu version associated with an arch version, so it defaults to highest supported `ubuntu` version
127127
:::
128128

129+
### Gentoo
130+
131+
<span class="badge badge--warning">Untested</span> <span class="badge badge--danger">Unsupported</span>
132+
133+
There are no official mongodb builds for Gentoo Distributions, but the `debian` binaries work on most Gentoo systems, so they are used<br/>
134+
:::note
135+
Because Gentoo dosnt base on debian, there is no specific debian version associated with an gentoo version, so it defaults to highest supported `debian` version
136+
:::
137+
129138
### Alpine
130139

131140
<span class="badge badge--danger">Unsupported</span>

packages/mongodb-memory-server-core/src/util/MongoBinaryDownloadUrl.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,17 @@ export class MongoBinaryDownloadUrl implements MongoBinaryDownloadUrlOpts {
197197
dist: 'Ubuntu Linux',
198198
release: '20.04',
199199
});
200+
} else if (regexHelper(/gentoo/i, os)) {
201+
// it seems like debian binaries work for gentoo too (at least most), see https://github.com/nodkz/mongodb-memory-server/issues/639
202+
console.warn(
203+
`There is no official build of MongoDB for Gentoo (${os.dist}). Falling back to Debian.`
204+
);
205+
206+
return this.getDebianVersionString({
207+
os: 'linux',
208+
dist: 'Debian',
209+
release: '11',
210+
});
200211
} else if (regexHelper(/unknown/i, os)) {
201212
// "unknown" is likely to happen if no release file / command could be found
202213
console.warn(

packages/mongodb-memory-server-core/src/util/__tests__/MongoBinaryDownloadUrl.test.ts

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ describe('MongoBinaryDownloadUrl', () => {
291291
version: '3.6.3',
292292
os: {
293293
os: 'linux',
294-
dist: 'Gentoo Linux',
294+
dist: 'Something Unhandled', // not "unknown", because that is when it failed to parse
295295
release: '',
296296
},
297297
});
@@ -342,6 +342,46 @@ describe('MongoBinaryDownloadUrl', () => {
342342
expect(console.warn).toHaveBeenCalledTimes(1);
343343
});
344344

345+
describe('for gentoo', () => {
346+
it('for gentoo 5.0.8', async () => {
347+
jest.spyOn(console, 'warn').mockImplementation(() => void 0);
348+
349+
const du = new MongoBinaryDownloadUrl({
350+
platform: 'linux',
351+
arch: 'x64',
352+
version: '5.0.8',
353+
os: {
354+
os: 'linux',
355+
dist: 'gentoo',
356+
release: '',
357+
},
358+
});
359+
expect(await du.getDownloadUrl()).toBe(
360+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian11-5.0.8.tgz'
361+
);
362+
expect(console.warn).toHaveBeenCalledTimes(1);
363+
});
364+
365+
it('for gentoo 4.4', async () => {
366+
jest.spyOn(console, 'warn').mockImplementation(() => void 0);
367+
368+
const du = new MongoBinaryDownloadUrl({
369+
platform: 'linux',
370+
arch: 'x64',
371+
version: '4.4.0',
372+
os: {
373+
os: 'linux',
374+
dist: 'gentoo',
375+
release: '',
376+
},
377+
});
378+
expect(await du.getDownloadUrl()).toBe(
379+
'https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-debian10-4.4.0.tgz'
380+
);
381+
expect(console.warn).toHaveBeenCalledTimes(1);
382+
});
383+
});
384+
345385
it('for unpopular arch', async () => {
346386
jest.spyOn(console, 'warn').mockImplementation(() => void 0);
347387

0 commit comments

Comments
 (0)