SUMMARY="An open-source Dropbox client"
DESCRIPTION="Orphilia is an open-source Dropbox client written in Python. \
Project's main goal is to provide an open-source desktop Dropbox client for \
platforms, that  aren't supported (for example, Haiku). Orphilia is \
script-based which makes it platform-independent. It's written using \
Dropbox SDK from here, which has been integrated into Orphilia's source \
code and is not required for installation."
HOMEPAGE="https://github.com/ksiazkowicz/orphilia-dropbox"
COPYRIGHT="2011-2014 Maciej Janiszewski"
LICENSE="MIT"
REVISION="2"
srcGitRev="f692f26793a48e2742f12c20767f0f22a9ff39af"
SOURCE_URI="https://github.com/ksiazkowicz/orphilia-dropbox/archive/f692f26793a48e2742f12c20767f0f22a9ff39af.tar.gz"
CHECKSUM_SHA256="31d39a4aa08b3711bcc044045c2862ddbd831ff4e848b85c6c188ce7e4c562d1"
SOURCE_DIR="orphilia-dropbox-$srcGitRev"

ARCHITECTURES="?all x86_gcc2"

# Should be called after activating package
#POST_INSTALL_SCRIPTS="
#	\"orphilia.py --configuration\"
#	"

PROVIDES="
	orphilia_dropbox = $portVersion
	cmd:orphilia.py = $portVersion
	cmd:orphilia_haiku_notify = $portVersion
	"
REQUIRES="
	pathtools_python
	setuptools_python
	urllib3_python
	watchdog_python
	cmd:python
	"

BUILD_REQUIRES="
	haiku_devel
	setuptools_python
	"
BUILD_PREREQUIRES="
	cmd:gcc
	cmd:python
	cmd:sed
	"

BUILD()
{
	python build.py
}

INSTALL()
{
	# GENERIC: all python_setuptools-based installs need this
	export PATH="$portPackageLinksDir/cmd~python/bin:$PATH"
	pythonVersion=$(python --version 2>&1 | sed 's/Python //' | head -c3)
	installLocation=$prefix/lib/python$pythonVersion/vendor-packages/
	export PYTHONPATH=$installLocation:$PYTHONPATH
	mkdir -p $installLocation

	cd built/dependencies
        python setup.py install \
                --single-version-externally-managed \
                --root=/ --prefix=$prefix
	cd ../..

	mkdir -p $installLocation/orphilia_dropbox
	cp -R built/* $installLocation/orphilia_dropbox

	mkdir -p $binDir

	# create symlink which could be directly accessed
	ln -s $installLocation/orphilia_dropbox/notify/haiku-notify $binDir/orphilia_haiku-notify
	ln -s $installLocation/orphilia_dropbox/orphilia.py $binDir/orphilia.py
}
