# Contributor: Fabio Ribeiro <fabiorphp@gmail.com>
# Maintainer: Andy Postnikov <apostnikov@gmail.com>
pkgname=php82-pecl-msgpack
_extname=msgpack
pkgver=3.0.0_rc1
_pkgver=${pkgver/_rc/RC}
pkgrel=0
pkgdesc="PHP 8.2 extension provides API for communicating with MessagePack serialization - PECL"
url="https://pecl.php.net/package/msgpack"
arch="all"
license="BSD-3-Clause"
_phpv=82
_php=php$_phpv
depends="$_php-session $_php-sockets"
makedepends="$_php-dev"
checkdepends="$_php-pecl-apcu"
source="php-pecl-$_extname-$pkgver.tgz::https://pecl.php.net/get/$_extname-$_pkgver.tgz"
builddir="$srcdir"/$_extname-$_pkgver
provides="$_php-msgpack=$pkgver-r$pkgrel" # for backward compatibility
replaces="$_php-msgpack" # for backward compatibility

install_if="php-$_extname php$_phpv"

build() {
	phpize$_phpv
	./configure --prefix=/usr --with-php-config=php-config$_phpv
	make
}

check() {
	rm -f tests/034.phpt # XFAIL https://github.com/msgpack/msgpack-php/issues/136
	rm -f tests/035.phpt # fails on ppc64le as of slow environment https://github.com/msgpack/msgpack-php/issues/123
	# Tests require session and sockets extensions which are not bundled
	local _depsdir=/usr/lib/$_php/modules
	make NO_INTERACTION=1 REPORT_EXIT_STATUS=1 test PHP_TEST_SHARED_EXTENSIONS="
		-d extension=$_depsdir/apcu.so \
		-d extension=$_depsdir/session.so \
		-d extension=$_depsdir/sockets.so \
		-d extension=modules/$_extname.so" TESTS=--show-diff
}

package() {
	make INSTALL_ROOT="$pkgdir" install
	local _confdir="$pkgdir"/etc/$_php/conf.d
	install -d $_confdir
	echo "extension=$_extname" > $_confdir/10_$_extname.ini
}

sha512sums="
908bb6bc161c6437240caea0e35f8e953caf50e45769d8ba0142e17bc292576ff04134291a721d0278303b8fd7bf7725ccd72eab98930c204dddd3ae076e21ab  php-pecl-msgpack-3.0.0_rc1.tgz
"
