# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=rpcbind
pkgver=0.2.4
pkgrel=0
pkgdesc="portmap replacement which supports RPC over various protocols"
url="http://rpcbind.sourceforge.net"
arch="all"
license="custom"
depends=
install="$pkgname.pre-install $pkgname.pre-upgrade"
makedepends="libtirpc-dev autoconf automake bsd-compat-headers"
subpackages="$pkgname-dbg $pkgname-doc"
source="http://downloads.sourceforge.net/project/rpcbind/rpcbind/$pkgver/rpcbind-$pkgver.tar.bz2
	CVE-2017-8779.patch
	pmapproc_dump-Fixed-typo-in-memory-leak-patch.patch
	rpcbproc_callit_com-Stop-freeing-a-static-pointer.patch
	rpcbind.initd
	rpcbind.confd
	"

# secfixes:
#   0.2.4-r0:
#   - CVE-2017-8779

builddir="$srcdir"/rpcbind-$pkgver
prepare() {
	cd "$builddir"
	for i in $source; do
		case $i in
		*.patch) msg $i; patch -p1 -i "$srcdir"/$i || return 1;;
		esac
	done
	sh autogen.sh || return 1
}

build() {
	cd "$builddir"
	unset CC
	unset CFLAGS
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--bindir=/sbin \
		--enable-warmstarts \
		--with-statedir=/var/lib/rpcbind \
		--with-rpcuser=rpc \
		--enable-debug \
		--with-systemdsystemunitdir='no' \
		|| return 1
	make -j1 || return 1
}

package() {
	cd "$builddir"
	make DESTDIR="$pkgdir" install || return 1
	install -Dm755 "$srcdir"/rpcbind.initd "$pkgdir"/etc/init.d/rpcbind
	install -Dm644 "$srcdir"/rpcbind.confd "$pkgdir"/etc/conf.d/rpcbind
	install -D -m644 COPYING "$pkgdir"/usr/share/licenses/rpcbind/COPYING
}
sha512sums="f3966a7284e94bdf120a9b3f0dd66efa1fe8761df2313545a031f77b7c06e27d7955d2780469943deb537d34f95c4cf3f30de523ec9fab9f571322d7224b210c  rpcbind-0.2.4.tar.bz2
cc3b7d72299279f6c7e7ce0329d29a8bc0c44a9e99c241cbbe8f34eba71ca16da7e87683a66e36565422dde9a3b03be8d6e345264495c6e2070f97116da32244  CVE-2017-8779.patch
1ecce48807b276381ff3199916e0b85880b948086e7891aa35df8a10f9188641253572c330e5fee35afa69c5ce3965ebead14fbe8ef20c49a4e9047345e63c5e  pmapproc_dump-Fixed-typo-in-memory-leak-patch.patch
a0125bd24a533366d7fcaed68e6671df65e3e39a4b18be2265f987602944d358666edef954f8707d24453331f7e96341739e5346bc1b233380c618b34a4014e2  rpcbproc_callit_com-Stop-freeing-a-static-pointer.patch
1cd655d86226a45fa3e927f8ac2bb580537644d2fb3684e0f4a956bf3721c95d95b8b8c1d9a2a742fb714eeba9277e0400a7493bf1bf676466d70adb2b35a88e  rpcbind.initd
0641087162ebc8fb10c5cb329105261d77cad073daed3f9a6c92574177298cd8a19a87b62dde14161cc554b5e68680cfd870b5334f3cfd8d6074ec8a43f4dfe3  rpcbind.confd"
