# Contributor: Michał Polański <michal@polanski.me>
# Maintainer: Michał Polański <michal@polanski.me>
pkgname=dummyhttp
pkgver=1.0.3
pkgrel=2
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 !s390x !riscv64" # limited by rust/cargo
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="
57dfeac8f9774d647b7ce09ec6a413f5ca3140500099fda7a7819134146eba105012a629e6e050eedb2ee1ecd026e25ff55bb0acee1fe460f24c8027df6f802a  dummyhttp-1.0.3.tar.gz
"
