# Contributor: Stuart Cardall <developer@it-offshore.co.uk>
# Maintainer: Stuart Cardall <developer@it-offshore.co.uk>
pkgname=xpra
pkgver=2.2.5
pkgrel=0
pkgdesc="Xpra is 'screen for X' & allows you to run X programs, usually on a remote host over SSH or encrypted tcp"
url="http://xpra.org"
# !armhf: fails to build
arch="all !s390x !armhf"
license="GPL-2.0-or-later"
depends="py-gobject py-gtk py-imaging xf86-video-dummy xvfb setxkbmap xorg-server
	py2-numpy py2-pillow py-gtkglext py2-lz4 py-rencode py-opencl py2-xxhash
	py2-cryptography"
makedepends="python2-dev cython-dev libx11-dev libxtst-dev libxcomposite-dev libxdamage-dev
	libxrandr-dev py-gobject-dev py-gtk-dev libxkbfile-dev gtk+2.0-dev x264-dev x265-dev
	libvpx-dev ffmpeg-dev cython linux-headers gstreamer-dev py2-yuicompressor"
subpackages="$pkgname-doc $pkgname-tests::noarch $pkgname-webclient::noarch"
options="!check"
source="https://xpra.org/src/$pkgname-$pkgver.tar.xz"
builddir="$srcdir/$pkgname-$pkgver"

build() {
	cd "$builddir"

	# https://www.xpra.org/trac/ticket/1080
	CFLAGS="$CFLAGS -fno-strict-aliasing"
	python2 setup.py build \
		--with-bundle_tests
}

package() {
	cd "$builddir"

	python2 setup.py install --prefix=/usr --root="$pkgdir"

	# Fixes Error relocating /usr/lib/xorg/modules/drivers/dummy_drv.so: fbPictureInit: symbol not found
	# https://bugs.alpinelinux.org/issues/5478
	printf '\nSection "Module"\n  Load\t"fb"\nEndSection\n' >> "$pkgdir"/etc/xpra/xorg.conf
}

tests() {
	pkgdesc="Xpra test suite"

	cd "$builddir"
	mkdir -p "$subpkgdir"/usr/share/xpra
	cp -rf tests "$subpkgdir"/usr/share/xpra/
}

webclient() {
	pkgdesc="Xpra websockets client"

	cd "$pkgdir"
	mkdir -p "$subpkgdir"/usr/share/xpra
	cp -rf usr/share/xpra/www "$subpkgdir"/usr/share/xpra/
}

sha512sums="84a1926e8d75eaa840faa1389127cd7ec75981c78d65e820f01f628300cf5e51b9e9569892e91c69d32aa9b64e5a4d5f05376cd8155cc29e41e6ef15092fdacf  xpra-2.2.5.tar.xz"
