# Maintainer: Felix Yan <felixonmars@archlinux.org>

pkgname=rime-double-pinyin
pkgver=0.0.0.20250923
_commit=5f9377ad5a6519b9a328874309877ebbd3d3ae31
pkgrel=1
pkgdesc="double-pinyin input for rime"
arch=('x86_64')
url="https://github.com/rime/rime-double-pinyin"
license=('LGPL')
# dependency for reverse lookup: rime-stroke
# dependency on dictionary: rime-luna-pinyin
depends=('rime-luna-pinyin' 'rime-stroke')
makedepends=('git' 'librime' 'rime-prelude' 'rime-essay')
source=("git+https://github.com/rime/rime-double-pinyin.git#commit=$_commit")
sha512sums=('7f560c45f53128b223048b94c67f5b37859c56189e7f13834830b828fe6b99486f185c6af63df5af14dc0851c4b90d43b33947ef6309586614917b88f760f86c')

prepare() {
  cd $pkgname
  # Link essentials
  for _f in $(pacman -Qql rime-prelude rime-essay rime-luna-pinyin | grep -v "/$"); do ln -sf $_f; done
}

build(){
  cd $pkgname
  for _s in $(ls *.schema.yaml); do rime_deployer --compile $_s; done
}

package() {
  cd $pkgname
  find . -type l -delete
  rm build/luna*
  rm build/*.txt
  install -Dm644 *.yaml -t "$pkgdir"/usr/share/rime-data/
  install -Dm644 build/* -t "$pkgdir"/usr/share/rime-data/build/
}
