BUILD_DIR="./var/tmp/${PKGNAME}.build"

case "${ACTION}" in
post)
	. usr/lib/btsync/btsync-vars.sh
	mkdir -p "$BUILD_DIR"
	(
		cd "$BUILD_DIR"
		xbps-uhelper fetch "${BTSYNC_URL}>$PKGNAME.tar.gz"
		echo "$BTSYNC_CHECKSUM $PKGNAME.tar.gz" > chksum
		sha256sum -c chksum || exit 1
		tar xf "$PKGNAME.tar.gz"
	) || {
		echo Error while extracting;
		rm -r $BUILD_DIR;
		exit 1;
	}
	cp $BUILD_DIR/btsync "usr/bin/btsync"
;;
esac
