Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions .github/workflows/release-desktop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -390,6 +390,15 @@ jobs:
mkdir -p "$target_dir"
cp "native/resource-monitor/target/${{ inputs.rust_target }}/release/${binary_name}" "$target_dir/$binary_name"

- uses: ./.github/actions/setup-apt-mirrors
if: inputs.platform == 'linux'

# The Linux archive ships libatomic.so.1 and points t3's RUNPATH at it.
- name: Install patchelf
if: inputs.cli_archive && inputs.platform == 'linux'
shell: bash
run: command -v patchelf || { sudo apt-get update && sudo apt-get install -y patchelf; }

- name: Build CLI archive
if: inputs.cli_archive
shell: bash
Expand Down Expand Up @@ -433,9 +442,6 @@ jobs:
path: release-cli/*
if-no-files-found: error

- uses: ./.github/actions/setup-apt-mirrors
if: inputs.platform == 'linux'

- name: Install Linux desktop build libraries
if: inputs.platform == 'linux'
shell: bash
Expand Down
39 changes: 34 additions & 5 deletions scripts/build-cli-archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,32 @@ const stageWebClient = Effect.fn("stageWebClient")(function* (source: string, ta
}
});

/** Node links libatomic.so.1, which Ubuntu server and container images lack, so t3 carries its own. */
const bundleLinuxLibatomic = Effect.fn("bundleLinuxLibatomic")(function* (input: {
readonly contentDir: string;
readonly executablePath: string;
}) {
const fs = yield* FileSystem.FileSystem;
const path = yield* Path.Path;
const spawner = yield* ChildProcessSpawner.ChildProcessSpawner;
const ldd = yield* spawner.string(ChildProcess.make("ldd", [input.executablePath]));
const source = /libatomic\.so\.1 => (\/\S+)/.exec(ldd)?.[1];
if (source === undefined) {
return yield* new CliArchiveInputMissingError({
inputPath: "libatomic.so.1",
hint: `ldd did not resolve it for ${input.executablePath}. Install libatomic1 on the build host.`,
});
}
yield* fs.makeDirectory(path.join(input.contentDir, "lib"));
yield* fs.copyFile(source, path.join(input.contentDir, "lib/libatomic.so.1"));
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
// RUNPATH resolves through symlinks and is not inherited by child processes, unlike LD_LIBRARY_PATH.
yield* runCommand(
ChildProcess.make("patchelf", ["--set-rpath", "$ORIGIN/lib", input.executablePath]),
"patchelf --set-rpath",
);
yield* Effect.log(`[cli-archive] Bundled ${source} as lib/libatomic.so.1.`);
});

const MacSigningConfig = Config.all({
identity: Config.String("T3CODE_CLI_MAC_SIGN_IDENTITY").pipe(Config.option),
appleApiKey: Config.String("APPLE_API_KEY").pipe(Config.option),
Expand Down Expand Up @@ -444,11 +470,6 @@ const buildCliArchive = Effect.fn("buildCliArchive")(function* (input: {
builtExecutable,
`Run \`node apps/server/scripts/cli.ts build-exe${targetKey === hostKey ? "" : ` --target ${targetKey}`}\` first.`,
);
// TEMPORARY one-time Node fix. Remove when fixed: https://github.com/nodejs/node/issues/67048
if (input.platform === "linux" && input.arch === "arm64") {
const bytes = yield* fs.readFile(builtExecutable);
yield* Effect.try(() => assertLinuxArm64PageCompatibility(bytes));
}
yield* requireInput(path.join(webClient, "index.html"), "Run `vp run --filter t3 build` first.");
yield* requireInput(
resourceMonitorDir,
Expand All @@ -473,6 +494,14 @@ const buildCliArchive = Effect.fn("buildCliArchive")(function* (input: {
});

const executablePath = path.join(contentDir, executableName);
if (input.platform === "linux") {
yield* bundleLinuxLibatomic({ contentDir, executablePath });
}
// TEMPORARY one-time Node fix. Remove when fixed: https://github.com/nodejs/node/issues/67048
if (input.platform === "linux" && input.arch === "arm64") {
const bytes = yield* fs.readFile(executablePath);
yield* Effect.try(() => assertLinuxArm64PageCompatibility(bytes));
}
if (input.platform === "mac") {
yield* signMacArchiveContents({ repoRoot, contentDir, executablePath });
} else if (input.platform === "win") {
Expand Down
12 changes: 12 additions & 0 deletions scripts/smoke-cli-archive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,18 @@ const smokeCliArchive = Effect.fn("smokeCliArchive")(function* (input: {
}
}

// The runner has libatomic installed; fresh Ubuntu servers do not.
if (platform === "linux") {
const ldd = yield* spawner.string(ChildProcess.make("ldd", [executable]));
const bundled = path.join(yield* fs.realPath(contentDir), "lib/libatomic.so.1");
if (!ldd.includes(`libatomic.so.1 => ${bundled} `)) {
return yield* new CliArchiveSmokeError({
step: "checking that t3 loads the bundled libatomic",
detail: ldd,
});
}
}

const version = yield* runExecutable(executable, ["--version"], contentDir);
if (version.exitCode !== 0 || !version.stdout.includes(input.expectVersion)) {
return yield* new CliArchiveSmokeError({
Expand Down
Loading