# Maintainer: clearclown <https://github.com/clearclown>
pkgname=an
pkgver=0.1.0
pkgrel=1
pkgdesc="AN (安装) - Unified Package Manager for Linux"
arch=('x86_64' 'aarch64')
url="https://github.com/clearclown/AN"
license=('MIT')
depends=('gcc-libs' 'git')
optdepends=(
    'flatpak: Flatpak support'
    'dpkg: Deb package support'
)
makedepends=('cargo')
source=("$pkgname-$pkgver.tar.gz::https://github.com/clearclown/AN/archive/v$pkgver.tar.gz")
sha256sums=('SKIP')

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

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

check() {
    cd "AN-$pkgver"
    export RUSTUP_TOOLCHAIN=stable
    cargo test --frozen --all-features
}

package() {
    cd "AN-$pkgver"
    install -Dm0755 -t "$pkgdir/usr/bin/" "target/release/$pkgname"
    install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
    install -Dm644 README.md "$pkgdir/usr/share/doc/$pkgname/README.md"
}
