# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=dummyhttp
pkgver=1.1.0
pkgrel=0
pkgdesc="Super simple HTTP server that replies a fixed body with a fixed response code"
url="https://github.com/svenstaro/dummyhttp"
license="MIT"
arch="all"
arch="$arch !ppc64le !loongarch64" # fails to build ring crate
makedepends="cargo cargo-auditable"
subpackages="
	$pkgname-doc
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="https://github.com/svenstaro/dummyhttp/archive/v$pkgver/dummyhttp-$pkgver.tar.gz"


prepare() {
	default_prepare

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

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

	./target/release/dummyhttp --print-manpage > $pkgname.1

	./target/release/dummyhttp --print-completions bash > $pkgname.bash
	./target/release/dummyhttp --print-completions fish > $pkgname.fish
	./target/release/dummyhttp --print-completions zsh > $pkgname.zsh
}

check() {
	cargo test --frozen
}

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

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

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

sha512sums="
e9accf6b75590f2c53d501555178f537a60b2d7209439ace83ea9e30e2ed5aa86ce40fd84d8b461f51567d51f50eb3e84fffd817015e7e79b80b1e80eda14466  dummyhttp-1.1.0.tar.gz
"
