diff --git a/pkgbuilds/opencode/PKGBUILD b/pkgbuilds/opencode/PKGBUILD new file mode 100644 index 0000000..25241a6 --- /dev/null +++ b/pkgbuilds/opencode/PKGBUILD @@ -0,0 +1,44 @@ +# Maintainer: dax +# Maintainer: adam + +pkgname='opencode' +pkgver=0.15.8 +options=('!debug' '!strip') +pkgrel=1 +pkgdesc='The AI coding agent built for the terminal.' +url='https://github.com/sst/opencode' +arch=('aarch64' 'x86_64') +license=('MIT') +provides=('opencode') +conflicts=('opencode-bin') +depends=('fzf' 'ripgrep') +makedepends=('git' 'bun-bin' 'go') + +source=("opencode-${pkgver}.tar.gz::https://github.com/sst/opencode/archive/v0.15.8.tar.gz") +sha256sums=('SKIP') + +build() { + cd "opencode-${pkgver}" + bun install + + # Fix for bun compile not finding platform-specific @parcel/watcher + # The compile step needs this to be explicitly installed + case "${CARCH}" in + x86_64) + bun add @parcel/watcher-linux-x64-glibc --optional + ;; + aarch64) + bun add @parcel/watcher-linux-arm64-glibc --optional + ;; + esac + + cd packages/tui + CGO_ENABLED=0 go build -ldflags="-s -w -X main.Version=${pkgver}" -o tui cmd/opencode/main.go + cd ../opencode + bun build --define OPENCODE_TUI_PATH="'$(realpath ../tui/tui)'" --define OPENCODE_VERSION="'${pkgver}'" --compile --target=bun-linux-x64 --outfile=opencode ./src/index.ts +} + +package() { + cd "opencode-${pkgver}/packages/opencode" + install -Dm755 ./opencode "${pkgdir}/usr/bin/opencode" +}