diff --git a/pkgbuilds/opencode/PKGBUILD b/pkgbuilds/opencode/PKGBUILD index 7df4368..ef31afd 100644 --- a/pkgbuilds/opencode/PKGBUILD +++ b/pkgbuilds/opencode/PKGBUILD @@ -13,19 +13,41 @@ license=('MIT') provides=('opencode') conflicts=('opencode-bin') depends=('fzf' 'ripgrep') -makedepends=('git' 'bun-bin' 'go') +makedepends=('git' 'bun-bin' 'go' 'npm') source=("opencode-${pkgver}.tar.gz::https://github.com/sst/opencode/archive/v${pkgver}${_subver}.tar.gz") sha256sums=('SKIP') build() { cd "opencode-${pkgver}" + + # Ensure npm is in PATH for bun's shell + export PATH="/usr/bin:$PATH" + + # Install workspace dependencies from root bun install - cd ./packages/opencode - OPENCODE_CHANNEL=latest OPENCODE_VERSION=1.0.57 bun run ./script/build.ts --single + + # The build script uses relative imports like ../node_modules/... + # Create symlink so packages/opencode/node_modules points to root node_modules + cd packages/opencode + ln -sf ../../node_modules node_modules + + # Build the binary + OPENCODE_CHANNEL=latest OPENCODE_VERSION=${pkgver} bun run build --single } package() { cd "opencode-${pkgver}/packages/opencode" - install -Dm755 $(find dist/*/bin/opencode) "${pkgdir}/usr/bin/opencode" + + # Find the appropriate binary for this architecture + case "${CARCH}" in + x86_64) + binary=$(find dist/opencode-linux-x64*/bin/opencode -type f | head -1) + ;; + aarch64) + binary=$(find dist/opencode-linux-arm64*/bin/opencode -type f | head -1) + ;; + esac + + install -Dm755 "${binary}" "${pkgdir}/usr/bin/opencode" }