git: aed26383cdf5 - main - deskutils/py-paperless-ngx: Fix document classifier hanging (2)

From: Michael Gmelin <grembo_at_FreeBSD.org>
Date: Tue, 28 May 2024 15:47:26 UTC
The branch main has been updated by grembo:

URL: https://cgit.FreeBSD.org/ports/commit/?id=aed26383cdf5928ed5f7642954123f8099b23920

commit aed26383cdf5928ed5f7642954123f8099b23920
Author:     Michael Gmelin <grembo@FreeBSD.org>
AuthorDate: 2024-05-28 15:44:24 +0000
Commit:     Michael Gmelin <grembo@FreeBSD.org>
CommitDate: 2024-05-28 15:45:50 +0000

    deskutils/py-paperless-ngx: Fix document classifier hanging (2)
    
    Turn paperless symlink into wrapper, this way OMP_NUM_THREADS=1 is
    also set when paperless is called outside rc scripts.
    
    PR:             279011
    Reported by:    freebsd.bugzilla@mail.tinsuke.com
---
 deskutils/py-paperless-ngx/Makefile                 |  8 +++-----
 deskutils/py-paperless-ngx/files/paperless-ngx.7.in | 13 ++++++-------
 deskutils/py-paperless-ngx/files/paperless.in       |  9 +++++++++
 3 files changed, 18 insertions(+), 12 deletions(-)

diff --git a/deskutils/py-paperless-ngx/Makefile b/deskutils/py-paperless-ngx/Makefile
index 59679a6776c3..cc2eff7e80ee 100644
--- a/deskutils/py-paperless-ngx/Makefile
+++ b/deskutils/py-paperless-ngx/Makefile
@@ -1,7 +1,7 @@
 PORTNAME=	paperless-ngx
 PORTVERSION=	2.7.2
 DISTVERSIONPREFIX=	v
-PORTREVISION=	3
+PORTREVISION=	4
 CATEGORIES=	deskutils python
 MASTER_SITES=	https://github.com/${PORTNAME}/${PORTNAME}/releases/download/${DISTVERSIONPREFIX}${DISTVERSION}/:webui \
 		GH:gh
@@ -83,7 +83,7 @@ CONFLICTS_INSTALL=	${PYTHON_PKGNAMEPREFIX}*paperless
 
 NO_ARCH=	yes
 
-SUB_FILES=	nginx.conf paperless-ngx.7 pkg-message README sshd_config
+SUB_FILES=	nginx.conf paperless paperless-ngx.7 pkg-message README sshd_config
 SUB_LIST=	CHOWN=${CHOWN} \
 		ECHO=${ECHO} \
 		EGREP=${EGREP} \
@@ -146,9 +146,7 @@ do-install:
 	@cd ${WRKSRC} && ${COPYTREE_SHARE} gunicorn.conf.py \
 		${STAGEDIR}${PYTHON_SITELIBDIR}/paperless
 	@${FIND} ${STAGEDIR}${PYTHON_SITELIBDIR} -name '*.orig' -delete
-	@${RLN} ${STAGEDIR}${PYTHON_SITELIBDIR}/paperless/manage.py \
-		${STAGEDIR}${PREFIX}/bin/paperless
-	@${CHMOD} +x ${STAGEDIR}${PREFIX}/bin/paperless
+	@cd ${WRKDIR} && ${INSTALL_SCRIPT} paperless ${STAGEDIR}${PREFIX}/bin
 	@${SED} -e 's|%%WWWDIR%%|${WWWDIR}|g;' \
 		${WRKSRC}/paperless.conf.example \
 		> ${STAGEDIR}${PREFIX}/etc/paperless.conf.sample
diff --git a/deskutils/py-paperless-ngx/files/paperless-ngx.7.in b/deskutils/py-paperless-ngx/files/paperless-ngx.7.in
index 6f771e4713e3..23bd7b42d9fb 100644
--- a/deskutils/py-paperless-ngx/files/paperless-ngx.7.in
+++ b/deskutils/py-paperless-ngx/files/paperless-ngx.7.in
@@ -23,7 +23,7 @@
 .\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 .\"
-.Dd April 24, 2024
+.Dd May 28, 2024
 .Dt PAPERLESS-NGX 7
 .Os
 .Sh NAME
@@ -59,14 +59,13 @@ For more information about using paperless-ngx, see
 the official paperless-ngx documentation
 .Pa ( https://docs.paperless-ngx.com ) .
 .Pp
-The package creates a symlink from
-.Pa %%PYTHONPREFIX_SITELIBDIR%%/paperless/manage.py
-to
+The package creates a wrapper
 .Pa %%PREFIX%%/bin/paperless
-for convenience reasons, so whenever the official
-documentation mentions
+which in turn calls
+.Pa %%PYTHONPREFIX_SITELIBDIR%%/paperless/manage.py ,
+so whenever the official documentation mentions
 .Em manage.py
-it can be substituted with
+it should be substituted with
 .Pa %%PREFIX%%/bin/paperless
 or simply
 .Pa paperless .
diff --git a/deskutils/py-paperless-ngx/files/paperless.in b/deskutils/py-paperless-ngx/files/paperless.in
new file mode 100644
index 000000000000..5753e5d4e003
--- /dev/null
+++ b/deskutils/py-paperless-ngx/files/paperless.in
@@ -0,0 +1,9 @@
+#!/bin/sh
+
+set -e
+
+export OMP_NUM_THREADS=1
+exec \
+  %%PYTHON_CMD%% \
+  %%PYTHONPREFIX_SITELIBDIR%%/paperless/manage.py \
+  "$@"