# Template file for 'teamspeak3'
pkgname=teamspeak3
version=3.5.0
revision=1
archs="i686 x86_64"
wrksrc=teamspeak3
create_wrksrc=yes
makedepends="tar"
depends="glib bash grep freetype nss libXcomposite fontconfig glibc
 libxslt dbus-libs alsa-lib libXi libXcursor libXtst libXScrnSaver pciutils"
short_desc="Popular proprietary voice chat for gaming"
maintainer="Tai Chi Minh Ralph Eastwood <tcmreastwood@gmail.com>"
license="Proprietary"
homepage="http://www.teamspeak.com/"
restricted=yes
repository="nonfree"
nopie=yes
nostrip=yes
noverifyrdeps=yes

if [ "$XBPS_TARGET_MACHINE" = "x86_64" ]; then
	_pkg="TeamSpeak3-Client-linux_amd64-${version}"
	distfiles="https://files.teamspeak-services.com/releases/client/${version}/${_pkg}.run"
	checksum=17d53f116f38519d41749d5b07059e1791a533d0bcee052052b0b6b41f015912
elif [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
	_pkg="TeamSpeak3-Client-linux_x86-${version}"
	distfiles="https://files.teamspeak-services.com/releases/client/${version}/${_pkg}.run"
	checksum=6ed3a4255c4785437668748b5a8f39895678cd57133150c33302a94421c5ffeb
else
	broken="No known upstream client for this architecture"
fi

do_extract() {
	install -m755 ${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_pkg}.run ${wrksrc}
	sh ./${_pkg}.run --tar xf
	rm -f ${_pkg}.run
}

do_install() {
	# Set proper permissions
	find -type d | xargs chmod 755
	find -type f | xargs chmod 644
	find -name '*.so*' | xargs chmod 755
	chmod +x ts3client* package_inst QtWebEngineProcess

	vmkdir "usr/lib/teamspeak3"
	vcopy * "usr/lib/teamspeak3"

	# Install desktop file
	vinstall "${FILESDIR}/teamspeak3.desktop" 644 "usr/share/applications"

	# Install icon file
	vinstall styles/default/logo-128x128.png 644 usr/share/pixmaps/teamspeak3.png

	# Install the license (not present in most recent version)
	# vlicense LICENSE

	# Install client launcher
	vbin "${FILESDIR}/teamspeak3"
}
