Open source Loom alternative. Beautiful, shareable screen recordings.
Rust appcapcossloommacnextjsnextjs15open-sourceossreactrecordrustscreen-capturescreen-recorderscreenshotsolidjstauritauri-apptypescriptvite
fix: declare and validate Linux glibc requirements
jatmn80208255bbc5
diff --git a/apps/desktop-gpui/tauri.conf.json b/apps/desktop-gpui/tauri.conf.jsonindex b5f4be441..314e0f27d 100644--- a/apps/desktop-gpui/tauri.conf.json+++ b/apps/desktop-gpui/tauri.conf.json@@ -81,6 +81,7 @@"linux": {"deb": {"depends": [+ "libc6 (>= 2.39)","libva2","libva-drm2","pulseaudio-utils",diff --git a/apps/web/components/pages/DownloadPage.tsx b/apps/web/components/pages/DownloadPage.tsxindex 28b7e0201..2c1e8a584 100644--- a/apps/web/components/pages/DownloadPage.tsx+++ b/apps/web/components/pages/DownloadPage.tsx@@ -431,6 +431,10 @@ export const DownloadPage = ({All versions</Link></div>+ <p className="mt-3 text-sm text-gray-10">+ Linux downloads require glibc 2.39 or newer, such as Ubuntu 24.04 or+ newer. Ubuntu 22.04 is not supported, including with AppImage.+ </p></div>{/* Discreet SEO Links */}diff --git a/scripts/finalize-linux-gpui-packages.mjs b/scripts/finalize-linux-gpui-packages.mjsindex f06dab0e9..f9daf4ffd 100644--- a/scripts/finalize-linux-gpui-packages.mjs+++ b/scripts/finalize-linux-gpui-packages.mjs@@ -1,6 +1,7 @@import {mkdir,mkdtemp,+ open,readdir,readFile,rename,@@ -221,6 +222,54 @@ const captured = (env) => ({stdio: ["ignore", "pipe", "inherit"],});+async function verifyDebGlibc(root, control, { env, run }) {+ const dependencies = /^Depends:(.*(?:\n[ \t].*)*)/m+ .exec(control)?.[1]+ .replace(/\n[ \t]+/g, " ")+ .split(",");+ const minimum = dependencies+ ?.map((dependency) =>+ /^\s*libc6\s*\(>=\s*(\d+(?:\.\d+)+)\)\s*$/.exec(dependency),+ )+ .find(Boolean)?.[1];+ if (!minimum) {+ throw new Error(+ "The Cap deb must declare a versioned libc6 (>= version) dependency",+ );+ }+ async function verifyDirectory(directory) {+ for (const entry of await readdir(directory, { withFileTypes: true })) {+ const filename = path.join(directory, entry.name);+ if (entry.isDirectory()) {+ await verifyDirectory(filename);+ } else if (entry.isFile()) {+ const file = await open(filename, "r");+ const magic = Buffer.alloc(4);+ try {+ await file.read(magic, 0, 4, 0);+ } finally {+ await file.close();+ }+ if (!magic.equals(Buffer.from([0x7f, 0x45, 0x4c, 0x46]))) continue;+ const { stdout } = await run(+ "readelf",+ ["--wide", "--version-info", filename],+ captured(env),+ );+ const needs = stdout.split("Version needs section")[1] ?? "";+ for (const match of needs.matchAll(/Name: GLIBC_(\d+(?:\.\d+)+)\b/g)) {+ if (match[1].localeCompare(minimum, "en", { numeric: true }) > 0) {+ throw new Error(+ `${path.relative(root, filename)} requires GLIBC_${match[1]}, exceeding the declared libc6 (>= ${minimum}) dependency`,+ );+ }+ }+ }+ }+ }+ await verifyDirectory(root);+}+async function recompressDebData(uncompressed, output, members, { env, run }) {await mkdir(members);const names = (await run("ar", ["t", uncompressed], captured(env))).stdout@@ -267,6 +316,10 @@ export async function finalizeGpuiDeb(path.join(root, "usr", "lib", "cap"),);const control = path.join(root, "DEBIAN", "control");+ await verifyDebGlibc(root, await readFile(control, "utf8"), {+ env: tools,+ run,+ });await writeFile(control,withInstalledSize(diff --git a/scripts/finalize-linux-gpui-packages.test.mjs b/scripts/finalize-linux-gpui-packages.test.mjsindex 1fae997d7..eabee5c86 100644--- a/scripts/finalize-linux-gpui-packages.test.mjs+++ b/scripts/finalize-linux-gpui-packages.test.mjs@@ -250,7 +250,7 @@ for (const [name, listing, expected] of [await mkdir(path.join(args[2], "DEBIAN"), { recursive: true });await writeFile(path.join(args[2], "DEBIAN/control"),- "Package: cap\nDepends: libva2, libwebkit2gtk-4.1-0, libgtk-3-0\n",+ "Package: cap\nDepends: libc6 (>= 2.39), libva2, libwebkit2gtk-4.1-0, libgtk-3-0\n",);} else if (command === "dpkg-deb" && args[0] === "--contents") {return {@@ -267,7 +267,7 @@ for (const [name, listing, expected] of []);assert.equal(await readFile(path.join(args[3], "DEBIAN/control"), "utf8"),- "Package: cap\nDepends: libva2\n",+ "Package: cap\nDepends: libc6 (>= 2.39), libva2\n",);await writeFile(args[4], "uncompressed");} else if (command === "ar" && args[0] === "t") {@@ -448,7 +448,7 @@ test("Architecture: amd64","Maintainer: cap","Installed-Size: 12",- "Depends: libva2, libasound2t64 | libasound2, libwebkit2gtk-4.1-0, libgtk-3-0",+ "Depends: libc6 (>= 2.39), libva2, libasound2t64 | libasound2, libwebkit2gtk-4.1-0, libgtk-3-0","Description: Beautiful screen recordings, owned by you.","",].join("\n"),@@ -459,7 +459,7 @@ test(await finalizeGpuiDeb(deb, { unsigned: true });assert.equal(capture("dpkg-deb", ["--field", deb, "Depends"]).trim(),- "libva2, libasound2t64 | libasound2",+ "libc6 (>= 2.39), libva2, libasound2t64 | libasound2",);assert.equal(capture("dpkg-deb", ["--field", deb, "Package"]).trim(),@@ -602,3 +602,78 @@ test(assert.match(capture("rpm", ["-Kv", rpm]), /Payload SHA256 digest: OK/);},);++for (const payload of ["usr/bin/Cap", "usr/lib/cap/libmedia.so"]) {+ test(+ `deb finalization checks glibc requirements in ${payload}`,+ {+ skip:+ !available("dpkg-deb") || !available("gcc") || !available("readelf"),+ },+ async (t) => {+ const root = await workspace(t);+ const tree = path.join(root, "tree");+ await mkdir(path.join(tree, "DEBIAN"), { recursive: true });+ await mkdir(path.dirname(path.join(tree, payload)), { recursive: true });+ const source = path.join(root, "payload.c");+ await writeFile(+ source,+ '#include <stdio.h>\nint main(void) { return puts("cap"); }\n',+ );+ capture("gcc", [+ ...(payload.endsWith(".so") ? ["-shared", "-fPIC"] : []),+ source,+ "-o",+ path.join(tree, payload),+ ]);+ const config = JSON.parse(+ await readFile(+ new URL("../apps/desktop-gpui/tauri.conf.json", import.meta.url),+ "utf8",+ ),+ );+ const declared = config.bundle.linux.deb.depends.find((dependency) =>+ dependency.startsWith("libc6"),+ );+ assert.equal(declared, "libc6 (>= 2.39)");+ const deb = path.join(root, "cap.deb");+ for (const dependency of ["", "libc6", "libc6 (>= 2.0)", declared]) {+ await writeFile(+ path.join(tree, "DEBIAN/control"),+ [+ "Package: cap",+ "Version: 0.6.1",+ "Architecture: all",+ "Maintainer: cap",+ ...(dependency ? [`Depends: ${dependency}`] : []),+ "Description: glibc packaging fixture",+ "",+ ].join("\n"),+ );+ capture("dpkg-deb", [+ "--root-owner-group",+ "-Zgzip",+ "--build",+ tree,+ deb,+ ]);+ const original = await readFile(deb);+ if (dependency !== declared) {+ await assert.rejects(+ finalizeGpuiDeb(deb, { unsigned: true }),+ dependency.includes("2.0")+ ? /requires GLIBC_.*exceeding/+ : /versioned libc6/,+ );+ assert.deepEqual(await readFile(deb), original);+ } else {+ await finalizeGpuiDeb(deb, { unsigned: true });+ assert.equal(+ capture("dpkg-deb", ["--field", deb, "Depends"]).trim(),+ declared,+ );+ }+ }+ },+ );+}