# Contributor: Matthias Ahouansou <matthias@ahouansou.cz>
# Maintainer: Matthias Ahouansou <matthias@ahouansou.cz>
pkgname=cargo-deny
pkgver=0.16.4
pkgrel=0
pkgdesc="Cargo plugin for linting your dependencies"
url="https://github.com/EmbarkStudios/cargo-deny"
# 32-bits: tests fail on 32bit https://github.com/EmbarkStudios/cargo-deny/issues/540
# s390x: tests fail due to different cargo index hash
arch="all !x86 !armv7 !armhf !s390x"
license="MIT OR Apache-2.0"
makedepends="
	cargo
	cargo-auditable
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/EmbarkStudios/cargo-deny/archive/refs/tags/$pkgver.tar.gz"
options="net"

prepare() {
	default_prepare
	# remove upstream's compile flags for musl target
	rm -r .cargo/
	cargo fetch --target="$CTARGET" --locked
}

build() {
	cargo auditable build --release --frozen
}

check() {
	# These tests require the advisory repos to be cloned via git
	cargo test --frozen -- \
		--skip detects_unmaintained \
		--skip detects_unsound \
		--skip detects_vulnerabilities \
		--skip downgrades_lint_levels \
		--skip fails_on_stale_advisory_database \
		--skip fetches_with_git \
		--skip fetches_with_gix \
		--skip warns_on_ignored_and_withdrawn \
		--skip warns_on_index_failures
}

package() {
	install -Dm 755 target/release/cargo-deny "$pkgdir"/usr/bin/cargo-deny

	for l in APACHE MIT
	do
		install -Dm 644 LICENSE-"$l" "$pkgdir"/usr/share/licenses/"$pkgname"/LICENSE-"$l"
	done
}

sha512sums="
89e357348a61dcf5d1cc0947bd7749e899190397c154c9897858bb04d868e1ef900cd753c5b36382111a5c16b6b559b0ce1fead6349e06400081576865051f84  cargo-deny-0.16.4.tar.gz
"
