# Contributor: Natanael Copa <ncopa@alpinelinux.org>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=spice
pkgver=0.14.0
pkgrel=6
pkgdesc="Implements the SPICE protocol"
url="http://www.spice-space.org/"
arch="all"
license="LGPL-2.0-or-later"
depends=""
depends_dev="spice-protocol pixman-dev celt051-dev libxinerama-dev"
makedepends="$depends_dev alsa-lib-dev libjpeg-turbo-dev libxrandr-dev
	cyrus-sasl-dev libxfixes-dev python2-dev bash cegui06-dev py-parsing
	py-six glib-dev opus-dev libressl-dev"
subpackages="$pkgname-dev $pkgname-server"
source="http://www.spice-space.org/download/releases/$pkgname-$pkgver.tar.bz2
	libressl.patch
	disable-test-channel.patch
	"
builddir="$srcdir/$pkgname-$pkgver"

# secfixes:
#   0.12.8-r4:
#     - CVE-2017-7506
#   0.12.8-r3:
#     - CVE-2016-9577
#     - CVE-2016-9578

build() {
	cd "$builddir"
	./configure \
		--build=$CBUILD \
		--host=$CHOST \
		--prefix=/usr \
		--sysconfdir=/etc \
		--mandir=/usr/share/man \
		--infodir=/usr/share/info \
		--localstatedir=/var \
		--enable-gui \
		--enable-client \
		--disable-smartcard \
		--enable-opus
	make -C spice-common WARN_CFLAGS=''
	make WARN_CFLAGS=''
}

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

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

server() {
	pkgdesc="Server library for SPICE"
	mkdir -p "$subpkgdir"/usr/lib
	mv "$pkgdir"/usr/lib/*server.so.* "$subpkgdir"/usr/lib/
}

sha512sums="84532146aa628ca6ca459a82afb89d6391892e063668fd4a68023c92cee7ca868b6c82e31dd9886819b76ea745ebdae0d0030e1f608d8f58f51c00f0b09bae1f  spice-0.14.0.tar.bz2
f28b0afaec4a9d18be0d29979c43f40695d33dcb158129064aa2033489534f643ec380075e16de9d54fd4b266dbcebea55d028dd4ec6ace49c0b155d96e8f68a  libressl.patch
77d3600f17c7b64b7b8eca4440244fbe4198c8541be262dd7825925bab731b116f4483a07f4b1d5a2e3d3761caedfaded2f999f57596495b65d11af9390e8242  disable-test-channel.patch"
