@fungi.computer/computer 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Dockerfile +85 -0
- package/LICENSE +21 -0
- package/README.md +228 -2
- package/container/computer-init.mjs +119 -0
- package/container/computer-start.sh +24 -0
- package/container/package.json +14 -0
- package/container/pnpm-lock.yaml +378 -0
- package/container/pnpm-workspace.yaml +5 -0
- package/container/resource-bounds.mjs +54 -0
- package/container/runtime-privileges.cc +37 -0
- package/container/runtime-privileges.mjs +11 -0
- package/container/terminal-assets/README.md +35 -0
- package/container/terminal-assets/bashrc +49 -0
- package/container/terminal-assets/git-prompt.sh +586 -0
- package/container/terminal-protocol.mjs +58 -0
- package/container/terminal-runtime.mjs +10 -0
- package/container/terminal-server.mjs +243 -0
- package/dist/apply-patch/LICENSE.codex +201 -0
- package/dist/apply-patch/build.mjs +98 -0
- package/dist/apply-patch/cache.mjs +168 -0
- package/dist/apply-patch/compile.mjs +199 -0
- package/dist/apply-patch/docker/darwin.Dockerfile +15 -0
- package/dist/apply-patch/docker/linux-arm64.Dockerfile +38 -0
- package/dist/apply-patch/docker/linux-x64.Dockerfile +23 -0
- package/dist/apply-patch/main.rs +320 -0
- package/dist/apply-patch/notices.mjs +44 -0
- package/dist/apply-patch/pin.mjs +8 -0
- package/dist/apply-patch/toolchain.mjs +39 -0
- package/dist/computer-backends.d.ts +94 -0
- package/dist/computer-backends.js +103 -0
- package/dist/computerd.cjs +18010 -0
- package/dist/container-policy.d.ts +7 -0
- package/dist/container-policy.js +24 -0
- package/dist/container-system-trust.d.ts +8 -0
- package/dist/container-system-trust.js +66 -0
- package/dist/egress-policy.d.ts +89 -0
- package/dist/egress-policy.js +240 -0
- package/dist/execution-result.d.ts +3 -0
- package/dist/execution-result.js +28 -0
- package/dist/files-patch.d.ts +20 -0
- package/dist/files-patch.js +108 -0
- package/dist/files.d.ts +75 -0
- package/dist/files.js +136 -0
- package/dist/fleet/admission.d.ts +14 -0
- package/dist/fleet/admission.js +10 -0
- package/dist/fleet/backing.d.ts +52 -0
- package/dist/fleet/backing.js +242 -0
- package/dist/fleet/computers.d.ts +62 -0
- package/dist/fleet/computers.js +35 -0
- package/dist/fleet/index.d.ts +11 -0
- package/dist/fleet/index.js +11 -0
- package/dist/fleet/inventory-wire.d.ts +29 -0
- package/dist/fleet/inventory-wire.js +15 -0
- package/dist/fleet/inventory.d.ts +24 -0
- package/dist/fleet/inventory.js +152 -0
- package/dist/fleet/lifecycle.d.ts +99 -0
- package/dist/fleet/lifecycle.js +418 -0
- package/dist/fleet/runtime-usage.d.ts +50 -0
- package/dist/fleet/runtime-usage.js +145 -0
- package/dist/fleet/slots.d.ts +30 -0
- package/dist/fleet/slots.js +46 -0
- package/dist/fleet/wire.d.ts +228 -0
- package/dist/fleet/wire.js +127 -0
- package/dist/host-config.d.ts +12 -0
- package/dist/host-config.js +10 -0
- package/dist/index.d.ts +282 -0
- package/dist/index.js +1237 -0
- package/dist/light-shell.d.ts +44 -0
- package/dist/light-shell.js +376 -0
- package/dist/local-backend.d.ts +52 -0
- package/dist/local-backend.js +143 -0
- package/dist/metered-container-host.d.ts +26 -0
- package/dist/metered-container-host.js +48 -0
- package/dist/on-box-vm.d.ts +119 -0
- package/dist/on-box-vm.js +294 -0
- package/dist/operation-contract.d.ts +456 -0
- package/dist/operation-contract.js +450 -0
- package/dist/operation-record.d.ts +50 -0
- package/dist/operation-record.js +162 -0
- package/dist/preview.d.ts +55 -0
- package/dist/preview.js +151 -0
- package/dist/process-inventory.d.ts +80 -0
- package/dist/process-inventory.js +427 -0
- package/dist/pull-pending.d.ts +26 -0
- package/dist/pull-pending.js +35 -0
- package/dist/team-candidate-builder.mjs +28220 -0
- package/dist/transport-backend.d.ts +3 -0
- package/dist/transport-backend.js +99 -0
- package/dist/workspace-stream.d.ts +2 -0
- package/dist/workspace-stream.js +31 -0
- package/package.json +126 -3
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import { createHash } from "node:crypto";
|
|
2
|
+
import {
|
|
3
|
+
chmod,
|
|
4
|
+
copyFile,
|
|
5
|
+
mkdir,
|
|
6
|
+
mkdtemp,
|
|
7
|
+
readFile,
|
|
8
|
+
rename,
|
|
9
|
+
rm,
|
|
10
|
+
stat,
|
|
11
|
+
writeFile,
|
|
12
|
+
} from "node:fs/promises";
|
|
13
|
+
import { join } from "node:path";
|
|
14
|
+
import lockfile from "proper-lockfile";
|
|
15
|
+
import { z } from "zod";
|
|
16
|
+
|
|
17
|
+
const digestSchema = z.string().regex(/^[a-f0-9]{64}$/u);
|
|
18
|
+
const versionSchema = z.string().regex(/^rust-v\d+\.\d+\.\d+$/u);
|
|
19
|
+
const targetSchema = z.enum([
|
|
20
|
+
"linux-x64",
|
|
21
|
+
"linux-arm64",
|
|
22
|
+
"darwin-x64",
|
|
23
|
+
"darwin-arm64",
|
|
24
|
+
]);
|
|
25
|
+
const pinSchema = z.object({
|
|
26
|
+
version: versionSchema,
|
|
27
|
+
sourceSha256: digestSchema,
|
|
28
|
+
});
|
|
29
|
+
const receiptSchema = z.strictObject({
|
|
30
|
+
schemaVersion: z.literal(1),
|
|
31
|
+
version: versionSchema,
|
|
32
|
+
target: targetSchema,
|
|
33
|
+
sourceSha256: digestSchema,
|
|
34
|
+
wrapperSha256: digestSchema,
|
|
35
|
+
binarySha256: digestSchema,
|
|
36
|
+
noticesSha256: digestSchema,
|
|
37
|
+
});
|
|
38
|
+
const noticesSchema = z.object({
|
|
39
|
+
platform: targetSchema,
|
|
40
|
+
packages: z.array(
|
|
41
|
+
z.object({ name: z.string().min(1), texts: z.array(z.string()) }),
|
|
42
|
+
),
|
|
43
|
+
});
|
|
44
|
+
function missing(cause) {
|
|
45
|
+
return cause instanceof Error && "code" in cause && cause.code === "ENOENT";
|
|
46
|
+
}
|
|
47
|
+
async function digest(path) {
|
|
48
|
+
return createHash("sha256")
|
|
49
|
+
.update(await readFile(path))
|
|
50
|
+
.digest("hex");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** One immutable artifact per Codex pin/target, shared by every checkout and updater. */
|
|
54
|
+
export async function ensureNativePatchArtifact({
|
|
55
|
+
cacheRoot,
|
|
56
|
+
pin: inputPin,
|
|
57
|
+
target: inputTarget,
|
|
58
|
+
wrapper,
|
|
59
|
+
destination,
|
|
60
|
+
build,
|
|
61
|
+
}) {
|
|
62
|
+
const pin = pinSchema.parse(inputPin);
|
|
63
|
+
const target = targetSchema.parse(inputTarget);
|
|
64
|
+
const wrapperSha256 = await digest(wrapper);
|
|
65
|
+
const key = join(cacheRoot, pin.version, target);
|
|
66
|
+
const artifact = join(key, "artifact");
|
|
67
|
+
await mkdir(key, { recursive: true, mode: 0o700 });
|
|
68
|
+
async function published() {
|
|
69
|
+
try {
|
|
70
|
+
await stat(artifact);
|
|
71
|
+
} catch (cause) {
|
|
72
|
+
if (missing(cause)) return false;
|
|
73
|
+
throw cause;
|
|
74
|
+
}
|
|
75
|
+
const receipt = receiptSchema.parse(
|
|
76
|
+
JSON.parse(await readFile(join(artifact, "receipt.json"), "utf8")),
|
|
77
|
+
);
|
|
78
|
+
if (
|
|
79
|
+
receipt.version !== pin.version ||
|
|
80
|
+
receipt.target !== target ||
|
|
81
|
+
receipt.sourceSha256 !== pin.sourceSha256 ||
|
|
82
|
+
receipt.wrapperSha256 !== wrapperSha256
|
|
83
|
+
)
|
|
84
|
+
throw new Error(
|
|
85
|
+
`Cached patch artifact does not match this pin or wrapper: ${artifact}. Use a new pin before rebuilding.`,
|
|
86
|
+
);
|
|
87
|
+
if (
|
|
88
|
+
(await digest(join(artifact, "fungi-apply-patch"))) !==
|
|
89
|
+
receipt.binarySha256 ||
|
|
90
|
+
(await digest(join(artifact, "build.json"))) !== receipt.noticesSha256
|
|
91
|
+
)
|
|
92
|
+
throw new Error(
|
|
93
|
+
`Cached patch artifact checksum mismatch: ${artifact}. The artifact was not used or rebuilt.`,
|
|
94
|
+
);
|
|
95
|
+
const notices = noticesSchema.parse(
|
|
96
|
+
JSON.parse(await readFile(join(artifact, "build.json"), "utf8")),
|
|
97
|
+
);
|
|
98
|
+
if (notices.platform !== target)
|
|
99
|
+
throw new Error("Cached patch notices do not match their target");
|
|
100
|
+
return true;
|
|
101
|
+
}
|
|
102
|
+
async function restore(kind) {
|
|
103
|
+
await mkdir(destination, { recursive: true });
|
|
104
|
+
await copyFile(
|
|
105
|
+
join(artifact, "fungi-apply-patch"),
|
|
106
|
+
join(destination, "fungi-apply-patch"),
|
|
107
|
+
);
|
|
108
|
+
await copyFile(
|
|
109
|
+
join(artifact, "build.json"),
|
|
110
|
+
join(destination, "build.json"),
|
|
111
|
+
);
|
|
112
|
+
await chmod(join(destination, "fungi-apply-patch"), 0o755);
|
|
113
|
+
return { kind, artifact };
|
|
114
|
+
}
|
|
115
|
+
if (await published()) return restore("hit");
|
|
116
|
+
// Compilation runs in an asynchronous child, so the maintained lock heartbeat stays live.
|
|
117
|
+
const release = await lockfile.lock(key, {
|
|
118
|
+
stale: 120_000,
|
|
119
|
+
update: 20_000,
|
|
120
|
+
retries: { retries: 600, factor: 1.5, minTimeout: 50, maxTimeout: 1_000 },
|
|
121
|
+
});
|
|
122
|
+
let staging;
|
|
123
|
+
try {
|
|
124
|
+
if (await published()) return await restore("hit");
|
|
125
|
+
await build();
|
|
126
|
+
const notices = noticesSchema.parse(
|
|
127
|
+
JSON.parse(await readFile(join(destination, "build.json"), "utf8")),
|
|
128
|
+
);
|
|
129
|
+
if (notices.platform !== target)
|
|
130
|
+
throw new Error("Native build does not match the cache target");
|
|
131
|
+
staging = await mkdtemp(join(key, "staging-"));
|
|
132
|
+
await copyFile(
|
|
133
|
+
join(destination, "fungi-apply-patch"),
|
|
134
|
+
join(staging, "fungi-apply-patch"),
|
|
135
|
+
);
|
|
136
|
+
await copyFile(
|
|
137
|
+
join(destination, "build.json"),
|
|
138
|
+
join(staging, "build.json"),
|
|
139
|
+
);
|
|
140
|
+
await writeFile(
|
|
141
|
+
join(staging, "receipt.json"),
|
|
142
|
+
JSON.stringify(
|
|
143
|
+
{
|
|
144
|
+
schemaVersion: 1,
|
|
145
|
+
version: pin.version,
|
|
146
|
+
target,
|
|
147
|
+
sourceSha256: pin.sourceSha256,
|
|
148
|
+
wrapperSha256,
|
|
149
|
+
binarySha256: await digest(join(staging, "fungi-apply-patch")),
|
|
150
|
+
noticesSha256: await digest(join(staging, "build.json")),
|
|
151
|
+
},
|
|
152
|
+
null,
|
|
153
|
+
2,
|
|
154
|
+
) + "\n",
|
|
155
|
+
{ mode: 0o600 },
|
|
156
|
+
);
|
|
157
|
+
await rename(staging, artifact);
|
|
158
|
+
staging = undefined;
|
|
159
|
+
return await restore("built");
|
|
160
|
+
} finally {
|
|
161
|
+
try {
|
|
162
|
+
if (staging !== undefined)
|
|
163
|
+
await rm(staging, { recursive: true, force: true });
|
|
164
|
+
} finally {
|
|
165
|
+
await release();
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
// Compiles `fungi-apply-patch` for one target inside a prepared builder: a
|
|
2
|
+
// native host with rustup, a release container (docker/*.Dockerfile) or the
|
|
3
|
+
// Computer image's builder stage. It needs only Node, rustup with the pinned
|
|
4
|
+
// toolchain, a C toolchain and network access to the pinned Codex release.
|
|
5
|
+
//
|
|
6
|
+
// node compile.mjs --out <dir> [--target <platform>] [--scratch <dir>]
|
|
7
|
+
// [--require-glibc <version>]
|
|
8
|
+
//
|
|
9
|
+
// It writes <out>/fungi-apply-patch and <out>/build.json (the license and
|
|
10
|
+
// notice texts of every crate compiled into it).
|
|
11
|
+
import { createHash } from "node:crypto";
|
|
12
|
+
import { spawnSync } from "node:child_process";
|
|
13
|
+
import { access, copyFile, mkdir, readFile, writeFile } from "node:fs/promises";
|
|
14
|
+
import { dirname, resolve } from "node:path";
|
|
15
|
+
import { homedir, tmpdir } from "node:os";
|
|
16
|
+
import { fileURLToPath, URL } from "node:url";
|
|
17
|
+
import console from "node:console";
|
|
18
|
+
import process from "node:process";
|
|
19
|
+
import { parseArgs } from "node:util";
|
|
20
|
+
import { nativeNotices } from "./notices.mjs";
|
|
21
|
+
import { codexPatchPin } from "./pin.mjs";
|
|
22
|
+
import {
|
|
23
|
+
ensureNativeHostToolchain,
|
|
24
|
+
selectCargoInvocation,
|
|
25
|
+
} from "./toolchain.mjs";
|
|
26
|
+
|
|
27
|
+
const { fetch } = globalThis;
|
|
28
|
+
const { values } = parseArgs({
|
|
29
|
+
options: {
|
|
30
|
+
target: { type: "string", default: `${process.platform}-${process.arch}` },
|
|
31
|
+
out: { type: "string" },
|
|
32
|
+
scratch: { type: "string" },
|
|
33
|
+
"require-glibc": { type: "string" },
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
if (values.out === undefined) throw new Error("compile.mjs requires --out");
|
|
37
|
+
const platform = values.target;
|
|
38
|
+
const host = `${process.platform}-${process.arch}`;
|
|
39
|
+
const crossLinuxArm = platform === "linux-arm64" && host === "linux-x64";
|
|
40
|
+
const macTarget = {
|
|
41
|
+
"darwin-arm64": "aarch64-apple-darwin",
|
|
42
|
+
"darwin-x64": "x86_64-apple-darwin",
|
|
43
|
+
}[platform];
|
|
44
|
+
const crossMac = macTarget !== undefined && process.platform !== "darwin";
|
|
45
|
+
if (platform !== host && !crossMac && !crossLinuxArm)
|
|
46
|
+
throw new Error(`Unsupported native build target: ${platform} on ${host}`);
|
|
47
|
+
const glibc = values["require-glibc"];
|
|
48
|
+
if (
|
|
49
|
+
glibc !== undefined &&
|
|
50
|
+
process.report.getReport().header.glibcVersionRuntime !== glibc
|
|
51
|
+
)
|
|
52
|
+
throw new Error(`This release builder requires glibc ${glibc}`);
|
|
53
|
+
|
|
54
|
+
const source = fileURLToPath(new URL("./", import.meta.url));
|
|
55
|
+
const out = resolve(values.out);
|
|
56
|
+
const scratch = resolve(
|
|
57
|
+
values.scratch ?? resolve(tmpdir(), `fungi-apply-patch-build-${platform}`),
|
|
58
|
+
);
|
|
59
|
+
const archive = resolve(scratch, `codex-${codexPatchPin.version}.tar.gz`);
|
|
60
|
+
const upstream = resolve(scratch, `codex-${codexPatchPin.version}/codex-rs`);
|
|
61
|
+
|
|
62
|
+
function run(command, args, options = {}) {
|
|
63
|
+
const result = spawnSync(command, args, { stdio: "inherit", ...options });
|
|
64
|
+
if (result.error !== undefined) throw result.error;
|
|
65
|
+
if (result.status !== 0)
|
|
66
|
+
throw new Error(`${command} failed (${String(result.status)})`);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
await mkdir(scratch, { recursive: true });
|
|
70
|
+
try {
|
|
71
|
+
await access(archive);
|
|
72
|
+
} catch {
|
|
73
|
+
const response = await fetch(
|
|
74
|
+
`https://github.com/openai/codex/archive/refs/tags/${codexPatchPin.version}.tar.gz`,
|
|
75
|
+
);
|
|
76
|
+
if (!response.ok)
|
|
77
|
+
throw new Error(`Codex source download failed: ${response.status}`);
|
|
78
|
+
await writeFile(archive, new Uint8Array(await response.arrayBuffer()));
|
|
79
|
+
}
|
|
80
|
+
if (
|
|
81
|
+
createHash("sha256")
|
|
82
|
+
.update(await readFile(archive))
|
|
83
|
+
.digest("hex") !== codexPatchPin.sourceSha256
|
|
84
|
+
)
|
|
85
|
+
throw new Error("Pinned Codex source checksum mismatch");
|
|
86
|
+
// Re-extract the verified source so old wrapper or manifest edits cannot survive.
|
|
87
|
+
run("tar", ["-xzf", archive, "-C", scratch]);
|
|
88
|
+
const manifestPath = resolve(upstream, "Cargo.toml");
|
|
89
|
+
const manifest = await readFile(manifestPath, "utf8");
|
|
90
|
+
// The release tag bumps workspace package versions but leaves 0.0.0 in its
|
|
91
|
+
// lockfile. Restore that build-only metadata; all dependency pins stay intact.
|
|
92
|
+
await writeFile(
|
|
93
|
+
manifestPath,
|
|
94
|
+
manifest.replace(
|
|
95
|
+
`version = "${codexPatchPin.version.slice(6)}"`,
|
|
96
|
+
'version = "0.0.0"',
|
|
97
|
+
),
|
|
98
|
+
);
|
|
99
|
+
await copyFile(
|
|
100
|
+
resolve(source, "main.rs"),
|
|
101
|
+
resolve(upstream, "apply-patch/src/fungi-main.rs"),
|
|
102
|
+
);
|
|
103
|
+
const patchManifest = resolve(upstream, "apply-patch/Cargo.toml");
|
|
104
|
+
await writeFile(
|
|
105
|
+
patchManifest,
|
|
106
|
+
`${await readFile(patchManifest, "utf8")}\n[[bin]]\nname = "fungi-apply-patch"\npath = "src/fungi-main.rs"\n`,
|
|
107
|
+
);
|
|
108
|
+
const cargoHome = process.env.CARGO_HOME ?? resolve(homedir(), ".cargo");
|
|
109
|
+
// Remap build-host paths so the executable carries no checkout or home path.
|
|
110
|
+
const nativePathFlags = [
|
|
111
|
+
`-ffile-prefix-map=${scratch}=/build`,
|
|
112
|
+
`-ffile-prefix-map=${cargoHome}=/cargo`,
|
|
113
|
+
]
|
|
114
|
+
.map((flag) => JSON.stringify(flag))
|
|
115
|
+
.join(" ");
|
|
116
|
+
ensureNativeHostToolchain({ toolchain: codexPatchPin.rustToolchain });
|
|
117
|
+
const { command: cargoCommand, args: cargoArgs } = selectCargoInvocation({
|
|
118
|
+
toolchain: codexPatchPin.rustToolchain,
|
|
119
|
+
cargoArgs: [
|
|
120
|
+
crossMac ? "zigbuild" : "build",
|
|
121
|
+
"--release",
|
|
122
|
+
...(crossMac
|
|
123
|
+
? ["--target", macTarget]
|
|
124
|
+
: crossLinuxArm
|
|
125
|
+
? ["--target", "aarch64-unknown-linux-gnu"]
|
|
126
|
+
: []),
|
|
127
|
+
"--message-format=json",
|
|
128
|
+
"--manifest-path",
|
|
129
|
+
manifestPath,
|
|
130
|
+
"--locked",
|
|
131
|
+
"-p",
|
|
132
|
+
"codex-apply-patch",
|
|
133
|
+
"--bin",
|
|
134
|
+
"fungi-apply-patch",
|
|
135
|
+
],
|
|
136
|
+
});
|
|
137
|
+
const cargo = spawnSync(cargoCommand, cargoArgs, {
|
|
138
|
+
encoding: "utf8",
|
|
139
|
+
maxBuffer: 64 * 1024 * 1024,
|
|
140
|
+
env: {
|
|
141
|
+
...process.env,
|
|
142
|
+
CARGO_TARGET_DIR: resolve(scratch, "target"),
|
|
143
|
+
CARGO_ENCODED_RUSTFLAGS: [
|
|
144
|
+
`--remap-path-prefix=${scratch}=/build`,
|
|
145
|
+
`--remap-path-prefix=${cargoHome}=/cargo`,
|
|
146
|
+
].join("\x1f"),
|
|
147
|
+
CFLAGS: nativePathFlags,
|
|
148
|
+
CXXFLAGS: nativePathFlags,
|
|
149
|
+
CC_SHELL_ESCAPED_FLAGS: "1",
|
|
150
|
+
CARGO_PROFILE_RELEASE_DEBUG: "0",
|
|
151
|
+
CARGO_PROFILE_RELEASE_INCREMENTAL: "false",
|
|
152
|
+
// Cargo strips debug references during linking, before Mach-O signing.
|
|
153
|
+
CARGO_PROFILE_RELEASE_STRIP: "debuginfo",
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
if (cargo.error) throw cargo.error;
|
|
157
|
+
process.stderr.write(cargo.stderr);
|
|
158
|
+
const messages = cargo.stdout
|
|
159
|
+
.trim()
|
|
160
|
+
.split("\n")
|
|
161
|
+
.filter(Boolean)
|
|
162
|
+
.map((line) => JSON.parse(line));
|
|
163
|
+
for (const message of messages) {
|
|
164
|
+
if (message.reason === "compiler-message" && message.message.rendered)
|
|
165
|
+
process.stderr.write(message.message.rendered);
|
|
166
|
+
}
|
|
167
|
+
if (cargo.status !== 0) throw new Error("Native patch engine build failed");
|
|
168
|
+
const artifacts = messages
|
|
169
|
+
.filter((message) => message.reason === "compiler-artifact")
|
|
170
|
+
.map(({ package_id, manifest_path }) => ({ package_id, manifest_path }));
|
|
171
|
+
const executable = messages.find(
|
|
172
|
+
(message) =>
|
|
173
|
+
message.reason === "compiler-artifact" &&
|
|
174
|
+
message.target.name === "fungi-apply-patch" &&
|
|
175
|
+
message.executable,
|
|
176
|
+
)?.executable;
|
|
177
|
+
if (!executable) throw new Error("Cargo did not report the patch executable");
|
|
178
|
+
const destination = resolve(out, "fungi-apply-patch");
|
|
179
|
+
await mkdir(dirname(destination), { recursive: true });
|
|
180
|
+
await copyFile(executable, destination);
|
|
181
|
+
// Keep the cross-linker's Mach-O code signature intact; Linux strip cannot
|
|
182
|
+
// re-sign a Mach-O executable. Native Apple builds use Apple's strip.
|
|
183
|
+
if (!crossMac)
|
|
184
|
+
run(crossLinuxArm ? "aarch64-linux-gnu-strip" : "strip", [
|
|
185
|
+
process.platform === "darwin" ? "-x" : "--strip-unneeded",
|
|
186
|
+
destination,
|
|
187
|
+
]);
|
|
188
|
+
await writeFile(
|
|
189
|
+
resolve(out, "build.json"),
|
|
190
|
+
JSON.stringify(
|
|
191
|
+
{
|
|
192
|
+
platform,
|
|
193
|
+
packages: await nativeNotices(artifacts, dirname(upstream)),
|
|
194
|
+
},
|
|
195
|
+
null,
|
|
196
|
+
2,
|
|
197
|
+
) + "\n",
|
|
198
|
+
);
|
|
199
|
+
console.log(`Built pinned Codex patch engine: ${destination}`);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
FROM ghcr.io/rust-cross/cargo-zigbuild@sha256:9b4f6b3eb9e8f9fefb3960fe288ddba576627d66d9eff851ce7f62d2455564a5 AS toolchain
|
|
2
|
+
RUN rustup toolchain install 1.98.1 --profile minimal && rustup target add --toolchain 1.98.1 aarch64-apple-darwin x86_64-apple-darwin
|
|
3
|
+
ENV RUSTUP_TOOLCHAIN=1.98.1
|
|
4
|
+
ENV MACOSX_DEPLOYMENT_TARGET=13.5
|
|
5
|
+
|
|
6
|
+
# Compile from the build context (this directory) and export only the result.
|
|
7
|
+
FROM toolchain AS build
|
|
8
|
+
COPY --from=node:24.20.0-trixie-slim@sha256:a747ad80c8a161b650d79a6da9c422005b91148b18b8d2c669eb5a0b7c07e600 /usr/local/bin/node /usr/local/bin/node
|
|
9
|
+
ARG TARGET=darwin-arm64
|
|
10
|
+
ARG CARGO_BUILD_JOBS=4
|
|
11
|
+
COPY . /source/
|
|
12
|
+
RUN node /source/compile.mjs --target "$TARGET" --out /out --scratch /scratch
|
|
13
|
+
|
|
14
|
+
FROM scratch
|
|
15
|
+
COPY --from=build /out/ /
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# Build arm64 against Ubuntu 22.04's glibc 2.35 from the pinned amd64 host.
|
|
2
|
+
FROM ubuntu:22.04@sha256:08ea48a03a3e78ebc7cd526e6a275053223aadd88bfc09cc49b06d5281525fde AS toolchain
|
|
3
|
+
RUN dpkg --add-architecture arm64 \
|
|
4
|
+
&& sed -i 's/^deb /deb [arch=amd64] /' /etc/apt/sources.list \
|
|
5
|
+
&& printf '%s\n' \
|
|
6
|
+
'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy main universe' \
|
|
7
|
+
'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy-updates main universe' \
|
|
8
|
+
'deb [arch=arm64] http://ports.ubuntu.com/ubuntu-ports jammy-security main universe' \
|
|
9
|
+
> /etc/apt/sources.list.d/arm64.list \
|
|
10
|
+
&& apt-get update && apt-get install -y --no-install-recommends \
|
|
11
|
+
build-essential gcc-aarch64-linux-gnu g++-aarch64-linux-gnu \
|
|
12
|
+
ca-certificates curl git pkg-config libssl-dev:arm64 qemu-user \
|
|
13
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
14
|
+
ENV RUSTUP_HOME=/opt/rustup CARGO_HOME=/opt/cargo
|
|
15
|
+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rustup.sh \
|
|
16
|
+
&& sh /tmp/rustup.sh -y --profile minimal --default-toolchain 1.98.1 \
|
|
17
|
+
&& /opt/cargo/bin/rustup target add --toolchain 1.98.1 aarch64-unknown-linux-gnu \
|
|
18
|
+
&& rm /tmp/rustup.sh \
|
|
19
|
+
&& chmod -R a+rX /opt/rustup /opt/cargo
|
|
20
|
+
ENV PATH=/opt/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
21
|
+
ENV RUSTUP_TOOLCHAIN=1.98.1
|
|
22
|
+
ENV CARGO_TARGET_AARCH64_UNKNOWN_LINUX_GNU_LINKER=aarch64-linux-gnu-gcc
|
|
23
|
+
ENV CC_aarch64_unknown_linux_gnu=aarch64-linux-gnu-gcc
|
|
24
|
+
ENV CXX_aarch64_unknown_linux_gnu=aarch64-linux-gnu-g++
|
|
25
|
+
ENV AR_aarch64_unknown_linux_gnu=aarch64-linux-gnu-ar
|
|
26
|
+
ENV PKG_CONFIG_ALLOW_CROSS=1
|
|
27
|
+
ENV PKG_CONFIG_LIBDIR=/usr/lib/aarch64-linux-gnu/pkgconfig:/usr/share/pkgconfig
|
|
28
|
+
|
|
29
|
+
# Compile from the build context (this directory) and export only the result.
|
|
30
|
+
FROM toolchain AS build
|
|
31
|
+
COPY --from=node:24.20.0-trixie-slim@sha256:a747ad80c8a161b650d79a6da9c422005b91148b18b8d2c669eb5a0b7c07e600 /usr/local/bin/node /usr/local/bin/node
|
|
32
|
+
ARG TARGET=linux-arm64
|
|
33
|
+
ARG CARGO_BUILD_JOBS=4
|
|
34
|
+
COPY . /source/
|
|
35
|
+
RUN node /source/compile.mjs --target "$TARGET" --out /out --scratch /scratch --require-glibc 2.35
|
|
36
|
+
|
|
37
|
+
FROM scratch
|
|
38
|
+
COPY --from=build /out/ /
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
# Ubuntu 22.04 amd64, jammy-20260924.1. Keep the libc floor at 2.35.
|
|
2
|
+
FROM ubuntu:22.04@sha256:08ea48a03a3e78ebc7cd526e6a275053223aadd88bfc09cc49b06d5281525fde AS toolchain
|
|
3
|
+
RUN apt-get update && apt-get install -y --no-install-recommends \
|
|
4
|
+
build-essential ca-certificates curl git pkg-config libssl-dev \
|
|
5
|
+
&& rm -rf /var/lib/apt/lists/*
|
|
6
|
+
ENV RUSTUP_HOME=/opt/rustup CARGO_HOME=/opt/cargo
|
|
7
|
+
RUN curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs -o /tmp/rustup.sh \
|
|
8
|
+
&& sh /tmp/rustup.sh -y --profile minimal --default-toolchain 1.98.1 \
|
|
9
|
+
&& rm /tmp/rustup.sh \
|
|
10
|
+
&& chmod -R a+rX /opt/rustup /opt/cargo
|
|
11
|
+
ENV PATH=/opt/cargo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
|
|
12
|
+
ENV RUSTUP_TOOLCHAIN=1.98.1
|
|
13
|
+
|
|
14
|
+
# Compile from the build context (this directory) and export only the result.
|
|
15
|
+
FROM toolchain AS build
|
|
16
|
+
COPY --from=node:24.20.0-trixie-slim@sha256:a747ad80c8a161b650d79a6da9c422005b91148b18b8d2c669eb5a0b7c07e600 /usr/local/bin/node /usr/local/bin/node
|
|
17
|
+
ARG TARGET=linux-x64
|
|
18
|
+
ARG CARGO_BUILD_JOBS=4
|
|
19
|
+
COPY . /source/
|
|
20
|
+
RUN node /source/compile.mjs --target "$TARGET" --out /out --scratch /scratch --require-glibc 2.35
|
|
21
|
+
|
|
22
|
+
FROM scratch
|
|
23
|
+
COPY --from=build /out/ /
|