# Template file for 'wps-office'
pkgname=wps-office
version=10.1.0.6757
revision=1
maintainer="Michael Aldridge <maldridge@voidlinux.org>"
homepage="http://wps-community.org"
license="Kingsoft WPS Community License"
#Full license is at: http://wps-community.org/license.md (Not downloadable)
short_desc="Linux office suite with similar appearance to MS Office"
allow_unknown_shlibs=yes
nodebug=yes
restricted=yes

#The programs themselves are PIE, but the error reporter isn't :/
nopie=yes

_disturl=http://kdl.cc.ksosoft.com/wps-community/download/6757

only_for_archs="i686 x86_64"
if [ "$XBPS_TARGET_MACHINE" = "x86_64" ]; then
	_arch=x86_64
	checksum=0280d3e5a3b0c524f54076db6a904a6fee68b19075f6b879b5d2473622d4627e
elif [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
	_arch=x86
	checksum=d291a63ae39e6ac5d4569db3ab58e9888ddab116f000c406f174bc7fccb86985
fi

_distTar="${pkgname}_${version}_${_arch}.tar.xz"
distfiles="${_disturl}/${_distTar}"

do_extract() {
	vmkdir "opt/kingsoft/wps-office"
	tar xvf "${XBPS_SRCDISTDIR}/${pkgname}-${version}/${_distTar}" -C "${DESTDIR}/opt/kingsoft/wps-office" --strip-components=1
}

do_install() {
	# Install the wps-office suites
	vmkdir usr/bin
	vmkdir usr/share

	_programs="wps wpp et"
	for prog in ${_programs}; do
		ln -fs /opt/kingsoft/wps-office/$prog ${DESTDIR}/usr/bin/$prog
	done
	mv ${DESTDIR}/opt/kingsoft/wps-office/resource/* ${DESTDIR}/usr/share/

	#Clean up some things
	rm ${DESTDIR}/opt/kingsoft/wps-office/README.txt
        rm -rf ${DESTDIR}/opt/kingsoft/wps-office/resource
}
