|
1 | 1 | import crypto from 'node:crypto' |
2 | | -import { mkdir, readFile, writeFile } from 'node:fs/promises' |
| 2 | +import { copyFile, mkdir, readFile, writeFile } from 'node:fs/promises' |
3 | 3 | import path from 'node:path' |
4 | 4 | import { spawn } from '@socketsecurity/lib-stable/process/spawn/child' |
5 | 5 | import { getDefaultLogger } from '@socketsecurity/lib-stable/logger/default' |
@@ -142,28 +142,36 @@ async function buildSeaTarget( |
142 | 142 | `SEA blob generation failed for ${target}. Inspect node-smol output.`, |
143 | 143 | ) |
144 | 144 | } |
145 | | - const result = await spawn( |
146 | | - injector, |
147 | | - [ |
148 | | - 'inject', |
149 | | - '--executable', |
150 | | - base, |
151 | | - '--output', |
152 | | - output, |
153 | | - '--sea', |
154 | | - blob, |
155 | | - '--vfs-compat', |
156 | | - '--skip-repack', |
157 | | - ], |
158 | | - { |
159 | | - stdio: process.argv.includes('--json') ? 'pipe' : 'inherit', |
160 | | - timeout: 600_000, |
161 | | - }, |
162 | | - ) |
163 | | - if (result.code !== 0) { |
164 | | - throw new Error( |
165 | | - `SEA build failed for ${target}: exit ${result.code}. Inspect binject output.`, |
| 145 | + if (target.startsWith('linux-')) { |
| 146 | + const { inject } = await import('postject') |
| 147 | + await copyFile(base, output) |
| 148 | + await inject(output, 'NODE_SEA_BLOB', await readFile(blob), { |
| 149 | + sentinelFuse: 'NODE_SEA_FUSE_fce680ab2cc467b6e072b8b5df1996b2', |
| 150 | + }) |
| 151 | + } else { |
| 152 | + const result = await spawn( |
| 153 | + injector, |
| 154 | + [ |
| 155 | + 'inject', |
| 156 | + '--executable', |
| 157 | + base, |
| 158 | + '--output', |
| 159 | + output, |
| 160 | + '--sea', |
| 161 | + blob, |
| 162 | + '--vfs-compat', |
| 163 | + '--skip-repack', |
| 164 | + ], |
| 165 | + { |
| 166 | + stdio: process.argv.includes('--json') ? 'pipe' : 'inherit', |
| 167 | + timeout: 600_000, |
| 168 | + }, |
166 | 169 | ) |
| 170 | + if (result.code !== 0) { |
| 171 | + throw new Error( |
| 172 | + `SEA build failed for ${target}: exit ${result.code}. Inspect binject output.`, |
| 173 | + ) |
| 174 | + } |
167 | 175 | } |
168 | 176 | return crypto |
169 | 177 | .createHash('sha256') |
|
0 commit comments