# Contributor: Chloe Kudryavtsev <code@toast.bunkerlabs.net>
# Maintainer: Celeste <cielesti@protonmail.com>
maintainer="Celeste <cielesti@protonmail.com>"
pkgname=watchexec
pkgver=2.3.2
pkgrel=0
pkgdesc="Executes commands in response to file modifications"
url="https://github.com/watchexec/watchexec"
# s390x: nix/libc crate
arch="all !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="
688a559574c622a39c0e536860b32e8e52f7fd782d7b91e81b0144fc6c24461d047bb7ae6caf2f6ff636650f61b3bbc1226239a1947f7c455e4d1bf8277148c3  watchexec-2.3.2.tar.gz
6f1af1025ed2b74a3d81499ea75ae66304c31d46363a3f506fe287754f2ef6368c9798da9691bc7432a8705056a00b1ca8bbcff0d0821fc2566190e1095e37e8  system-dbus.patch
"
