# Maintainer: Renato Iwashima <renato@lyre>
#
# To generate .SRCINFO after editing this file:
#   makepkg --printsrcinfo > .SRCINFO

pkgname=lyre-tts-bin
pkgver=0.1.0
pkgrel=1
pkgdesc='Cross-platform TTS companion for games'
arch=('x86_64')
url='https://github.com/renatoi/lyre'
license=('MIT')
depends=('gtk4' 'libx11' 'libxcb' 'alsa-lib' 'pipewire' 'gtk4-layer-shell')
provides=('lyre-tts')
conflicts=('lyre-tts')
options=('!strip')

_tag="v${pkgver}"
source=(
  "lyre-linux-x64-${pkgver}.tar.gz::${url}/releases/download/${_tag}/lyre-linux-x64.tar.gz"
  "SHA256SUMS-${pkgver}::${url}/releases/download/${_tag}/SHA256SUMS"
)

# Populated from the GitHub Release SHA256SUMS file at packaging time.
# Run updpkgsums or manually extract the hash for lyre-linux-x64.tar.gz.
sha256sums=('SKIP'
            'SKIP')

prepare() {
  # Verify the tarball hash matches the one published in SHA256SUMS
  _expected="$(grep 'lyre-linux-x64.tar.gz' "${srcdir}/SHA256SUMS-${pkgver}" | cut -d' ' -f1)"
  _actual="$(sha256sum "${srcdir}/lyre-linux-x64-${pkgver}.tar.gz" | cut -d' ' -f1)"
  if [ "${_expected}" != "${_actual}" ]; then
    echo "ERROR: SHA256 mismatch for lyre-linux-x64.tar.gz"
    echo "  expected: ${_expected}"
    echo "  actual:   ${_actual}"
    return 1
  fi
}

package() {
  install -Dm755 "${srcdir}/lyre-tts" "${pkgdir}/usr/bin/lyre-tts"
  install -Dm644 "${srcdir}/creature_voiced_db.json" "${pkgdir}/usr/share/lyre/creature_voiced_db.json"
}
