# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=zoxide
pkgver=0.9.4
pkgrel=0
pkgdesc="Faster way to navigate your filesystem"
url="https://github.com/ajeetdsouza/zoxide"
# s390x: https://github.com/nix-rust/nix/issues/1968
arch="all !s390x"
license="MIT"
makedepends="cargo cargo-auditable"
checkdepends="dash bash fish shfmt zsh"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/ajeetdsouza/zoxide/archive/v$pkgver/zoxide-$pkgver.tar.gz
	exclude-shellcheck-test.patch
	Cargo-update.patch
	"

export CARGO_PROFILE_RELEASE_OPT_LEVEL="z"

prepare() {
	default_prepare

	cargo fetch --target="$CTARGET" --locked
}

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

check() {
	cargo test --frozen
}

package() {
	install -Dm755 target/release/zoxide -t "$pkgdir"/usr/bin/

	install -Dm644 man/man1/*.1 -t "$pkgdir"/usr/share/man/man1/

	cd contrib/completions
	install -Dm644 zoxide.bash "$pkgdir"/usr/share/bash-completion/completions/zoxide
	install -Dm644 zoxide.fish -t "$pkgdir"/usr/share/fish/vendor_completions.d/
	install -Dm644 _zoxide -t "$pkgdir"/usr/share/zsh/site-functions/
}

sha512sums="
c09c54402bb8db52952017e51b65728a5b1a63be617ddc2dbab47aae59e2059f0c58c97c3355a4a00570a0e9d79c6cdd529adb4f73d5cec0f2f9b490c2af668c  zoxide-0.9.4.tar.gz
78f53af62460aec5db610ed7a47344f4386b1a0129f05b9b392cbd588d5c8ea10a18a48c9c8ef34bc73436aeaf0e3e6eecc50c99425b3efdec266d4f862dbf78  exclude-shellcheck-test.patch
7483f139ccc187ea4ababe3aaaaf5070485749002641624960e70245ea54fcaa108f83e1191273c7966aaddef531e938aa87517111bd9bef6a524f0df163c761  Cargo-update.patch
"