# Template file for 'quake4'
pkgname=quake4
version=1.4.2
revision=3
depends="SDL libXext libudev zlib desktop-file-utils"
short_desc="Quake 4 for Linux"
maintainer="Juan RP <xtraeme@voidlinux.eu>"
license="Propietary"
homepage="http://www.quake4game.com/"
distfiles="http://ftp.iinet.net.au/games/idstuff/quake4/linux/quake4-linux-${version}.x86.run"
skip_extraction="quake4-linux-${version}.x86.run"
checksum=9203b387b1a4075a1b9ad1eb7be32b49a88141a448d9330d9cbe1f40a145bd6a

# 32bit package for x86_64 built on x86 :-)
only_for_archs="i686"
repository="nonfree"
nostrip="yes"

create_wrksrc=yes
lib32mode=full

do_install() {
	vmkdir opt

	# Extract files
	chmod +x ${XBPS_SRCDISTDIR}/${pkgname}-${version}/quake4-linux-${version}.x86.run
	${XBPS_SRCDISTDIR}/${pkgname}-${version}/quake4-linux-${version}.x86.run --noexec --target quake4

	# Move pk4 files to correct location
	mv quake4/us/q4base/*.pk4 quake4/q4base

	# Move Executables and Libraries
	install -m 755 -t quake4/ quake4/bin/Linux/x86/{lib*,q4ded*,quake4*}

	# Make Everything World-Readable
	chmod -R a+r quake4/

	# Remove Unneeded Files
	rm -rf quake4/{germany/,setup.data/,setup.sh,us/,bin/}
 
	# Move Quake4 to Destination Directory
	mv quake4 ${DESTDIR}/opt/

	# Install Launcher (Client - SMP)
	vinstall ${FILESDIR}/quake4-smp.launcher 755 usr/bin quake4

	# Install Launcher (Server)
	vinstall ${FILESDIR}/quake4-dedicated.launcher 755 usr/bin quake4-dedicated

	# Install License (Quake 4)
	vinstall ${DESTDIR}/opt/quake4/License.txt 644 usr/share/licenses/quake4

	# Install License (PunkBuster)
	vinstall ${DESTDIR}/opt/quake4/pb/PBEULA.txt 644 usr/share/licenses/quake4

	# Install Desktop File
	vinstall ${FILESDIR}/quake4.desktop 644 usr/share/applications

	# Install Icon File
	vinstall ${FILESDIR}/Quake-IV-icon.png 644 usr/share/pixmaps quake4.png
}
