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

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

	rm "$pkgdir"/usr/bin/ptest

	mkdir -p "$pkgdir"/usr/share/man/man1
	cp doc/man/*.1 "$pkgdir"/usr/share/man/man1/
}

sha512sums="5f33f42ffec1e16090491895fb7403de6c0fcdf99e0fef7a49db19684b261a355ab0e0364891d1dfdaf47ff32671f2725d5e236df29e3f3feb5484cd8ffca0ca  pipexec-2.5.5.tar.xz
9838e8c45f6ded0e3207be4f225e751cec892ff110e8d18daaae514ea88b0f7a96381b31d425c1178c78f87ee86da4ddf18483fccd5308b9d7daa85c287df3ea  dont-require-bash.patch"
