Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(desktop): preserve Linux sandbox across parallel package targets (#22190)

AmAzing-8a000ebbe455
diff --git a/apps/desktop/package.json b/apps/desktop/package.json
index ea5afdd2f2e..3de4febab99 100644
--- a/apps/desktop/package.json
+++ b/apps/desktop/package.json
@@ -103,7 +103,7 @@
"drizzle-kit": "^0.31.11",
"drizzle-orm": "^0.45.3",
"electron": "44.5.1",
- "electron-builder": "26.16.1",
+ "electron-builder": "26.18.0",
"electron-store": "^11.0.2",
"electron-updater": "^6.8.9",
"electron-window-state": "^5.0.3",
diff --git a/apps/desktop/pnpm-lock.yaml b/apps/desktop/pnpm-lock.yaml
index b8ccb5a28a9..0aaee84966b 100644
--- a/apps/desktop/pnpm-lock.yaml
+++ b/apps/desktop/pnpm-lock.yaml
@@ -167,8 +167,8 @@ importers:
specifier: 44.5.1
version: 44.5.1([email protected])
electron-builder:
- specifier: 26.16.1
+ specifier: 26.18.0
electron-store:
specifier: ^11.0.2
version: 11.0.2
@@ -1357,8 +1357,8 @@ packages:
engines: {node: '>=12.0.0'}
hasBin: true
- '@electron/[email protected]':
- resolution: {integrity: sha512-RKL/O+jGoXJMxrx/5771y1n0xTKmFuOYGO3gMmwypBM6rsH0kou0mswwdXA2JrhIkE4xyC7v9vGk0n6NPzgOxQ==}
+ '@electron/[email protected]':
+ resolution: {integrity: sha512-IS4pG3BysRrCLJ8xTAfvg+IQDbiUoAzdJy2SfjcYKnLDy5DpCdjnPdhS5Zf5UMfrkB24xu0KC+TqcOxg+eG+6w==}
engines: {node: '>=22.12.0'}
hasBin: true
@@ -3861,12 +3861,12 @@ packages:
resolution: {integrity: sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==}
engines: {node: '>= 8'}
- resolution: {integrity: sha512-FhaO6YOup01ZfQW0Z6gt3AyukJjv1gW4uFK47jTgwcHZKqyN/fSlK2LqPf9tAeZYLP2bRJLDzeOkRImsw2X4Pg==}
+ resolution: {integrity: sha512-lx+KkuCSZHcbECf4R3IAcC9VOFk0+cMUwljO63s5y8yqS1Lw0sRGmjPaWsPwP3zv3ohZYbMhUvjXeiQXXZhJXA==}
engines: {node: '>=14.0.0'}
peerDependencies:
- dmg-builder: 26.16.1
- electron-builder-squirrel-windows: 26.16.1
+ dmg-builder: 26.18.0
+ electron-builder-squirrel-windows: 26.18.0
resolution: {integrity: sha512-tLIEcj5GuR2RSTnxNKdkK0dJ/GrC7P38sUkiDmDuHfsHmbagTFAxDVIBltoklXEVIQ/f14IL8IMJ5pn9Hez1Ew==}
@@ -4500,8 +4500,8 @@ packages:
resolution: {integrity: sha512-7SCDfnQtBObcngVXNPZcnxGxqqPTK4UqeXeKAch+RGH5qpqadWbV9FmN71x9Bb4tTs0TNFb4FT/4Kz4P4Cjqcw==}
engines: {node: '>=6.0.0'}
- resolution: {integrity: sha512-pnI/3Qb24Uk+rMTgIUrsVUKosVgwmBUdF8Zeb8TexOSbpq8MWc7v6l+n+FrEqVkjNZwzBN+XpDS9ENgZ/rkWAw==}
+ resolution: {integrity: sha512-ozCGC54wi2C1RkS2v69y9lQxvoQ1Coh+iT8CmWiyY8y1ZuOKVvuNson2Hd+HEOs9+EZNNsOBbzKgQZ4SNqWd0w==}
resolution: {integrity: sha512-sqo+pNp3qRhCIpbgRi1y8Tgk27Bo2Ry7w0dC1NBeNTdZChWjz9Xb/KOoZbRP/R6pQZ80Qw8YhXw13hWWBbMRnQ==}
@@ -4659,11 +4659,11 @@ packages:
resolution: {integrity: sha512-hDQ9FX17th7NDNMO8/St6m3ADQVqjF0sQoOHI6NUAxC7yDaPmZ9wC9d8zau/9FIqOV7KtNwrPKRt6fkkrzZj0g==}
engines: {node: '>=14.17.0'}
- resolution: {integrity: sha512-w0y44wSaT1l6R7CAGmeHn4nHPfvzDyCAU1xJyi1w9SbPYJpYn76SmHDzqHf8Y7l91cPWTdPYBpGQtB2T5mJ08A==}
+ resolution: {integrity: sha512-a2elgTipboXNIsxqS1HOmHMGp4Pd3LJgIZOdIFTOskBSawvxKyZWYWQ1d7KKA4CtINSchYCYEKzhxRqiKZev9Q==}
- resolution: {integrity: sha512-LrLK65QX5PUYYODXqp23FKrV7CILTtVY7mrJckNknO9jLNSMiqFkKbSMiDRw4CjOADMPVDdWLxY4mezOZWswxg==}
+ resolution: {integrity: sha512-ASgIuQnOq4RuD8jMhS9hI0LS3EMRT1I/M5R6utqifB/BHN80IcCjBdt+DED+NmNPvmBgEtrlExXZitNdA7kXOg==}
engines: {node: '>=14.0.0'}
hasBin: true
@@ -4671,8 +4671,8 @@ packages:
resolution: {integrity: sha512-istWgaXjBfURBSS8LWVW9C3jsc6+ac+tY1lXrQEOTp0lVj+a4OlO1Tmqb36GgnEUDv92DGC9VI1HNXwJinWpgA==}
engines: {node: '>= 14'}
- resolution: {integrity: sha512-Vt3KzQIiw9BImvNOYtndg9Mjki+tl4+1sQiC/+G5j8khWaENOJFWodiB+sUl6yyHwtd37avehskdtPw7f8y/+Q==}
+ resolution: {integrity: sha512-MagnqaZSALSWjcdKu5HEVhYUZD/2BDL3q7XzrqWwub6gf/UfD3ItMgmthVDv9w5y9E0gH1C3JWqKaXwf6f4ROg==}
resolution: {integrity: sha512-mEN+cKZ+oujw/kDTc0XbToVg0dNNZVELttD0xuFo/v3tw8b0aocWF0phcW1XvpUTFHpr4HRApfT3H9QzJgZs5w==}
@@ -8921,7 +8921,7 @@ snapshots:
transitivePeerDependencies:
- supports-color
dependencies:
'@malept/cross-spawn-promise': 2.0.0
debug: 4.4.3([email protected])
@@ -11186,14 +11186,14 @@ snapshots:
normalize-path: 3.0.0
picomatch: 2.3.2
dependencies:
'@electron/asar': 3.4.1
'@electron/fuses': 1.8.0
'@electron/get': 3.1.0([email protected])
'@electron/notarize': 2.5.0([email protected])
'@electron/osx-sign': 1.3.3([email protected])
- '@electron/rebuild': 4.2.0([email protected])
+ '@electron/rebuild': 4.2.1([email protected])
'@electron/universal': 2.0.3([email protected])
'@malept/flatpak-bundler': 0.4.0([email protected])
'@noble/hashes': 1.8.0
@@ -11207,12 +11207,12 @@ snapshots:
chromium-pickle-js: 0.2.0
ci-info: 4.3.1
debug: 4.4.3([email protected])
- dmg-builder: 26.16.1([email protected])([email protected])
+ dmg-builder: 26.18.0([email protected])([email protected])
dotenv: 16.6.1
dotenv-expand: 11.0.7
ejs: 3.1.10
- electron-builder-squirrel-windows: 26.16.1([email protected])([email protected])
- electron-publish: 26.16.0([email protected])
+ electron-builder-squirrel-windows: 26.18.0([email protected])([email protected])
+ electron-publish: 26.18.0([email protected])
fs-extra: 10.1.0
hosted-git-info: 4.1.0
isbinaryfile: 5.0.7
@@ -11824,9 +11824,9 @@ snapshots:
unescape-js: 1.1.4
utf8: 3.0.0
dependencies:
builder-util: 26.16.0([email protected])
fs-extra: 10.1.0
js-yaml: 4.3.2
@@ -11891,23 +11891,23 @@ snapshots:
dependencies:
builder-util: 26.16.0([email protected])
electron-winstaller: 5.4.0([email protected])
transitivePeerDependencies:
- dmg-builder
- supports-color
dependencies:
builder-util: 26.16.0([email protected])
builder-util-runtime: 9.7.0([email protected])
chalk: 4.1.2
ci-info: 4.4.0
- dmg-builder: 26.16.1([email protected])([email protected])
+ dmg-builder: 26.18.0([email protected])([email protected])
fs-extra: 10.1.0
lazy-val: 1.0.5
simple-update-notifier: 2.0.0
@@ -11918,7 +11918,7 @@ snapshots:
dependencies:
'@types/fs-extra': 9.0.13
aws4: 1.13.2
diff --git a/apps/desktop/scripts/__tests__/linuxPackaging.test.mjs b/apps/desktop/scripts/__tests__/linuxPackaging.test.mjs
new file mode 100644
index 00000000000..c14a22b79b3
--- /dev/null
+++ b/apps/desktop/scripts/__tests__/linuxPackaging.test.mjs
@@ -0,0 +1,68 @@
+import { mkdir, mkdtemp, readFile, rm, stat, writeFile } from 'node:fs/promises';
+import { createRequire } from 'node:module';
+import { tmpdir } from 'node:os';
+import path from 'node:path';
+
+import { expect, it, vi } from 'vitest';
+
+const require = createRequire(import.meta.url);
+const builderRequire = createRequire(
+ createRequire(require.resolve('electron-builder')).resolve('app-builder-lib'),
+);
+const { SnapCoreLegacy } = builderRequire('./targets/snap/coreLegacy');
+const builderUtil = builderRequire('builder-util');
+const electronGet = builderRequire('./util/electronGet');
+
+it('keeps the shared Linux sandbox intact while excluding it from the template Snap', async () => {
+ // Exercise the installed packager, not a version/source-string assertion. Older
+ // builders deleted this shared file while AppImage/deb/rpm were still using it.
+ const dir = await mkdtemp(path.join(tmpdir(), 'linux-packaging-'));
+ const appOutDir = path.join(dir, 'linux-unpacked');
+ const stageDir = path.join(dir, 'snap-stage');
+ const templateDir = path.join(dir, 'snap-template');
+ const sandboxPath = path.join(appOutDir, 'chrome-sandbox');
+ const executablePath = path.join(appOutDir, 'lobehub');
+ const compressor = path.join(dir, 'mksquashfs');
+
+ try {
+ await Promise.all([appOutDir, stageDir, templateDir].map((directory) => mkdir(directory)));
+ await writeFile(sandboxPath, 'sandbox fixture', { mode: 0o755 });
+ await writeFile(executablePath, 'app fixture');
+ await writeFile(path.join(templateDir, 'desktop-init.sh'), '#!/bin/sh\n');
+ const originalMode = (await stat(sandboxPath)).mode;
+
+ // Only external downloads and process execution are stubbed. Staging,
+ // filtering and all filesystem mutations use the real upstream code.
+ vi.spyOn(electronGet, 'downloadBuilderToolset').mockResolvedValue(templateDir);
+ vi.stubEnv('MKSQUASHFS_PATH', compressor);
+ const compressionInputs = [];
+ vi.spyOn(builderUtil, 'exec').mockImplementation(async (command, args) => {
+ if (command === 'chmod') return '';
+ expect(command).toBe(compressor);
+ compressionInputs.push(args);
+ // Other targets must still be able to read the helper at this point.
+ expect(await readFile(sandboxPath, 'utf8')).toBe('sandbox fixture');
+ return '';
+ });
+
+ const snap = new SnapCoreLegacy({ executableName: 'lobehub' }, {}, {});
+ await snap.buildWithTemplate({
+ appOutDir,
+ artifactPath: path.join(dir, 'lobehub.snap'),
+ compression: 'xz',
+ extraAppArgs: [],
+ snapArch: builderUtil.Arch.x64,
+ stageDir,
+ });
+
+ expect(compressionInputs).toHaveLength(1);
+ expect(compressionInputs[0]).toContain(executablePath);
+ expect(compressionInputs[0]).not.toContain(sandboxPath);
+ expect(await readFile(sandboxPath, 'utf8')).toBe('sandbox fixture');
+ expect((await stat(sandboxPath)).mode).toBe(originalMode);
+ } finally {
+ vi.restoreAllMocks();
+ vi.unstubAllEnvs();
+ await rm(dir, { recursive: true, force: true });
+ }
+});