Skip to content

The agent that grows with you

fix(desktop): ship chromium in the payload — drop stripFetchCache

ethernet9ed9cc83500d
diff --git a/apps/desktop/scripts/after-pack.mjs b/apps/desktop/scripts/after-pack.mjs
index bd54043363d..75cb2a6e71b 100644
--- a/apps/desktop/scripts/after-pack.mjs
+++ b/apps/desktop/scripts/after-pack.mjs
@@ -21,7 +21,7 @@
import path from 'node:path'
-import { findPackedPayload, relativizePayloadLinks, stripFetchCache } from './materialize-payload-links.mjs'
+import { findPackedPayload, relativizePayloadLinks } from './materialize-payload-links.mjs'
import { batchSignAppTree } from './batch-sign-binaries.mjs'
import { resolveSigningIdentity, signNestedChromium } from './sign-nested-chromium.mjs'
import { sanitizeTree } from './sanitize-pe-signatures.mjs'
@@ -32,13 +32,12 @@ export default async function afterPack(context) {
if (platform === 'darwin') {
const payload = findPackedPayload(context.appOutDir, platform)
if (payload) {
- const dropped = stripFetchCache(payload)
const n = relativizePayloadLinks(payload)
const entitlements = path.join(import.meta.dirname, '..', 'electron', 'entitlements.mac.inherit.plist')
const { identity, keychain } = await resolveSigningIdentity(context.packager)
const nested = signNestedChromium(payload, { entitlements, identity, keychain })
console.log(
- `[after-pack] dropped ${dropped} fetch- cache dirs; relativized ${n} payload links; repaired ${nested.repaired} framework links; signed ${nested.signed} nested chromium targets` +
+ `[after-pack] relativized ${n} payload links; repaired ${nested.repaired} framework links; signed ${nested.signed} nested chromium targets` +
(identity ? ` as ${identity}` : ' (no Developer ID in the builder keychain)')
)
}
diff --git a/apps/desktop/scripts/materialize-payload-links.mjs b/apps/desktop/scripts/materialize-payload-links.mjs
index 21e811b4fbd..2f562464f3a 100644
--- a/apps/desktop/scripts/materialize-payload-links.mjs
+++ b/apps/desktop/scripts/materialize-payload-links.mjs
@@ -38,26 +38,6 @@ export function findPackedPayload(appOutDir, platform) {
return candidates.find(p => fs.existsSync(p)) || null
}
-// The store keeps verified downloads under fetch-<sha16>/. A sealed
-// payload already has the unpacked entries. Apple's notary unpacks
-// every archive it finds and rejects unsigned Mach-O inside them
-// (uv tarball, leftover chromium). Drop the cache and leftover
-// chromium store entries before codesign.
-export function stripFetchCache(root) {
- if (!root) return 0
- const tools = path.join(root, 'tools')
- if (!fs.existsSync(tools)) return 0
- let removed = 0
- for (const ent of fs.readdirSync(tools, { withFileTypes: true })) {
- if (!ent.isDirectory()) continue
- if (ent.name.startsWith('fetch-') || /^chromium(_headless_shell)?-\d+/.test(ent.name)) {
- fs.rmSync(path.join(tools, ent.name), { recursive: true, force: true })
- removed += 1
- }
- }
- return removed
-}
-
/**
* Rewrite payload venv/bin symlinks to RELATIVE targets that resolve
* inside the bundle. Returns the count rewritten.
diff --git a/apps/desktop/scripts/materialize-payload-links.test.mjs b/apps/desktop/scripts/materialize-payload-links.test.mjs
index 758775d9416..1284e65c14e 100644
--- a/apps/desktop/scripts/materialize-payload-links.test.mjs
+++ b/apps/desktop/scripts/materialize-payload-links.test.mjs
@@ -4,7 +4,7 @@ import os from 'node:os'
import path from 'node:path'
import { test } from 'vitest'
-import { findPackedPayload, relativizePayloadLinks, stripFetchCache } from './materialize-payload-links.mjs'
+import { findPackedPayload, relativizePayloadLinks } from './materialize-payload-links.mjs'
function tempRoot() {
return fs.mkdtempSync(path.join(os.tmpdir(), 'hermes-relativize-'))
@@ -124,41 +124,6 @@ test('relativizePayloadLinks leaves already-relative links alone', () => {
}
})
-test('stripFetchCache removes only fetch- dirs under tools/', () => {
- const root = tempRoot()
- try {
- const tools = path.join(root, 'tools')
- fs.mkdirSync(path.join(tools, 'fetch-546f7f8a6c70ff13'), { recursive: true })
- fs.writeFileSync(path.join(tools, 'fetch-546f7f8a6c70ff13', 'uv.tar.gz'), 'x')
- fs.mkdirSync(path.join(tools, 'uv-0.12.3-darwin-arm64'), { recursive: true })
- fs.writeFileSync(path.join(tools, 'uv-0.12.3-darwin-arm64', 'uv'), 'bin')
- assert.equal(stripFetchCache(root), 1)
- assert.equal(fs.existsSync(path.join(tools, 'fetch-546f7f8a6c70ff13')), false)
- assert.equal(fs.existsSync(path.join(tools, 'uv-0.12.3-darwin-arm64', 'uv')), true)
- assert.equal(stripFetchCache(root), 0)
- } finally {
- fs.rmSync(root, { recursive: true, force: true })
- }
-})
-
-test('stripFetchCache also drops leftover chromium store entries', () => {
- const root = tempRoot()
- try {
- const tools = path.join(root, 'tools')
- fs.mkdirSync(path.join(tools, 'chromium-1208'), { recursive: true })
- fs.writeFileSync(path.join(tools, 'chromium-1208', 'INSTALLATION_COMPLETE'), '')
- fs.mkdirSync(path.join(tools, 'chromium_headless_shell-1208'), { recursive: true })
- fs.mkdirSync(path.join(tools, 'uv-0.12.3-darwin-arm64'), { recursive: true })
- fs.writeFileSync(path.join(tools, 'uv-0.12.3-darwin-arm64', 'uv'), 'bin')
- assert.equal(stripFetchCache(root), 2)
- assert.equal(fs.existsSync(path.join(tools, 'chromium-1208')), false)
- assert.equal(fs.existsSync(path.join(tools, 'chromium_headless_shell-1208')), false)
- assert.equal(fs.existsSync(path.join(tools, 'uv-0.12.3-darwin-arm64', 'uv')), true)
- } finally {
- fs.rmSync(root, { recursive: true, force: true })
- }
-})
-
test('relativizePayloadLinks does not touch a framework file-symlink (not under venv/bin)', () => {
if (process.platform === 'win32') return
const root = tempRoot()
diff --git a/scripts/build-bundled-desktop.mjs b/scripts/build-bundled-desktop.mjs
index 7aeaac35a0d..8741f32b196 100644
--- a/scripts/build-bundled-desktop.mjs
+++ b/scripts/build-bundled-desktop.mjs
@@ -25,7 +25,7 @@ import { fileURLToPath } from 'node:url'
import { CLI_LAUNCHER_SPECS, posixTrampolineScripts, renderWinWrapper } from './desktop-cli/cli-entrypoints.mjs'
import { windowsFileVersion } from '../apps/desktop/scripts/windows-file-version.mjs'
-import { relativizePayloadLinks, stripFetchCache } from '../apps/desktop/scripts/materialize-payload-links.mjs'
+import { relativizePayloadLinks } from '../apps/desktop/scripts/materialize-payload-links.mjs'
import { nightlyBuildMinutes } from './msix-shared.mjs'
const REPO_ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')
@@ -273,8 +273,6 @@ if (!fs.existsSync(path.join(plantedWeb, 'index.html'))) {
}
console.log('[build-bundled] planted hermes_cli/tui_dist/entry.js and hermes_cli/web_dist into the payload')
-const dropped = stripFetchCache(PAYLOAD_DIR)
-console.log(`[build-bundled] dropped ${dropped} fetch- cache dirs from the payload`)
if (process.platform === 'darwin') {
const n = relativizePayloadLinks(PAYLOAD_DIR)
console.log(`[build-bundled] relativized ${n} payload links so codesign can sign each path once`)