# Maintainer: qwjyh <urataw421@gmail.com>

pkgname=xdbm
pkgver=0.4.0
pkgrel=1
depends=('libgit2')
makedepends=('cargo')
arch=('i686' 'x86_64' 'armv6h' 'armv7h')
pkgdesc="Cross device backup manager, which manages backups on several storages mounted on multiple devices."
url="https://github.com/qwjyh/xdbm"
source=("$pkgname-$pkgver.tar.gz::https://static.crates.io/crates/$pkgname/$pkgname-$pkgver.crate")
options=(!lto)
license=('MIT OR Apache-1.0')
sha512sums=('SKIP')

# Generated in accordance to https://wiki.archlinux.org/title/Rust_package_guidelines.
# Might require further modification depending on the package involved.
prepare() {
  cd "$pkgname-$pkgver" || exit
  cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
  cd "$pkgname-$pkgver" || exit
  cargo build --frozen --release --all-features
}

check() {
  cd "$pkgname-$pkgver" || exit
  cargo test --frozen --all-features
}

package() {
  cd "$pkgname-$pkgver" || exit
  install -Dm0755 -t "$pkgdir/usr/bin/" "target/release/$pkgname"

  for shell in 'bash' 'zsh' 'fish'; do
    "$pkgdir/usr/bin/$pkgname" completion $shell > "$pkgname.$shell"
  done
  install -Dm644 "$pkgname.bash" "$pkgdir/usr/share/bash-completion/completions/$pkgname"
  install -Dm644 "$pkgname.zsh" "$pkgdir/usr/share/zsh/site-functions/_$pkgname"
  install -Dm644 "$pkgname.fish" "$pkgdir/usr/share/fish/vendor_completions.d/$pkgname.fish"
}

# vim: ts=2 sw=2: