# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=pipexec
pkgver=2.6.2
pkgrel=0
pkgdesc="Handling pipe of commands like a single command"
url="https://github.com/flonatel/pipexec"
arch="all"
license="GPL-2.0-or-later"
subpackages="$pkgname-doc"
source="https://github.com/flonatel/pipexec/releases/download/$pkgver/$pkgname-$pkgver.tar.xz"

prepare() {
	default_prepare
	update_config_sub
}

build() {
	cd "$builddir"

	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--mandir=/usr/share/man
	make
}

# Note: make check actually does not run any tests.
check() {
	local out

	out=$("$builddir"/bin/pipexec -- \
		[A /bin/echo 'Hello, world!' ] [B /bin/grep -o world ] '{A:1>B:0}')
	[ "$out" = world ]
}

package() {
	cd "$builddir"

	make DESTDIR="$pkgdir" install
	install -D -m644 doc/man/*.1 -t "$pkgdir"/usr/share/man/man1/

	rm "$pkgdir"/usr/bin/ptest
}

sha512sums="
c63e724a4bc1c53fbe42e7ce0295a3e93c0be5bea5b20f15d07a7b150cbec6cae3ab10ffee06fe5d8ed36569ab4a0467a10be4f781f9b770db3a5d294973e567  pipexec-2.6.2.tar.xz
"
