diff --git a/dev-util/codex/Manifest b/dev-util/codex/Manifest index 3366dee40a..73154e0b17 100644 --- a/dev-util/codex/Manifest +++ b/dev-util/codex/Manifest @@ -1,5 +1,7 @@ DIST codex-0.130.0.tar.gz 7565974 BLAKE2B 077be63eaeacc94cafb3505c01f90b78947fce878be80bd040b466c0b81374d721856cab6454a66adef2c8f3790cb9aaa5ea0d6d9451c7b44ae5e93427998cc2 SHA512 9e0cdb6581af7e7b2f1aa01536cfe89956ed804927df5341c60042bea7cd6c6a6c613c15e5d9315e70c04fde5a41d3ca96ad542463f7fa39b430913ce0e0bc2c +DIST codex-0.131.0.tar.gz 7936381 BLAKE2B 61a4a87ad506b5cdb2707e2951c1867b79780c2a14cbcf5bc88cad6ec8839191086c1c27fbffac07689b057e1b704c7d61282dd21fde2f2a30df1e9bffd4cb5c SHA512 42042c2557fdf660345a535dfc86389211bf23321876740e187e4db4b260d89018d655c193d346478b85900fd770caa47f09ba95d264249d8f33112475b53f62 DIST codex-rust-v0.130.0-crates.tar.xz 117146536 BLAKE2B 5033eb2cb00345b6f9c1faba7636c38990029a1e7b4e5b0c5f61a4dd5fa468a9729ed06d7438a4f696f4ace839673f9ba784d30a4052625c4e7ba81717d29376 SHA512 cd72031f5b870dd214f485f97b1f07d0853e6172965be530a6240ffe61322a332e8afc135ede957432fea14f68ea6ab8d389c92ea4cfa150050225bebb1fc702 +DIST codex-rust-v0.131.0-crates.tar.xz 117131216 BLAKE2B c227b8213f71f0736b18d877c7942ee73086ffc48801fd5bcd58979409dd5af0e787785de6260dddb96ecf31d5bd34526b84636b1992e8bef2e18390e445e969 SHA512 c6035bc756d6821e30cecf6841193aab119399117da0e9f68d777117f0a4b6fb9a5adb191356a616a431c5e8516c8e194fee7c632f409e18c7634bceba550c2b DIST crossterm-87db8bfa6dc99427fd3b071681b07fc31c6ce995.gh.tar.gz 129254 BLAKE2B 414dacc3a682c7a6dc5c9e43f185966255205d18f0522ee7eae73b5f113b4c3ea9b132e6dee81783d4ce160e4bf95aab784cf3601d666265bef4f889d5e46e68 SHA512 9dc7247d081a25d18776c9c0fd7fe3373f372950728b7fcf5ff43aaa6f7d69f11e1dbd91f92991cbe73007eb9e78c9a901b2388c27ddd6898553fdcef7fdaf44 DIST nucleo-4253de9faabb4e5c6d81d946a5e35a90f87347ee.gh.tar.gz 86782 BLAKE2B a812a2d2f08df818ac7b13b800f51c4229ea1f968668b1224fbc1fd82fb4e045f6b2c536ec6d2647a579097efbddaf041f4b7b356107679156aaa3ca5a9d4068 SHA512 354061278efce55defb30b9ee2ef5cdab745ab56d7d113f6f47a8ac174b4215ec6efe15c15bef0e3d907350182c0d189071e9d7d17d40e807d4db5361682f4e0 DIST ratatui-9b2ad1298408c45918ee9f8241a6f95498cdbed2.gh.tar.gz 566574 BLAKE2B 97f09fda6a798afb00067debab30b89d35aa00bfd284d2ef95fd6176aaa680121a8eee9b8dbe605e6230a6e72ead7b5d4e57ddf4892bcfe93f2fcbbafaba88d2 SHA512 b2ab8bcf19cfd649b8fbbc6752b628f69e79b09e8f8258ea9112ce4348dee512d9e718b5310fc73de65239b51b2b1b593942974f9698bd080616ab389093f4ef diff --git a/dev-util/codex/codex-0.131.0.ebuild b/dev-util/codex/codex-0.131.0.ebuild new file mode 100644 index 0000000000..3d33273a85 --- /dev/null +++ b/dev-util/codex/codex-0.131.0.ebuild @@ -0,0 +1,151 @@ +# Copyright 2025-2026 Gentoo Authors +# Distributed under the terms of the GNU General Public License v2 + +EAPI=8 + +# NOTE: This package uses a pre-built crate tarball instead of listing individual +# crates in CRATES="". This approach is required because: +# 1. Codex has 800+ crate dependencies, which triggers Portage QA warnings: +# "QA Notice: This package uses a very large number of CRATES. Please provide +# a crate tarball instead and fetch it via SRC_URI." +# 2. Stricter ebuild QA checks (e.g., in CI pipelines) fail with too many crates. +# +# The crate tarball is auto-generated by GitHub Actions at: +# https://github.com/gentoo-zh-drafts/codex/ +# Workflow source code for auditing: +# https://github.com/gentoo-zh-drafts/codex/blob/crate-dist/.github/workflows/crates.yml +# This allows anyone to review and verify the crate packaging process. + +CRATES=" +" + +declare -A GIT_CRATES=( + [crossterm]='https://github.com/nornagon/crossterm;87db8bfa6dc99427fd3b071681b07fc31c6ce995;crossterm-%commit%' + [libwebrtc]='https://github.com/juberti-oai/rust-sdks;e2d1d1d230c6fc9df171ccb181423f957bb3c1f0;rust-sdks-%commit%/libwebrtc' + [livekit-protocol]='https://github.com/juberti-oai/rust-sdks;e2d1d1d230c6fc9df171ccb181423f957bb3c1f0;rust-sdks-%commit%/livekit-protocol' + [livekit-runtime]='https://github.com/juberti-oai/rust-sdks;e2d1d1d230c6fc9df171ccb181423f957bb3c1f0;rust-sdks-%commit%/livekit-runtime' + [nucleo-matcher]='https://github.com/helix-editor/nucleo;4253de9faabb4e5c6d81d946a5e35a90f87347ee;nucleo-%commit%/matcher' + [nucleo]='https://github.com/helix-editor/nucleo;4253de9faabb4e5c6d81d946a5e35a90f87347ee;nucleo-%commit%' + [ratatui]='https://github.com/nornagon/ratatui;9b2ad1298408c45918ee9f8241a6f95498cdbed2;ratatui-%commit%' + [runfiles]='https://github.com/dzbarsky/rules_rust;b56cbaa8465e74127f1ea216f813cd377295ad81;rules_rust-%commit%/rust/runfiles' + [tokio-tungstenite]='https://github.com/openai-oss-forks/tokio-tungstenite;132f5b39c862e3a970f731d709608b3e6276d5f6;tokio-tungstenite-%commit%' + [tungstenite]='https://github.com/openai-oss-forks/tungstenite-rs;9200079d3b54a1ff51072e24d81fd354f085156f;tungstenite-rs-%commit%' + [webrtc-sys-build]='https://github.com/juberti-oai/rust-sdks;e2d1d1d230c6fc9df171ccb181423f957bb3c1f0;rust-sdks-%commit%/webrtc-sys/build' + [webrtc-sys]='https://github.com/juberti-oai/rust-sdks;e2d1d1d230c6fc9df171ccb181423f957bb3c1f0;rust-sdks-%commit%/webrtc-sys' +) + +RUST_MIN_VER="1.93.0" + +# python3 .github/scripts/rusty_v8_bazel.py resolved-v8-crate-version +RUSTY_V8_TAG="146.4.0" + +inherit cargo check-reqs toolchain-funcs + +CHECKREQS_MEMORY="16G" +CHECKREQS_DISK_BUILD="20G" + +DESCRIPTION="Codex CLI - OpenAI's AI-powered coding agent" +HOMEPAGE="https://github.com/openai/codex" + +# The crate tarball URL uses ${PV} so it auto-updates when bumping versions. +# This tarball is generated by: https://github.com/gentoo-zh-drafts/codex/ +# See .github/workflows/crates.yml for the generation process. +SRC_URI=" + https://github.com/openai/${PN}/archive/rust-v${PV}.tar.gz -> ${P}.tar.gz + https://github.com/gentoo-zh-drafts/codex/releases/download/rust-v${PV}/codex-rust-v${PV}-crates.tar.xz + amd64? ( + https://github.com/openai/codex/releases/download/rusty-v8-v${RUSTY_V8_TAG}/librusty_v8_release_x86_64-unknown-linux-musl.a.gz + -> rusty_v8_${RUSTY_V8_TAG}_librusty_v8_release_x86_64-unknown-linux-musl.a.gz + https://github.com/openai/codex/releases/download/rusty-v8-v${RUSTY_V8_TAG}/src_binding_release_x86_64-unknown-linux-musl.rs + -> rusty_v8_${RUSTY_V8_TAG}_src_binding_release_x86_64-unknown-linux-musl.rs + ) + arm64? ( + https://github.com/openai/codex/releases/download/rusty-v8-v${RUSTY_V8_TAG}/librusty_v8_release_aarch64-unknown-linux-musl.a.gz + -> rusty_v8_${RUSTY_V8_TAG}_librusty_v8_release_aarch64-unknown-linux-musl.a.gz + https://github.com/openai/codex/releases/download/rusty-v8-v${RUSTY_V8_TAG}/src_binding_release_aarch64-unknown-linux-musl.rs + -> rusty_v8_${RUSTY_V8_TAG}_src_binding_release_aarch64-unknown-linux-musl.rs + ) + ${CARGO_CRATE_URIS} +" + +S="${WORKDIR}/${PN}-rust-v${PV}/codex-rs" + +LICENSE="Apache-2.0" +# Dependent crate licenses +LICENSE+=" + Apache-2.0 Apache-2.0-with-LLVM-exceptions BSD-2 BSD Boost-1.0 + CC0-1.0 CDLA-Permissive-2.0 ISC MIT MPL-2.0 Unicode-3.0 ZLIB +" +SLOT="0" +KEYWORDS="-* ~amd64 ~arm64" +# Tests fail due to ring crate conflicts with system OpenSSL +RESTRICT="test" + +DEPEND=" + dev-libs/openssl:= + sys-apps/dbus +" +RDEPEND="${DEPEND}" +BDEPEND="virtual/pkgconfig" + +# rust does not use *FLAGS from make.conf, silence portage warning +QA_FLAGS_IGNORED="usr/bin/${PN}" + +pkg_pretend() { + check-reqs_pkg_pretend +} + +pkg_setup() { + check-reqs_pkg_setup + rust_pkg_setup + if tc-is-lto; then + export CARGO_PROFILE_RELEASE_LTO=thin + else + export CARGO_PROFILE_RELEASE_LTO=false + fi +} + +gen_git_crate_dir() { + # https://github.com/gentoo/gentoo/blob/b09dd88412fe2d5eee5a8891e08bfa2d67848da3/eclass/cargo.eclass#L442 + IFS=';' read -r crate_uri commit crate_dir <<<"${GIT_CRATES[$1]}" + echo "${WORKDIR}/${crate_dir//%commit%/${commit}}" +} + +src_prepare() { + default + + # Fix tokio-tungstenite's git dependency on tungstenite + sed -i '/^\[dependencies\.tungstenite\]/,/^$/{ + s|git = "https://github.com/openai-oss-forks/tungstenite-rs"|path = "'"$(gen_git_crate_dir tungstenite)"'"| + /^rev = /d + }' "$(gen_git_crate_dir tokio-tungstenite)/Cargo.toml" || die + + # Remove the [patch.crates-io] section and add path-based patches + sed -i '/^\[patch\.crates-io\]/,/^$/d' "${S}/Cargo.toml" || die + sed -i '/^\[patch\."ssh:\/\/git@github\.com/,/^$/d' "${S}/Cargo.toml" || die + + # Add new patch section with local paths + cat >> "${S}/Cargo.toml" <<-EOF || die + + [patch.crates-io] + crossterm = { path = "$(gen_git_crate_dir crossterm)" } + ratatui = { path = "$(gen_git_crate_dir ratatui)" } + tokio-tungstenite = { path = "$(gen_git_crate_dir tokio-tungstenite)" } + tungstenite = { path = "$(gen_git_crate_dir tungstenite)" } + EOF +} + +src_compile() { + local rusty_v8_triple + use amd64 && rusty_v8_triple=x86_64-unknown-linux-musl + use arm64 && rusty_v8_triple=aarch64-unknown-linux-musl + + RUSTY_V8_ARCHIVE="${DISTDIR}/rusty_v8_${RUSTY_V8_TAG}_librusty_v8_release_${rusty_v8_triple}.a.gz" \ + RUSTY_V8_SRC_BINDING_PATH="${DISTDIR}/rusty_v8_${RUSTY_V8_TAG}_src_binding_release_${rusty_v8_triple}.rs" \ + cargo_src_compile --package codex-cli +} + +src_install() { + dobin "$(cargo_target_dir)/codex" + einstalldocs +}