PORTNAME=	graphite-api
PORTVERSION=	1.1.3
PORTREVISION=	4
CATEGORIES=	www python
MASTER_SITES=	PYPI
PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}

MAINTAINER=	dch@FreeBSD.org
COMMENT=	Graphite-web, without the interface - just the rendering HTTP API
WWW=		https://github.com/brutasse/graphite-api

LICENSE=	APACHE20

RUN_DEPENDS=	\
		${PYTHON_PKGNAMEPREFIX}pytz>0:devel/py-pytz@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}flask>=0.10.1:www/py-flask@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}Flask-Cache>=0.13.1:www/py-flask-cache@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}tzlocal>=1.1.1:devel/py-tzlocal@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}structlog>=16.0.0:devel/py-structlog@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}pyparsing>=2.0.0:devel/py-pyparsing@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}pyyaml>3.1:devel/py-pyyaml@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}cairocffi>=0.7.2:graphics/py-cairocffi@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}gunicorn>=19.4.1:www/py-gunicorn@${PY_FLAVOR} \
		xorg-fonts-truetype>=0:x11-fonts/xorg-fonts-truetype

USES=		python
USE_PYTHON=	distutils py3kplist

NO_ARCH=	yes

GRAPHITEAPI_APP=	graphiteapi

SUB_FILES=	pkg-message
SUB_LIST=	PYTHON_VER=${PYTHON_VER} \
		PYTHON_VERSION=${PYTHON_VERSION} \
		GRAPHITEAPI_APP=${GRAPHITEAPI_APP} \
		GRAPHITEAPI_USER=${GRAPHITEAPI_USER} \
		GRAPHITEAPI_GROUP=${GRAPHITEAPI_GROUP} \
		GRAPHITEAPI_LOGDIR=${GRAPHITEAPI_LOGDIR} \
		GRAPHITEAPI_TMPDIR=${GRAPHITEAPI_TMPDIR} \
		GRAPHITEAPI_PIDFILE=${GRAPHITEAPI_PIDFILE}

PLIST_SUB=	GRAPHITEAPI_APP=${GRAPHITEAPI_APP} \
		GRAPHITEAPI_USER=${GRAPHITEAPI_USER} \
		GRAPHITEAPI_GROUP=${GRAPHITEAPI_GROUP} \
		GRAPHITEAPI_LOGDIR=${GRAPHITEAPI_LOGDIR} \
		GRAPHITEAPI_TMPDIR=${GRAPHITEAPI_TMPDIR} \
		GRAPHITEAPI_PIDFILE=${GRAPHITEAPI_PIDFILE}

GRAPHITEAPI_USER?=	carbon
GRAPHITEAPI_GROUP?=	carbon

LOCALSTATEDIR=	/var
USE_RC_SUBR=	${GRAPHITEAPI_APP}

GRAPHITEAPI_LOGDIR=	${LOCALSTATEDIR}/log/${GRAPHITEAPI_APP}
GRAPHITEAPI_TMPDIR=	${LOCALSTATEDIR}/run/${GRAPHITEAPI_APP}
GRAPHITEAPI_PIDFILE=	${LOCALSTATEDIR}/run/${GRAPHITEAPI_APP}/${GRAPHITEAPI_APP}.pid

post-install:
	${MKDIR} \
	    ${STAGEDIR}${ETCDIR} \
	    ${STAGEDIR}${GRAPHITEAPI_TMPDIR} \
	    ${STAGEDIR}${GRAPHITEAPI_LOGDIR}
	${INSTALL_DATA} \
	    ${FILESDIR}/${GRAPHITEAPI_APP}.yaml.sample \
	    ${STAGEDIR}${ETCDIR}/${GRAPHITEAPI_APP}.yaml.sample

.include <bsd.port.mk>
