# Contributor: Chloe Kudryavtsev <code@toast.bunkerlabs.net>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=watchexec
pkgver=2.2.0
pkgrel=0
pkgdesc="Executes commands in response to file modifications"
url="https://github.com/watchexec/watchexec"
# riscv64: scopes test in ignore/tests/filtering.rs fails
# s390x: nix/libc crate
arch="all !riscv64 !s390x"
license="Apache-2.0"
makedepends="cargo cargo-auditable dbus-dev"
checkdepends="bash"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/watchexec/watchexec/archive/refs/tags/v$pkgver.tar.gz
	system-dbus.patch
	"
options="net"

prepare() {
	default_prepare

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

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

check() {
	cargo test --all --frozen
}

package() {
	install -Dm755 target/release/watchexec -t "$pkgdir"/usr/bin/
	install -Dm644 doc/watchexec.1 -t "$pkgdir"/usr/share/man/man1/

	install -Dm644 completions/bash \
		"$pkgdir"/usr/share/bash-completion/completions/watchexec
	install -Dm644 completions/fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/watchexec.fish
	install -Dm644 completions/zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_watchexec
}

sha512sums="
373a676e815d4d7a5f517b9952746bd242dff2a9824f2164daef9be7153352f17cb6db5854e151b697a25869336bade5782218e1d6d5cc6168be47b3c6b490a1  watchexec-2.2.0.tar.gz
0be010a1d7897602477f6351ec8dd6c0f6a097772810d3fe2a979799d417b5c75fd0abae341bcb1167d5821a361af86643a4f63446beb0a727d9d21ba4ddedae  system-dbus.patch
"
