Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
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
53 changes: 53 additions & 0 deletions devel/opencode/Portfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# -*- coding: utf-8; mode: tcl; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- vim:fenc=utf-8:ft=tcl:et:sw=4:ts=4:sts=4

PortSystem 1.0
PortGroup github 1.0

github.setup sst opencode 1.0.141 v

revision 0
categories devel
license MIT
maintainers @diogom93 openmaintainer

description Terminal AI coding agent
long_description OpenCode is an open-source AI coding agent \
built for the terminal, with a native TUI, \
provider-agnostic model support and strong \
integration with modern developer workflows.

homepage https://opencode.ai/

supported_archs arm64 x86_64

github.tarball_from archive
fetch.type git
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Without cloning the repo, it would throw an error during build:

"fatal: not a git repository (or any of the parent directories): .git\n"


depends_build port:bun

patchfiles bun-version.diff

checksums rmd160 ac2eaa72e680d7c433688c601d3fcd3d5ed8261a \
sha256 84c04fba88e2be8b0bba2f2cd05d96f76d3891ead1603646eecbfc627d75f4d4 \
size 48587896

if {${build_arch} eq "x86_64"} {
set arch "x64"
} elseif {${build_arch} eq "arm64"} {
set arch "arm64"
}

configure.cmd bun
configure.args install
configure.pre_args

build.dir ${worksrcpath}/packages/opencode/scripts
build.cmd bun
build.env OPENCODE_VERSION=${version}
build.args run build --single
build.target

destroot {
xinstall -d ${destroot}${prefix}/bin
xinstall -m 755 ${worksrcpath}/packages/opencode/dist/opencode-darwin-${arch}/bin/opencode ${destroot}${prefix}/bin/
}
20 changes: 20 additions & 0 deletions devel/opencode/files/bun-version.diff
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Applying a patch to the script that checks the bun version to allow builds with same minor version

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--- packages/script/src/index.ts.orig 2025-12-09 15:36:24
+++ packages/script/src/index.ts 2025-12-09 15:39:57
@@ -5,12 +5,15 @@
const rootPkg = await Bun.file(rootPkgPath).json()
const expectedBunVersion = rootPkg.packageManager?.split("@")[1]

+const [expectedMajor, expectedMinor] = expectedBunVersion.split(".")
+const [actualMajor, actualMinor] = process.versions.bun.split(".")
+
if (!expectedBunVersion) {
throw new Error("packageManager field not found in root package.json")
}

-if (process.versions.bun !== expectedBunVersion) {
- throw new Error(`This script requires bun@${expectedBunVersion}, but you are using bun@${process.versions.bun}`)
+if (expectedMajor !== actualMajor || expectedMinor !== actualMinor) {
+ throw new Error(`This script requires bun ~${expectedBunVersion}, but you are using bun@${process.versions.bun}`)
}

const CHANNEL = process.env["OPENCODE_CHANNEL"] ?? (await $`git branch --show-current`.text().then((x) => x.trim()))