# Template build file for 'spotify'.
pkgname=spotify
version=0.9
revision=7
short_desc="Proprietary music streaming client"
maintainer="Stefan Mühlinghaus <jazzman@alphabreed.com>"
homepage="https://www.spotify.com"
license="Proprietary"
create_wrksrc=1
only_for_archs="x86_64 i686"
repository=nonfree
build_style=fetch
makedepends="libgpg-error-devel"
distfiles="ftp://ftp.gnupg.org/gcrypt/libgcrypt/libgcrypt-1.5.4.tar.bz2"
checksum="d5f88d9f41a46953dc250cdb8575129b37ee2208401b7fa338c897f667c7fb33"
depends="binutils qt gtk+ nss GConf libXScrnSaver"

if test "${XBPS_TARGET_MACHINE}" = "x86_64"; then
	_sversion=".17.1.g9b85d43.7-1_amd64"
	_schecksum="717a878bcfa495852d19ac34bb4b0fa1b2f063ab94547defd32725d1dec10775"
	distfiles+=" http://seblu.net/a/arm/packages/g/gtk2/gtk2-2.24.24-1-x86_64.pkg.tar.xz"
	checksum+=" 53a7a400050d5c16585fa19f587da9639f05970fd703dc4c6482f9ceb6ccbaee"
	depends+=" pango-xft"
else
	_sversion=".4.183.g644e24e.428-1_i386"
	_schecksum="ca45d057357e4c30efee3838dd941222500463ddd0a1db6981e4d48d7ad986f2"
	distfiles+=" http://seblu.net/a/arm/packages/g/gtk2/gtk2-2.24.24-1-i686.pkg.tar.xz"
	checksum+=" 8d9be115cfe6fb2b26d4ecc837a1aa498cd7492395106e5085d08f6a15862209"
fi

do_extract() {
	tar xjf "${XBPS_SRCDISTDIR}/spotify-${version}/libgcrypt-1.5.4.tar.bz2"
	tar xJf "${XBPS_SRCDISTDIR}/spotify-${version}/gtk2-2.24.24-1-${XBPS_TARGET_MACHINE}.pkg.tar.xz"
}

do_build() {
	cd libgcrypt-1.5.4
	./configure ${configure_args}
	make ${makejobs}
}

do_install() {
	vbin ${FILESDIR}/spotify
	vmkdir usr/share/spotify/libs
	vinstall libgcrypt-1.5.4/src/.libs/libgcrypt.so.11.8.3 755 usr/share/spotify/libs libgcrypt.so.11
	vinstall usr/lib/libgdk-x11-2.0.so.0.2400.24 755 usr/share/spotify/libs libgdk-x11-2.0.so.0
	vinstall usr/lib/libgtk-x11-2.0.so.0.2400.24 755 usr/share/spotify/libs libgtk-x11-2.0.so.0
	echo "export SVERSION=\"${version}${_sversion}\"" >"${DESTDIR}/usr/share/spotify/pkgdata"
	echo "export SCHECKSUM=\"${_schecksum}\"" >>"${DESTDIR}/usr/share/spotify/pkgdata"
}
