2025-05-12 13:38:10 -07:00
|
|
|
|
#!/usr/bin/env bash
|
2025-05-01 08:36:07 -07:00
|
|
|
|
|
2025-05-12 13:38:10 -07:00
|
|
|
|
# Install native runtime dependencies for codex-cli.
|
2025-05-01 08:36:07 -07:00
|
|
|
|
#
|
2025-05-12 13:38:10 -07:00
|
|
|
|
# By default the script copies the sandbox binaries that are required at
|
|
|
|
|
|
# runtime. When called with the --full-native flag, it additionally
|
|
|
|
|
|
# bundles pre-built Rust CLI binaries so that the resulting npm package can run
|
|
|
|
|
|
# the native implementation when users set CODEX_RUST=1.
|
2025-05-01 08:36:07 -07:00
|
|
|
|
#
|
2025-05-12 13:38:10 -07:00
|
|
|
|
# Usage
|
|
|
|
|
|
# install_native_deps.sh [RELEASE_ROOT] [--full-native]
|
2025-05-01 08:36:07 -07:00
|
|
|
|
#
|
2025-05-12 13:38:10 -07:00
|
|
|
|
# The optional RELEASE_ROOT is the path that contains package.json. Omitting
|
|
|
|
|
|
# it installs the binaries into the repository's own bin/ folder to support
|
|
|
|
|
|
# local development.
|
2025-05-01 08:36:07 -07:00
|
|
|
|
|
|
|
|
|
|
set -euo pipefail
|
|
|
|
|
|
|
2025-05-12 13:38:10 -07:00
|
|
|
|
# ------------------
|
|
|
|
|
|
# Parse arguments
|
|
|
|
|
|
# ------------------
|
|
|
|
|
|
|
|
|
|
|
|
DEST_DIR=""
|
|
|
|
|
|
INCLUDE_RUST=0
|
|
|
|
|
|
|
|
|
|
|
|
for arg in "$@"; do
|
|
|
|
|
|
case "$arg" in
|
|
|
|
|
|
--full-native)
|
|
|
|
|
|
INCLUDE_RUST=1
|
|
|
|
|
|
;;
|
|
|
|
|
|
*)
|
|
|
|
|
|
if [[ -z "$DEST_DIR" ]]; then
|
|
|
|
|
|
DEST_DIR="$arg"
|
|
|
|
|
|
else
|
|
|
|
|
|
echo "Unexpected argument: $arg" >&2
|
|
|
|
|
|
exit 1
|
|
|
|
|
|
fi
|
|
|
|
|
|
;;
|
|
|
|
|
|
esac
|
|
|
|
|
|
done
|
|
|
|
|
|
|
2025-05-01 08:36:07 -07:00
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
# Determine where the binaries should be installed.
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
if [[ $# -gt 0 ]]; then
|
|
|
|
|
|
# The caller supplied a release root directory.
|
|
|
|
|
|
CODEX_CLI_ROOT="$1"
|
|
|
|
|
|
BIN_DIR="$CODEX_CLI_ROOT/bin"
|
|
|
|
|
|
else
|
|
|
|
|
|
# No argument; fall back to the repo’s own bin directory.
|
|
|
|
|
|
# Resolve the path of this script, then walk up to the repo root.
|
|
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
|
|
|
|
CODEX_CLI_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
|
|
|
|
|
BIN_DIR="$CODEX_CLI_ROOT/bin"
|
|
|
|
|
|
fi
|
|
|
|
|
|
|
|
|
|
|
|
# Make sure the destination directory exists.
|
|
|
|
|
|
mkdir -p "$BIN_DIR"
|
|
|
|
|
|
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
# Download and decompress the artifacts from the GitHub Actions workflow.
|
|
|
|
|
|
# ----------------------------------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
# Until we start publishing stable GitHub releases, we have to grab the binaries
|
|
|
|
|
|
# from the GitHub Action that created them. Update the URL below to point to the
|
|
|
|
|
|
# appropriate workflow run:
|
2025-06-05 23:14:10 -07:00
|
|
|
|
WORKFLOW_URL="https://github.com/openai/codex/actions/runs/15483730027"
|
2025-05-01 08:36:07 -07:00
|
|
|
|
WORKFLOW_ID="${WORKFLOW_URL##*/}"
|
|
|
|
|
|
|
|
|
|
|
|
ARTIFACTS_DIR="$(mktemp -d)"
|
|
|
|
|
|
trap 'rm -rf "$ARTIFACTS_DIR"' EXIT
|
|
|
|
|
|
|
|
|
|
|
|
# NB: The GitHub CLI `gh` must be installed and authenticated.
|
|
|
|
|
|
gh run download --dir "$ARTIFACTS_DIR" --repo openai/codex "$WORKFLOW_ID"
|
|
|
|
|
|
|
2025-05-12 13:38:10 -07:00
|
|
|
|
# Decompress the artifacts for Linux sandboxing.
|
2025-05-01 08:36:07 -07:00
|
|
|
|
zstd -d "$ARTIFACTS_DIR/x86_64-unknown-linux-musl/codex-linux-sandbox-x86_64-unknown-linux-musl.zst" \
|
|
|
|
|
|
-o "$BIN_DIR/codex-linux-sandbox-x64"
|
|
|
|
|
|
|
2025-06-05 22:45:45 -07:00
|
|
|
|
zstd -d "$ARTIFACTS_DIR/aarch64-unknown-linux-musl/codex-linux-sandbox-aarch64-unknown-linux-musl.zst" \
|
2025-05-01 08:36:07 -07:00
|
|
|
|
-o "$BIN_DIR/codex-linux-sandbox-arm64"
|
|
|
|
|
|
|
2025-05-12 13:38:10 -07:00
|
|
|
|
if [[ "$INCLUDE_RUST" -eq 1 ]]; then
|
|
|
|
|
|
# x64 Linux
|
|
|
|
|
|
zstd -d "$ARTIFACTS_DIR/x86_64-unknown-linux-musl/codex-x86_64-unknown-linux-musl.zst" \
|
|
|
|
|
|
-o "$BIN_DIR/codex-x86_64-unknown-linux-musl"
|
|
|
|
|
|
# ARM64 Linux
|
2025-06-05 22:45:45 -07:00
|
|
|
|
zstd -d "$ARTIFACTS_DIR/aarch64-unknown-linux-musl/codex-aarch64-unknown-linux-musl.zst" \
|
|
|
|
|
|
-o "$BIN_DIR/codex-aarch64-unknown-linux-musl"
|
2025-05-12 13:38:10 -07:00
|
|
|
|
# x64 macOS
|
|
|
|
|
|
zstd -d "$ARTIFACTS_DIR/x86_64-apple-darwin/codex-x86_64-apple-darwin.zst" \
|
|
|
|
|
|
-o "$BIN_DIR/codex-x86_64-apple-darwin"
|
|
|
|
|
|
# ARM64 macOS
|
|
|
|
|
|
zstd -d "$ARTIFACTS_DIR/aarch64-apple-darwin/codex-aarch64-apple-darwin.zst" \
|
|
|
|
|
|
-o "$BIN_DIR/codex-aarch64-apple-darwin"
|
|
|
|
|
|
fi
|
2025-05-01 08:36:07 -07:00
|
|
|
|
|
2025-05-12 13:38:10 -07:00
|
|
|
|
echo "Installed native dependencies into $BIN_DIR"
|