# Contributor: Jakub Jirutka <jakub@jirutka.cz>
# Maintainer: Jakub Jirutka <jakub@jirutka.cz>
pkgname=pdsh
pkgver=2.33
pkgrel=0
pkgdesc="A high performance, parallel remote shell utility"
url="https://github.com/chaos/pdsh"
arch="all"
license="GPL-2.0"
depends="perl"
makedepends="autoconf automake libtool readline-dev ncurses-dev"
subpackages="$pkgname-doc $pkgname-rcmd-ssh:_rcmd_ssh"
source="https://github.com/chaos/$pkgname/archive/$pkgname-$pkgver.tar.gz
	without-rresvport.patch
	fix-test-t6036.patch"
builddir="$srcdir/$pkgname-$pkgname-$pkgver"
options="!checkroot"

prepare() {
	default_prepare

	cd "$builddir"
	./bootstrap
}

build() {
	cd "$builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--localstatedir=/var \
		--disable-static \
		--without-rsh \
		--with-ssh \
		--with-readline
	make
}

check() {
	cd "$builddir"
	make check
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install
}

_rcmd_ssh() {
	pkgdesc="Pdsh module for ssh rcmd functionality"
	depends="$pkgname openssh-client"
	install_if="$pkgname=$pkgver-r$pkgrel openssh-client"

	mkdir -p "$subpkgdir"/usr/lib/$pkgname
	mv "$pkgdir"/usr/lib/$pkgname/sshcmd.* "$subpkgdir"/usr/lib/$pkgname/
}

sha512sums="cb6cd9c8449c9484ff35405a162930635cf2e7c83a5d2f476fff23f070c63a7e2d2eb1135b3480aaf76e707d4b13f563a07a787ed2e8ee7a6cba38cc0fcd4333  pdsh-2.33.tar.gz
97d9cde907cdfe51cb805dcf772011578cc1485d67ad177e24a4f81283aac2535a400a9d71cc79f4c08f4ae8e5886635203b1c92c910ae915a591eb616b7347a  without-rresvport.patch
8ddfb37a4e7c9550f79e8bf0d24795203f23452541382f8d744adfe40889964fa966655795f2d4d594ee21af3f14c9d2fe93ad98a0620403d5c42aaab1f55949  fix-test-t6036.patch"
