Skip to content

Commit eb522eb

Browse files
misc fixes
1 parent 4ef2200 commit eb522eb

File tree

3 files changed

+22
-45
lines changed

3 files changed

+22
-45
lines changed

.github/docker/Dockerfile.musl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ FROM ${PLATFORM}/node:${NODE_VERSION}-alpine AS build
66
WORKDIR /zstd
77
COPY . .
88

9-
RUN apk --no-cache add make g++ libc-dev curl bash python3 py3-pip vim cmake
9+
RUN apk --no-cache add make g++ libc-dev curl bash python3 py3-pip vim cmake git
1010
RUN npm run install:libmongocrypt
1111
RUN npm run prebuild
1212

.github/scripts/libmongocrypt.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import path from 'node:path';
99
import https from 'node:https';
1010
import stream from 'node:stream/promises';
1111
import url from 'node:url';
12-
import { buildLibmongocryptDownloadUrl, getLibmongocryptPackageName, getLibmongocryptPrebuildName, run } from './utils.mjs';
12+
import { buildLibmongocryptDownloadUrl, getLibmongocryptPrebuildName, run } from './utils.mjs';
1313

1414
const __dirname = path.dirname(url.fileURLToPath(import.meta.url));
1515

.github/scripts/utils.mjs

Lines changed: 20 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -55,22 +55,25 @@ export function buildLibmongocryptDownloadUrl(ref, platform) {
5555
}
5656

5757
export function getLibmongocryptPrebuildName() {
58-
const platformMatrix = {
59-
['darwin-arm64']: 'macos',
60-
['darwin-x64']: 'macos',
61-
['linux-ppc64']: 'rhel-71-ppc64el',
62-
['linux-s390x']: 'rhel72-zseries-test',
63-
['linux-arm64']: 'ubuntu1804-arm64',
64-
['linux-x64']: 'rhel-70-64-bit',
65-
['win32-x64']: 'windows-test'
66-
};
67-
68-
const detectedPlatform = `${process.platform}-${process.arch}`;
69-
const prebuild = platformMatrix[detectedPlatform];
70-
71-
if (prebuild == null) throw new Error(`Unsupported: ${detectedPlatform}`);
72-
73-
return prebuild;
58+
const prebuildIdentifierFactory = {
59+
'darwin': () => 'macos',
60+
'win32': () => 'windows-test',
61+
'linux': () => {
62+
const key = `${getLibc()}-${process.arch}`;
63+
return {
64+
['musl-x64']: 'alpine-amd64-earthly',
65+
['musl-arm64']: 'alpine-arm64-earthly',
66+
['glibc-ppc64']: 'rhel-71-ppc64el',
67+
['glibc-s390x']: 'rhel72-zseries-test',
68+
['glibc-arm64']: 'ubuntu1804-arm64',
69+
['glibc-x64']: 'rhel-70-64-bit',
70+
}[key]
71+
}
72+
}[process.platform] ?? (() => {
73+
throw new Error(`Unsupported platform`);
74+
});
75+
76+
return prebuildIdentifierFactory();
7477
}
7578

7679
/** `xtrace` style command runner, uses spawn so that stdio is inherited */
@@ -91,7 +94,7 @@ export async function run(command, args = [], options = {}) {
9194
/**
9295
* @returns the libc (`musl` or `glibc`), if the platform is linux, otherwise null.
9396
*/
94-
export function getLibc() {
97+
function getLibc() {
9598
if (process.platform !== 'linux') return null;
9699

97100
/**
@@ -111,29 +114,3 @@ export function getLibc() {
111114
console.error({ ldd: lddVersion() });
112115
return lddVersion().includes('musl') ? 'musl' : 'glibc';
113116
}
114-
115-
/**
116-
* @returns the name of the package inside the libmognocrypt prebuild tarball for the current platform, arch and libc (if linux).
117-
*/
118-
export function getLibmongocryptPackageName() {
119-
const platformFactory = {
120-
'darwin': () => 'macos',
121-
'win32': () => 'windows-test',
122-
'linux': () => {
123-
const key = `${getLibc()}-${process.arch}`;
124-
return {
125-
['musl-x64']: 'alpine-amd64-earthly',
126-
['musl-arm64']: 'alpine-arm64-earthly',
127-
['glibc-ppc64']: 'rhel-71-ppc64el',
128-
['glibc-s390x']: 'rhel72-zseries-test',
129-
['glibc-arm64']: 'ubuntu1804-arm64',
130-
['glibc-x64']: 'rhel-70-64-bit',
131-
}[key]
132-
}
133-
}[process.platform] ?? (() => {
134-
throw new Error('unexpected platform.')
135-
});
136-
137-
return platformFactory();
138-
}
139-

0 commit comments

Comments
 (0)