# Maintainer: Matheus Teixeira <github@mteixeira.dev>
#
# This is a template PKGBUILD for submitting to the Arch User Repository (AUR)
# To use:
# 1. Update the maintainer email above
# 2. Update the pkgver when releasing new versions
# 3. Calculate the sha256sum: curl -sL <source_url> | sha256sum
# 4. Submit to AUR: https://aur.archlinux.org/packages/multidiff

pkgname=multidiff
pkgver=0.1.0
pkgrel=1
pkgdesc="Binary data diffing for multiple objects or streams of data"
arch=('x86_64' 'aarch64')
url="https://github.com/mtxr/multidiff-rs"
license=('MIT')
depends=()
makedepends=('cargo' 'git')
source=("$pkgname-$pkgver.tar.gz::https://github.com/mtxr/multidiff-rs/archive/v$pkgver.tar.gz")
sha256sums=('SKIP')  # Update with actual sha256sum before submitting to AUR

prepare() {
    cd "multidiff-rs-$pkgver"
    cargo fetch --locked --target "$CARCH-unknown-linux-gnu"
}

build() {
    cd "multidiff-rs-$pkgver"
    export RUSTUP_TOOLCHAIN=stable
    export CARGO_TARGET_DIR=target
    cargo build --frozen --release --all-features
}

check() {
    cd "multidiff-rs-$pkgver"
    cargo test --frozen --all-features
}

package() {
    cd "multidiff-rs-$pkgver"
    install -Dm755 "target/release/$pkgname" "$pkgdir/usr/bin/$pkgname"
    install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
    install -Dm644 CHANGELOG.md "$pkgdir/usr/share/doc/$pkgname/CHANGELOG.md"
    install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
}
