pkgname=ratbin
pkgver=0.1.0
pkgrel=1
pkgdesc="Integrate AppImages, binaries and scripts into the application menu via the Thunar context menu"
arch=('x86_64')
license=('unknown')
depends=('gcc-libs' 'glibc')
makedepends=('cargo')
optdepends=(
  'kitty: terminal used by the Ratbin menu entry'
  'thunar: context menu integration'
  'desktop-file-utils: refresh the menu cache after changes'
  'libnotify: notifications from context menu actions'
)
options=('!lto')

_root="$startdir/../.."

prepare() {
  cd "$_root"
  export RUSTUP_TOOLCHAIN=stable
  cargo fetch --locked --target "$(rustc -vV | sed -n 's/host: //p')"
}

build() {
  cd "$_root"
  export RUSTUP_TOOLCHAIN=stable
  export CARGO_TARGET_DIR="$srcdir/target"
  cargo build --frozen --release
}

package() {
  install -Dm755 "$srcdir/target/release/ratbin" "$pkgdir/usr/bin/ratbin"
  install -Dm644 "$_root/assets/ratbin.desktop" "$pkgdir/usr/share/applications/ratbin.desktop"
}
