# Maintainer: NOKOTAN local builder
pkgname=ratune
pkgver=0.17.0
pkgrel=1
pkgdesc='A modern terminal music player for Subsonic-compatible servers'
arch=('x86_64')
url='https://github.com/acmagn/ratune'
license=('MIT')
depends=('alsa-lib' 'dbus' 'gcc-libs' 'glibc')
makedepends=('base-devel' 'rust' 'pkgconf')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/acmagn/ratune/archive/refs/tags/v${pkgver}.tar.gz")
sha256sums=('SKIP')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  cargo build --release --locked --package ratune
}

check() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  cargo test --locked --workspace
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"
  install -Dm755 "target/release/ratune" "${pkgdir}/usr/bin/ratune"
  install -Dm644 "LICENSE" "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE"
  install -Dm644 "README.md" "${pkgdir}/usr/share/doc/${pkgname}/README.md"
  if [[ -f docs/sample-config.toml ]]; then
    install -Dm644 docs/sample-config.toml \
      "${pkgdir}/usr/share/doc/${pkgname}/sample-config.toml"
  fi
}
