# Template file for 'openbazaar'
pkgname=openbazaar
version=1.1.13
revision=2
archs="i686 x86_64"
create_wrksrc=yes
depends="nodejs"
short_desc="P2P Distributed marketplace"
maintainer="ananteris <ananteris@protonmail.ch>"
license="MIT"
homepage="http://openbazaar.org"
python_version=3
nostrip=yes
repository="nonfree"

case "${XBPS_TARGET_MACHINE}" in
	x86_64) _debarch=amd64
		checksum=34118eecedd15d89052b8cc6d08fb789adba5788d43019ea5c89e52f1f07064a
		;;
	i686)	_debarch=i386
		checksum=87c73589aebdb78455e69fe1ccc058440d0ae662404e9ef7d4988e6c574e2add
		;;
esac

distfiles="https://github.com/OpenBazaar/OpenBazaar-Installer/releases/download/v${version}/openbazaar_${version}_${_debarch}.deb"

do_install() {
	vcopy usr /
	vlicense usr/share/openbazaar/LICENSE
	vmkdir usr/lib/openbazaar/resources
	mv -v ${DESTDIR}/usr/share/openbazaar/resources/OpenBazaar-Server \
		${DESTDIR}/usr/lib/openbazaar/resources
	ln -frsv ${DESTDIR}/usr/lib/openbazaar/resources/OpenBazaar-Server/openbazaard \
		${DESTDIR}/usr/bin/
	vconf ${DESTDIR}/usr/lib/openbazaar/resources/OpenBazaar-Server/ob.cfg
	mv -v ${DESTDIR}/usr/share/openbazaar/openbazaar \
		${DESTDIR}/usr/lib/openbazaar
	ln -frsv ${DESTDIR}/usr/lib/openbazaar/openbazaar \
		${DESTDIR}/usr/bin/
	vdoc ${FILESDIR}/void_service.EXAMPLE

	find ${DESTDIR}/usr/share/openbazaar -iname "*.so" -print0 | while read -d "" lib; do
		dir="${lib%/*}"
		dir="${dir/\/share\//\/lib\/}"
		mkdir -p "${dir}"
		mv -v "${lib}" "${dir}"
	done
}
