| 1 | # shellcheck shell=bash |
| 2 | # shellcheck disable=SC2034,SC2154 |
| 3 | # makepkg consumes the metadata variables and defines CARCH/srcdir/pkgdir. |
| 4 | pkgname=codewhale-bin |
| 5 | pkgver=@PKGVER@ |
| 6 | pkgrel=@PKGREL@ |
| 7 | pkgdesc='Provider-neutral coding agent for the terminal (prebuilt binary)' |
| 8 | arch=('x86_64' 'aarch64') |
| 9 | url='https://codewhale.net' |
| 10 | license=('MIT') |
| 11 | if [[ "${CODEWHALE_INSTALL_COMPILED_HOST:-}" == 1 ]]; then |
| 12 | license+=('custom:compiled-Bun-runtime') |
| 13 | fi |
| 14 | depends=('glibc' 'gcc-libs' 'dbus') |
| 15 | provides=("codewhale=${pkgver}" 'codewhale-tui' 'deepseek' 'deepseek-tui') |
| 16 | conflicts=('codewhale' 'codewhale-tui' 'deepseek' 'deepseek-tui' 'deepseek-tui-bin') |
| 17 | replaces=('deepseek-tui-bin') |
| 18 | options=('!strip') |
| 19 | |
| 20 | _release_url="https://github.com/codewhale-hq/CodeWhale/releases/download/v${pkgver}" |
| 21 | |
| 22 | source=("LICENSE-${pkgver}::https://raw.githubusercontent.com/codewhale-hq/CodeWhale/v${pkgver}/LICENSE") |
| 23 | sha256sums=('@LICENSE_SHA256@') |
| 24 | source_x86_64=("${pkgname}-${pkgver}-x86_64.tar.gz::${_release_url}/codewhale-linux-x64.tar.gz") |
| 25 | sha256sums_x86_64=('@X86_64_SHA256@') |
| 26 | source_aarch64=("${pkgname}-${pkgver}-aarch64.tar.gz::${_release_url}/codewhale-linux-arm64.tar.gz") |
| 27 | sha256sums_aarch64=('@AARCH64_SHA256@') |
| 28 | |
| 29 | package() { |
| 30 | local release_arch |
| 31 | case "${CARCH}" in |
| 32 | x86_64) release_arch='x64' ;; |
| 33 | aarch64) release_arch='arm64' ;; |
| 34 | *) printf 'unsupported architecture: %s\n' "${CARCH}" >&2; return 1 ;; |
| 35 | esac |
| 36 | |
| 37 | install -Dm755 "${srcdir}/codewhale-linux-${release_arch}/codewhale" \ |
| 38 | "${pkgdir}/usr/bin/codewhale" |
| 39 | install -Dm755 "${srcdir}/codewhale-linux-${release_arch}/codew" \ |
| 40 | "${pkgdir}/usr/bin/codew" |
| 41 | # Optional qualified image, not a default/runtime replacement. Existing |
| 42 | # package-manager ownership keeps these files outside Core self-update. |
| 43 | if [[ "${CODEWHALE_INSTALL_COMPILED_HOST:-}" == 1 ]]; then |
| 44 | local archive="${srcdir}/codewhale-linux-${release_arch}" |
| 45 | local file |
| 46 | for file in codewhale-extension-host codewhale-extension-host.LICENSES.txt codewhale-extension-host.relink-source.tar.gz codewhale-extension-host.release.json; do |
| 47 | [[ -f "${archive}/${file}" && ! -L "${archive}/${file}" ]] || { printf 'compiled host requested but qualified payload is absent: %s\n' "${file}" >&2; return 1; } |
| 48 | done |
| 49 | install -Dm755 "${archive}/codewhale-extension-host" "${pkgdir}/usr/bin/codewhale-extension-host" |
| 50 | install -Dm644 "${archive}/codewhale-extension-host.release.json" "${pkgdir}/usr/bin/codewhale-extension-host.release.json" |
| 51 | for file in codewhale-extension-host.LICENSES.txt codewhale-extension-host.relink-source.tar.gz; do |
| 52 | install -Dm644 "${archive}/${file}" "${pkgdir}/usr/share/licenses/${pkgname}/${file}" |
| 53 | done |
| 54 | fi |
| 55 | ln -s codewhale "${pkgdir}/usr/bin/codewhale-tui" |
| 56 | install -Dm644 "${srcdir}/LICENSE-${pkgver}" \ |
| 57 | "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE" |
| 58 | } |
| 59 |