Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions scripts/linux-glibc.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,10 @@ describe.skipIf(HostProcess.Platform.defaultValue() !== "linux")("packaged ELF s
await afterPack({ appOutDir: app, electronPlatformName: "linux", targets: [deb] });
}
expect(deb.options.depends).toEqual(["libnss3", "libc6 (>= 2.34)"]);
await NodeFSP.writeFile(NodePath.join(native, "helper"), elfFixture(machine, "2.40"));
await NodeFSP.writeFile(NodePath.join(native, "helper"), elfFixture(machine, "2.99"));
await expect(
afterPack({ appOutDir: app, electronPlatformName: "linux", targets: [deb] }),
).rejects.toThrow(/helper.*GLIBC_2\.40.*2\.39/s);
).rejects.toThrow(/helper.*GLIBC_2\.99.*exceeding build ceiling/s);
await NodeFSP.writeFile(NodePath.join(native, "helper"), Buffer.from("\x7fELFbroken"));
await expect(scanGlibcNeeds(app)).rejects.toThrow(/helper/);
} finally {
Expand Down
18 changes: 11 additions & 7 deletions scripts/linux-glibc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,15 @@ import * as NodeFSP from "node:fs/promises";
import * as NodePath from "node:path";
import * as NodeUtil from "node:util";

// Both Linux release jobs build on Ubuntu 24.04; this is a build ceiling, not a distro support promise.
const GLIBC_BUILD_CEILING = "2.39";
const readelf = NodeUtil.promisify(NodeChildProcess.execFile);

// 456code stages its AppImage on the machine that runs it, so that machine's glibc is the ceiling.
function glibcBuildCeiling(): string {
const { header } = process.report.getReport() as { header?: { glibcVersionRuntime?: string } };
if (!header?.glibcVersionRuntime) throw new Error("Cannot read the build host's glibc version");
return header.glibcVersionRuntime;
}

function compareVersions(left: string, right: string): number {
const a = left.split(".").map(Number);
const b = right.split(".").map(Number);
Expand Down Expand Up @@ -39,6 +44,7 @@ export async function scanGlibcNeeds(appOutDir: string): Promise<{
minimum: string;
elfCount: number;
}> {
const ceiling = glibcBuildCeiling();
let minimum: string | undefined;
let elfCount = 0;
async function walk(directory: string): Promise<void> {
Expand Down Expand Up @@ -68,10 +74,8 @@ export async function scanGlibcNeeds(appOutDir: string): Promise<{
});
if (stderr.trim()) throw new Error(stderr.trim());
const required = parseGlibcNeeds(stdout);
if (required && compareVersions(required, GLIBC_BUILD_CEILING) > 0) {
throw new Error(
`requires GLIBC_${required}, exceeding build ceiling ${GLIBC_BUILD_CEILING}`,
);
if (required && compareVersions(required, ceiling) > 0) {
throw new Error(`requires GLIBC_${required}, exceeding build ceiling ${ceiling}`);
}
if (required && (!minimum || compareVersions(required, minimum) > 0)) minimum = required;
} catch (cause) {
Expand All @@ -85,7 +89,7 @@ export async function scanGlibcNeeds(appOutDir: string): Promise<{
await walk(appOutDir);
if (elfCount === 0 || !minimum) throw new Error(`No glibc requirements found in ${appOutDir}`);
console.log(
`[linux-glibc] ${elfCount} ELF files; requires glibc >= ${minimum}; build ceiling ${GLIBC_BUILD_CEILING}`,
`[linux-glibc] ${elfCount} ELF files; requires glibc >= ${minimum}; build ceiling ${ceiling}`,
);
return { minimum, elfCount };
}