summaryrefslogtreecommitdiff
path: root/deskutils/py-paperless/Makefile
blob: b9b629b22f1f257de7446021936d1c43a84c818b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135

PORTNAME=	paperless
PORTVERSION=	2.7.0
PORTREVISION=	9
CATEGORIES=	deskutils python
PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}

PATCH_SITES=	https://github.com/${GH_ACCOUNT}/${GH_PROJECT}/commit/
PATCHFILES+=	b122931185fb.patch:-p1 # https://github.com/the-paperless-project/paperless/pull/712
PATCHFILES+=	b131c97d1d85.patch:-p1 # https://github.com/the-paperless-project/paperless/pull/716

MAINTAINER=	grembo@FreeBSD.org
COMMENT=	Index and archive scanned paper documents

LICENSE=	GPLv3
LICENSE_FILE=	${WRKSRC}/LICENSE

BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}dateparser>=0.7.1:devel/py-dateparser@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}django-cors-headers>=2.4.0:www/py-django-cors-headers@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}django-crispy-forms>=1.7.2:www/py-django-crispy-forms@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}django-extensions>=2.1.6:www/py-django-extensions@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}django-filter>=2.0.0:www/py-django-filter@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}djangoql>=0.12.4:www/py-djangoql@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}djangorestframework>=3.9.0:www/py-djangorestframework@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}fuzzywuzzy>=0.15.1:devel/py-fuzzywuzzy@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}langdetect>=1.0.7:textproc/py-langdetect@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}pdftotext>=2.1.1:textproc/py-pdftotext@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}pyocr>=0.5.3:graphics/py-pyocr@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}python-dotenv>=0.10.1:www/py-python-dotenv@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}python-gnupg>=0.4.3:security/py-python-gnupg@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}python-magic>=0.4.10:devel/py-python-magic@${PY_FLAVOR} \
		${PYTHON_PKGNAMEPREFIX}sqlite3>0:databases/py-sqlite3@${PY_FLAVOR}
RUN_DEPENDS:=	${BUILD_DEPENDS}
RUN_DEPENDS+=	gpg2:security/gnupg \
		optipng:graphics/optipng \
		tesseract:graphics/tesseract \
		unpaper:graphics/unpaper

USES=		python:3.5+ shebangfix
USE_GITHUB=	yes
GH_ACCOUNT=	the-paperless-project
GH_PROJECT=	paperless
USE_RC_SUBR=	paperless-consumer

SHEBANG_FILES=	${WRKSRC}/src/manage.py

SUB_FILES=	README nginx.conf paperless.7 pkg-message sshd_config uwsgi.ini
SUB_LIST=	PKGBASE=${PKGBASE} PYTHON_CMD=${PYTHON_CMD} \
		PYTHONPREFIX_SITELIBDIR=${PYTHONPREFIX_SITELIBDIR} \
		ECHO=${ECHO} EGREP=${EGREP} TOUCH=${TOUCH} \
		CHOWN=${CHOWN} RM=${RM:Q}

NO_ARCH=	yes

USERS=		paperless
GROUPS=		paperless

OPTIONS_DEFINE=		DOCS EXAMPLES
OPTIONS_SINGLE=		IMAGICK
OPTIONS_SINGLE_IMAGICK=	IMAGICK6_NOX11 IMAGICK6_X11 IMAGICK7_NOX11 IMAGICK7_X11
OPTIONS_DEFAULT=	IMAGICK6_X11

IMAGICK_DESC=		${IMAGEMAGICK_DESC}
IMAGICK6_NOX11_DESC=	ImageMagick6 without X11 support
IMAGICK6_X11_DESC=	ImageMagick6 with X11 support
IMAGICK7_NOX11_DESC=	ImageMagick7 without X11 support
IMAGICK7_X11_DESC=	ImageMagick7 with X11 support

DOCS_BUILD_DEPENDS=	${PYTHON_PKGNAMEPREFIX}sphinx>=1.8.3,1:textproc/py-sphinx@${PY_FLAVOR}
DOCS_USES=		gmake

IMAGICK6_X11_RUN_DEPENDS=	convert:graphics/ImageMagick6
IMAGICK6_NOX11_RUN_DEPENDS=	convert:graphics/ImageMagick6-nox11
IMAGICK7_X11_RUN_DEPENDS=	convert:graphics/ImageMagick7
IMAGICK7_NOX11_RUN_DEPENDS=	convert:graphics/ImageMagick7-nox11

PORTDOCS=	*

PAPERLESS_STATICDIR=	${WRKSRC}/static

do-build:
	@${PYTHON_CMD} ${PYTHON_LIBDIR}/compileall.py \
		-d ${PYTHONPREFIX_SITELIBDIR} \
		-f ${WRKSRC}/src
	@${PYTHON_CMD} -O ${PYTHON_LIBDIR}/compileall.py \
		-d ${PYTHONPREFIX_SITELIBDIR} \
		-f ${WRKSRC}/src
	@${RM} -r ${PAPERLESS_STATICDIR}
	@${SETENV} \
		PAPERLESS_STATICDIR=${PAPERLESS_STATICDIR} \
		${PYTHON_CMD} ${WRKSRC}/src/manage.py collectstatic

do-build-DOCS-on:
	cd ${WRKSRC}/docs && ${SETENV} ${MAKE_ENV} \
		${MAKE_CMD} ${MAKE_ARGS} html SPHINXBUILD=sphinx-build-${PYTHON_VER}

post-build-DOCS-on:
	@${RM} ${WRKSRC}/docs/_build/html/.buildinfo

do-install:
	@${MKDIR} ${STAGEDIR}${PYTHON_SITELIBDIR}/paperless
	@cd ${WRKSRC}/resources && \
		${COPYTREE_SHARE} . ${STAGEDIR}${DATADIR}
	@cd ${WRKSRC}/src && \
		${COPYTREE_SHARE} . ${STAGEDIR}${PYTHON_SITELIBDIR}/paperless
	@${RLN} ${STAGEDIR}${PYTHON_SITELIBDIR}/paperless/manage.py \
		${STAGEDIR}${PREFIX}/bin/paperless
	@${MKDIR} ${STAGEDIR}${WWWDIR}
	@cd ${WRKSRC} && \
		${COPYTREE_SHARE} static ${STAGEDIR}${WWWDIR}
	@${SED} -e 's|%%WWWDIR%%|${WWWDIR}|g;' \
		${WRKSRC}/paperless.conf.example \
		> ${STAGEDIR}${PREFIX}/etc/paperless.conf.sample
	@${MKDIR} ${STAGEDIR}/var/db/paperless/consume/input \
		${STAGEDIR}/var/db/paperless/media \
		${STAGEDIR}/var/db/paperless/sqlite
	${INSTALL_MAN} ${WRKDIR}/paperless.7 ${STAGEDIR}${MANPREFIX}/man/man7

post-install-DOCS-on:
	@${MKDIR} ${STAGEDIR}${DOCSDIR}/presentation
	@cd ${WRKSRC}/docs/_build/html && \
		${COPYTREE_SHARE} . ${STAGEDIR}${DOCSDIR}
	@cd ${WRKSRC}/presentation && \
		${COPYTREE_SHARE} . ${STAGEDIR}${DOCSDIR}/presentation

post-install-EXAMPLES-on:
	@${MKDIR} ${STAGEDIR}${EXAMPLESDIR}
	${INSTALL_DATA} \
		${WRKDIR}/README \
		${WRKDIR}/nginx.conf \
		${WRKDIR}/sshd_config \
		${WRKDIR}/uwsgi.ini \
		${STAGEDIR}${EXAMPLESDIR}

.include <bsd.port.mk>