mirror of
https://github.com/stablyai/orca.git
synced 2026-10-30 16:47:34 +00:00
* build(linux): carry the pinned Node inside the AppImage so orca serve's slot works offline Linux packaging places the pinned glibc Node at resources/node-runtime/bin/node before the glibc-floor gate, proves it serves one PTY with the packaged daemon entry, and deb/rpm exclude it through fpm. orca serve's orcad slot copies that Node (hash-checked) instead of downloading. * test(serve): type the bundled Node fixture --------- Co-authored-by: m4air <m4air@Mac.localdomain>
62 lines
2.4 KiB
JavaScript
62 lines
2.4 KiB
JavaScript
/**
|
|
* Linux builds place the pinned Node at resources/node-runtime/bin/node in afterPack, before the
|
|
* glibc-floor gate scans the tree. deb and rpm drop it again through fpm, so only the AppImage
|
|
* ships it: an AppImage's files vanish with its mount, an installed package's do not.
|
|
*/
|
|
const { chmodSync, copyFileSync, mkdirSync } = require('node:fs')
|
|
const { join, resolve } = require('node:path')
|
|
const { pathToFileURL } = require('node:url')
|
|
const {
|
|
APPIMAGE_NODE_RUNTIME_FPM_EXCLUDE,
|
|
APPIMAGE_NODE_RUNTIME_SEGMENTS,
|
|
appImageNodeRuntimeTarget
|
|
} = require('../../src/shared/appimage-node-runtime.ts')
|
|
const { runTerminalHostRoundTrip } = require('./verify-packaged-daemon-entry.cjs')
|
|
|
|
const appImageNodeRuntimeFpmArgs = ['--exclude', APPIMAGE_NODE_RUNTIME_FPM_EXCLUDE]
|
|
const PTY_ROUND_TRIP_TIMEOUT_MS = 20_000
|
|
|
|
async function ensurePinnedNode(target) {
|
|
const { ensurePinnedNodeExecutable } = await import(
|
|
pathToFileURL(resolve(__dirname, 'pinned-node-downloads.mjs')).href
|
|
)
|
|
return ensurePinnedNodeExecutable({ target })
|
|
}
|
|
|
|
/** `arch` is a Node arch name; the copy is hash-checked by the pinned download it comes from. */
|
|
async function placeAppImageNodeRuntime(resourcesDir, arch, ensureNode = ensurePinnedNode) {
|
|
const target = appImageNodeRuntimeTarget(arch)
|
|
if (!target) {
|
|
throw new Error(`[appimage-node-runtime] the Node pin has no glibc build for Linux ${arch}`)
|
|
}
|
|
const destination = join(resourcesDir, ...APPIMAGE_NODE_RUNTIME_SEGMENTS)
|
|
mkdirSync(join(destination, '..'), { recursive: true })
|
|
copyFileSync(await ensureNode(target), destination)
|
|
chmodSync(destination, 0o755)
|
|
return destination
|
|
}
|
|
|
|
/** The bundled Node must load the packaged node-pty and serve one PTY, as the daemon will. */
|
|
async function verifyAppImageNodeRuntimeServesPty(resourcesDir, runtimePath) {
|
|
const stderr = []
|
|
try {
|
|
await runTerminalHostRoundTrip({
|
|
command: [runtimePath],
|
|
entry: join(resourcesDir, 'app.asar.unpacked', 'out', 'main', 'daemon-entry.js'),
|
|
deadline: Date.now() + PTY_ROUND_TRIP_TIMEOUT_MS,
|
|
stderr
|
|
})
|
|
} catch (error) {
|
|
throw new Error(
|
|
`[appimage-node-runtime] the bundled Node did not serve a PTY: ${error.message}\n${stderr.join('').slice(-2000)}`
|
|
)
|
|
}
|
|
console.log('[appimage-node-runtime] OK — the bundled Node served a PTY')
|
|
}
|
|
|
|
module.exports = {
|
|
appImageNodeRuntimeFpmArgs,
|
|
placeAppImageNodeRuntime,
|
|
verifyAppImageNodeRuntimeServesPty
|
|
}
|