diff --git a/scripts/linux-glibc.test.ts b/scripts/linux-glibc.test.ts index 7efcf1a481..d8591a49c6 100644 --- a/scripts/linux-glibc.test.ts +++ b/scripts/linux-glibc.test.ts @@ -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 { diff --git a/scripts/linux-glibc.ts b/scripts/linux-glibc.ts index 9cc56eee36..98714ccd8a 100644 --- a/scripts/linux-glibc.ts +++ b/scripts/linux-glibc.ts @@ -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); @@ -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 { @@ -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) { @@ -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 }; }