summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.gitignore3
-rw-r--r--opencode.spec131
-rw-r--r--sources5
3 files changed, 92 insertions, 47 deletions
diff --git a/.gitignore b/.gitignore
index 907855a..438155a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,2 +1,5 @@
/models-api.json.xz
/opencode-1.19.5.tar.gz
+/bun-linux-x64-1.4.4.tgz
+/node-v24.18.0-linux-x64.tar.xz
+/opencode-node_modules.tar.xz
diff --git a/opencode.spec b/opencode.spec
index 2fc675a..9556fb7 100644
--- a/opencode.spec
+++ b/opencode.spec
@@ -1,10 +1,13 @@
-# Source build of opencode 1.19.5 for openEuler 24.03 LTS SP4.
+# Source build of opencode 1.19.5 for openEuler 24.03 LTS SP4 (x86_64).
#
-# The EUR upload endpoint rejects SRPMs of a few MB, so this SRPM is kept tiny:
-# the upstream source archive is fetched in %prep from a reachable GitHub proxy,
-# Node.js and Bun come from Huawei Cloud mirrors, and the npm dependency tree
-# is resolved from the Huawei npm mirror. The models.dev snapshot is small
-# enough to ship compressed in the SRPM.
+# The EUR upload endpoint rejects SRPMs of a few MB, so the EUR reference spec
+# fetched the upstream archive in %prep from a GitHub proxy and downloaded
+# Node.js/Bun from Huawei Cloud mirrors. This COPR project has network access
+# disabled inside the build chroot (enable_net=False), which makes every
+# build-time download fail with "Could not resolve host" (build 114080 aborted
+# in %prep). This spec therefore ships every build input inside the SRPM:
+# Source0 = upstream archive, Source1 = models.dev snapshot, Source2 = Node.js,
+# Source3 = Bun, Source4 = the resolved node_modules tree.
#
# The upstream source is pruned to the CLI + embedded Web UI workspace closure
# (console/stats/desktop/docs/web/storybook/slack/identity/containers/cli/
@@ -24,14 +27,21 @@
Name: opencode
Version: 1.19.5
-Release: 2%{?dist}
+Release: 3%{?dist}
Summary: The open source coding agent
License: MIT
URL: https://github.com/anomalyco/opencode
-# Source0 is a zero-byte placeholder; %prep fetches the real archive.
+# Source0 carries the upstream tarball (opencode-1.19.5/ top-level dir).
Source0: opencode-1.19.5.tar.gz
Source1: models-api.json.xz
+# The build chroot has no network access (project enable_net=False), so the
+# remaining build inputs are shipped in the SRPM as well:
+# Source2 = Node.js 24.18.0 x86_64, Source3 = Bun 1.4.4 x86_64 npm package,
+# Source4 = the node_modules tree for the pruned workspace closure.
+Source2: node-v%{node_version}-linux-x64.tar.xz
+Source3: bun-linux-x64-%{bun_version}.tgz
+Source4: opencode-node_modules.tar.xz
ExclusiveArch: x86_64
BuildRequires: bash
@@ -66,21 +76,31 @@ Node.js and Bun are not needed after installation.
%prep
cd %{_builddir}
+# The upstream archive ships inside the SRPM as Source0, so %prep needs no
+# network access; the GitHub proxies remain only as a fallback.
src_ok=0
-for url in \
- "%{src_proxy}" \
- "https://gh.llkk.cc/https://github.com/anomalyco/opencode/archive/refs/tags/v1.19.5.tar.gz" \
- "https://gh-proxy.com/https://github.com/anomalyco/opencode/archive/refs/tags/v1.19.5.tar.gz"; do
- echo "Fetching source from ${url}"
- if curl --fail --location --retry 2 --connect-timeout 30 --max-time 900 \
- --output src.tar.gz "${url}"; then
- if tar -tzf src.tar.gz 2>/dev/null | head -1 | grep -q '^opencode-1.19.5/'; then
- src_ok=1
- break
+if [ -s "%{SOURCE0}" ] && \
+ tar -tzf "%{SOURCE0}" 2>/dev/null | grep -q '^opencode-1.19.5/'; then
+ echo "Using source archive shipped in the SRPM: %{SOURCE0}"
+ cp -f "%{SOURCE0}" src.tar.gz
+ src_ok=1
+fi
+if [ "${src_ok}" != "1" ]; then
+ for url in \
+ "%{src_proxy}" \
+ "https://gh.llkk.cc/https://github.com/anomalyco/opencode/archive/refs/tags/v1.19.5.tar.gz" \
+ "https://gh-proxy.com/https://github.com/anomalyco/opencode/archive/refs/tags/v1.19.5.tar.gz"; do
+ echo "Fetching source from ${url}"
+ if curl --fail --location --retry 2 --connect-timeout 30 --max-time 900 \
+ --output src.tar.gz "${url}"; then
+ if tar -tzf src.tar.gz 2>/dev/null | grep -q '^opencode-1.19.5/'; then
+ src_ok=1
+ break
+ fi
fi
- fi
- rm -f src.tar.gz
-done
+ rm -f src.tar.gz
+ done
+fi
if [ "${src_ok}" != "1" ]; then
echo "ERROR: no source mirror was reachable" >&2
exit 1
@@ -88,6 +108,10 @@ fi
tar -xzf src.tar.gz
cd opencode-1.19.5
+# The in-SRPM archive is re-packed from the upstream git clone; drop any VCS
+# metadata so the build tree matches the upstream tag archive layout.
+rm -rf .git
+
# Keep only the CLI + embedded-Web-UI workspace closure.
rm -rf packages/console packages/stats packages/enterprise packages/desktop \
packages/docs packages/web packages/storybook packages/slack \
@@ -102,6 +126,14 @@ rm -rf packages/*/test packages/*/tests packages/*/e2e packages/*/test-browser \
packages/*/*/README* sdks github nix infra specs .github README* \
AGENTS.md CONTRIBUTING.md STATS.md CONTEXT.md perf screenshot-*.png
+# packages/script (@opencode-ai/script) reads .github/TEAM_MEMBERS at module
+# load time (top-level await), so the pruning above must leave that file in
+# place; otherwise `bun run script/build.ts` fails with ENOENT. Only release
+# tooling consumes the team list, so a stub is enough for the build.
+mkdir -p .github
+printf '# build stub: team list is only used by upstream release tooling\n' \
+ > .github/TEAM_MEMBERS
+
python3 - <<'PY'
import json
import os
@@ -130,38 +162,30 @@ cd opencode-1.19.5
export HOME="%{_builddir}/%{name}-%{version}/.home"
mkdir -p "$HOME"
-# Node.js 24.18.0
-curl --fail --location --retry 3 --connect-timeout 30 \
- --output node.tar.xz \
- "https://mirrors.huaweicloud.com/nodejs/v%{node_version}/node-v%{node_version}-linux-x64.tar.xz"
-echo '%{node_sha256} node.tar.xz' | sha256sum -c -
+# Nothing is downloaded here: the build chroot has no network access, so
+# Node.js, Bun and the npm dependency tree are all shipped in the SRPM
+# (Source2/Source3/Source4).
+echo '%{node_sha256} %{SOURCE2}' | sha256sum -c -
mkdir -p "$HOME/node"
-tar -xJf node.tar.xz -C "$HOME/node" --strip-components=1
+tar -xJf %{SOURCE2} -C "$HOME/node" --strip-components=1
export PATH="$HOME/node/bin:$PATH"
node --version
npm --version
-# Bun 1.4.4 from the npm platform package
-curl --fail --location --retry 3 --connect-timeout 30 \
- --output bun.tgz \
- "https://mirrors.huaweicloud.com/repository/npm/@oven/bun-linux-x64/-/bun-linux-x64-%{bun_version}.tgz"
-echo '%{bun_sha256} bun.tgz' | sha256sum -c -
+echo '%{bun_sha256} %{SOURCE3}' | sha256sum -c -
mkdir -p "$HOME/bun"
-tar -xzf bun.tgz -C "$HOME/bun" --strip-components=1
+tar -xzf %{SOURCE3} -C "$HOME/bun" --strip-components=1
export PATH="$HOME/bun/bin:$PATH"
bun --version
-export npm_config_registry="https://mirrors.huaweicloud.com/repository/npm/"
-export NPM_CONFIG_REGISTRY="$npm_config_registry"
-export BUN_CONFIG_REGISTRY="$npm_config_registry"
-export npm_config_prefix="$HOME/npm-global"
-export NPM_CONFIG_PREFIX="$npm_config_prefix"
-mkdir -p "$npm_config_prefix"
-export PATH="$npm_config_prefix/bin:$PATH"
-npm install -g node-gyp
-node-gyp --version
-
-export BUN_INSTALL_CACHE_DIR="$HOME/bun-cache"
+# Vendored npm dependency tree (Source4) replaces `bun install`.
+tar -xJf %{SOURCE4} -C .
+test -d node_modules/.bun
+
+# The embedded Web UI is built with vite, which does not fit in Node's default
+# 1 GB heap for this module graph.
+export NODE_OPTIONS="--max-old-space-size=4096"
+
export BUN_CONFIG_DISABLE_ANALYTICS=1
export MODELS_DEV_API_JSON="$PWD/models-api.json"
export OPENCODE_VERSION="%{version}"
@@ -169,10 +193,15 @@ export OPENCODE_CHANNEL="prod"
export USE_HARD_LINKS=false
export HUSKY=0
-bun install
+# node-pty's spawn-helper needs the executable bit; the vendored tree already
+# has it, this keeps the step harmless/idempotent.
bun run --cwd packages/core fix-node-pty || :
cd packages/opencode
-bun run script/build.ts --single
+# --skip-install keeps the build offline: the dependency tree is already in
+# place (Source4) and the flag also suppresses the extra cross-platform
+# `bun install --os="*"` calls the script issues, which we do not need for a
+# single linux-x64 target.
+bun run script/build.ts --single --skip-install
%install
cd opencode-1.19.5
@@ -187,6 +216,16 @@ install -Dpm 0644 LICENSE %{buildroot}%{_licensedir}/%{name}/LICENSE
%{_bindir}/opencode
%changelog
+* Mon Nov 02 2026 user_76c6f026 <user_76c6f026@eur.openeuler.cn> - 1.19.5-3
+- Build fully offline: this COPR project has network access disabled
+ (enable_net=False), which made the %prep GitHub-proxy fetch fail with
+ "Could not resolve host" (build 114080)
+- Ship the upstream archive (Source0), Node.js 24.18.0 (Source2), Bun 1.4.4
+ (Source3) and the resolved node_modules tree (Source4) inside the SRPM
+- Replace the build-time downloads and `bun install` with the in-SRPM inputs
+ and build with `--skip-install` so no registry access is attempted
+- Raise Node's heap for the embedded Web UI build (NODE_OPTIONS)
+
* Thu Oct 29 2026 user_76c6f026 <user_76c6f026@eur.openeuler.cn> - 1.19.5-2
- Build opencode 1.19.5 from source for openEuler 24.03 LTS SP4 x86_64
- Fetch upstream source from a GitHub proxy at build time; use Huawei Cloud
diff --git a/sources b/sources
index 28cf6cc..e5a533d 100644
--- a/sources
+++ b/sources
@@ -1,2 +1,5 @@
+6856d42e2008c97cc698518e18156d77 bun-linux-x64-1.4.4.tgz
208cee0297d06b2172933cc3952080b0 models-api.json.xz
-d41d8cd98f00b204e9800998ecf8427e opencode-1.19.5.tar.gz
+1c611b02dae6d3f3bcb1f3e64bd9f3bf node-v24.18.0-linux-x64.tar.xz
+35e87c45a9585d250e7c286bb8e219db opencode-1.19.5.tar.gz
+7fc618352ca9b51a9348acb1066c4ed6 opencode-node_modules.tar.xz