# Template file for 'libreoffice-bin'
pkgname=libreoffice-bin
version=4.0.3
revision=1
maintainer="pancake <pancake@nopcode.org>"
homepage="http://www.libreoffice.org/"
license="LGPL-3"
short_desc="Productivity suite compatible with other major office suites (binary build)"

_disturi="http://download.documentfoundation.org/libreoffice/stable/${version}/deb"
if [ "$XBPS_TARGET_MACHINE" = "x86_64" ]; then
	_arch=x86-64
	distfiles="${_disturi}/x86_64/LibreOffice_${version}_Linux_${_arch}_deb.tar.gz"
	checksum=b7c5274ef50ab9e9cad569fe94a3997563850a9c36bac852533c64a8949105e2
elif [ "$XBPS_TARGET_MACHINE" = "i686" ]; then
	_arch=x86
	distfiles="${_disturi}/x86/LibreOffice_${version}_Linux_${_arch}_deb.tar.gz"
	checksum=066109676c42b7a5302ef8eb5b636c218917b2c89de672523e174eb326c82872
fi
only_for_archs="i686 x86_64"
wrksrc="LibreOffice_${version}.3_Linux_${_arch}_deb"
disable_debug=yes

do_install() {
	cd DEBS
	mkdir -p ${DESTDIR}
	for a in *.deb ; do
		ar x $a
		tar xzpvf data.tar.gz -C ${DESTDIR}
	done
	# hack the missing shlibs!
	p=/opt/libreoffice4.0/program/
	d=${DESTDIR}/$p
	rm -f ${d}/libpng12.so.0
	ln -fs /usr/lib/libpng.so ${d}/libpng12.so.0
	cd ${d}
	hack_shlibs="
		libjawt.so
		libkdeui.so.4
		libkdecore.so.4
		libqt-mt.so.3
		libkabc.so.1
		libkio.so.4
	"
	for a in ${hack_shlibs} ; do
		ln -fs ./libpng12.so.0 ./${a}
	done

	# install symlinked programs to /usr
	programs="soffice scalc swriter simpress sdraw sbase"
	mkdir -p ${DESTDIR}/usr/bin
	for a in ${programs} ; do
		ln -fs ${p}/$a ${DESTDIR}/usr/bin/$a
	done
}

libreoffice-bin_package() {
	pkg_install() {
		vmove all
	}
}
