git: ba6612833358 - main - www/py-calibreweb: add new port

From: Dries Michiels <driesm_at_FreeBSD.org>
Date: Mon, 09 Dec 2024 17:03:15 UTC
The branch main has been updated by driesm:

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

commit ba6612833358392e3fe2b1472143eec622033dad
Author:     Matthew Wener <matthew@wener.org>
AuthorDate: 2024-11-28 20:06:14 +0000
Commit:     Dries Michiels <driesm@FreeBSD.org>
CommitDate: 2024-12-09 17:01:59 +0000

    www/py-calibreweb: add new port
    
    Web app that offers an interface for browsing a Calibre Library DB.
    
    PR:     281304
---
 GIDs                                   |   2 +-
 UIDs                                   |   2 +-
 www/Makefile                           |   1 +
 www/py-calibreweb/Makefile             | 141 +++++++++++++++++++++++++++++++++
 www/py-calibreweb/distinfo             |   5 ++
 www/py-calibreweb/files/calibreweb.in  |  91 +++++++++++++++++++++
 www/py-calibreweb/files/pkg-message.in |  17 ++++
 www/py-calibreweb/pkg-descr            |   3 +
 8 files changed, 260 insertions(+), 2 deletions(-)

diff --git a/GIDs b/GIDs
index c67f101c167d..eb55b2514514 100644
--- a/GIDs
+++ b/GIDs
@@ -752,7 +752,7 @@ bosun:*:807:
 clixon:*:808:
 # free: 809
 # free: 810
-# free: 811
+calibreweb:*:811:
 foreman_proxy:*:812:
 hitch:*:813:
 puppet:*:814:
diff --git a/UIDs b/UIDs
index 686c17aa217c..7248825ac5d4 100644
--- a/UIDs
+++ b/UIDs
@@ -758,7 +758,7 @@ bosun:*:807:807::0:0:Bosun Daemon:/nonexistent:/usr/sbin/nologin
 clixon:*:808:808::0:0:Clixon Daemon:/nonexistent:/usr/sbin/nologin
 # free: 809
 # free: 810
-# free: 811
+calibreweb:*:811:811::0:0:Calibre-Web Daemon:/nonexistent:/usr/sbin/nologin
 foreman_proxy:*:812:812::0:0:Foreman Smart Proxy:/usr/local/share/foreman-proxy:/usr/sbin/nologin
 hitch:*:813:813::0:0:Hitch TLS Proxy:/nonexistent:/usr/sbin/nologin
 puppet:*:814:814::0:0:Puppet Daemon:/nonexistent:/usr/sbin/nologin
diff --git a/www/Makefile b/www/Makefile
index 9ec54a0f8dab..542d1376ea1c 100644
--- a/www/Makefile
+++ b/www/Makefile
@@ -1486,6 +1486,7 @@
     SUBDIR += py-cachecontrol
     SUBDIR += py-cachelib
     SUBDIR += py-caldav
+    SUBDIR += py-calibreweb
     SUBDIR += py-channels
     SUBDIR += py-channels-redis
     SUBDIR += py-cheroot
diff --git a/www/py-calibreweb/Makefile b/www/py-calibreweb/Makefile
new file mode 100644
index 000000000000..876936ff2b27
--- /dev/null
+++ b/www/py-calibreweb/Makefile
@@ -0,0 +1,141 @@
+PORTNAME=	calibreweb
+PORTVERSION=	0.6.24
+CATEGORIES=	www python
+MASTER_SITES=	PYPI
+PKGNAMEPREFIX=	${PYTHON_PKGNAMEPREFIX}
+
+PATCH_SITES=	https://github.com/janeczku/calibre-web/commit/
+PATCHFILES=	f493d4e4e521b99964c0b2a744d54390fc3b663e.patch:-p1
+
+MAINTAINER=	matthew@wener.org
+COMMENT=	Web interface for viewing and downloading eBooks from a Calibre DB
+WWW=		https://github.com/janeczku/calibre-web
+
+LICENSE=	GPLv3
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+BUILD_DEPENDS=	${PY_SETUPTOOLS} \
+		${PYTHON_PKGNAMEPREFIX}wheel>=0:devel/py-wheel@${PY_FLAVOR}
+RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}APScheduler>=0:devel/py-apscheduler@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}bleach>=0:www/py-bleach@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}chardet>=0:textproc/py-chardet@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}flask-babel>=0:devel/py-flask-babel@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}Flask-HTTPAuth>=0:security/py-flask-httpauth@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}Flask-Principal>=0:www/py-flask-principal@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}flask_limiter>=0:www/py-flask-limiter@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}flask_wtf>=0:www/py-flask-wtf@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}iso-639>=0:textproc/py-iso-639@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}lxml>=0:devel/py-lxml@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}netifaces-plus>=0:net/py-netifaces-plus@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}pypdf>=0:print/py-pypdf@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}python-magic>=0:devel/py-python-magic@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}regex>=0:textproc/py-regex@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}requests>=0:www/py-requests@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}sqlite3>=0:databases/py-sqlite3@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}tornado>=0:www/py-tornado@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}unidecode>=0:converters/py-unidecode@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}urllib3>=0:net/py-urllib3@${PY_FLAVOR} \
+		${PYTHON_PKGNAMEPREFIX}Wand>=0:graphics/py-wand@${PY_FLAVOR}
+
+USES=		python
+USE_PYTHON=	autoplist pep517
+USE_RC_SUBR=	${PORTNAME}
+
+NO_ARCH=	yes
+
+SUB_FILES=	pkg-message
+SUB_LIST=	GROUP=${GROUPS} \
+		PORTNAME=${PORTNAME} \
+		PYTHON_CMD=${PYTHON_CMD} \
+		RC_NAME=calibreweb \
+		USER=${USERS}
+PATCH_WRKSRC=	${WRKSRC}/src/calibreweb
+
+USERS=		${PORTNAME}
+GROUPS=		${PORTNAME}
+
+POST_PLIST=	fix-plist
+PORTDOCS=	PKG-INFO README.md
+
+OPTIONS_DEFINE=		CALIBRE COMICS DOCS GDRIVE GMAIL GREADS KOBO LDAP \
+			METADATA OAUTH
+OPTIONS_DEFAULT=	IMAGICK7_X11 SQLA20
+
+OPTIONS_SINGLE=		IMAGICK SQLA
+OPTIONS_SINGLE_IMAGICK=	IMAGICK6_NOX11 IMAGICK6_X11 IMAGICK7_NOX11 IMAGICK7_X11
+OPTIONS_SINGLE_SQLA=	SQLA14 SQLA20
+
+CALIBRE_DESC=		Calibre Desktop Conversion and Metadata Editing
+COMICS_DESC=		Comic Metadata Support
+GDRIVE_DESC=		Google Drive Support
+GMAIL_DESC=		GMail
+GREADS_DESC=		Goodreads API
+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
+IMAGICK_DESC=		${IMAGEMAGICK_DESC}
+KOBO_DESC=		Kobo Device Support
+LDAP_DESC=		LDAP Login Support
+METADATA_DESC=		Metadata Extraction Support
+OAUTH_DESC=		OAuth Login
+SQLA14_DESC=		Use SQLAlchemy 1.4.*
+SQLA20_DESC=		Use SQLAlchemy 2.0.*
+SQLA_DESC=		SQLAchemy Database Toolkit for Python
+
+CALIBRE_RUN_DEPENDS=	calibre>=0:deskutils/calibre
+COMICS_RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}comicapi>=0:archivers/py-comicapi@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}natsort>=0:devel/py-natsort@${PY_FLAVOR}
+GDRIVE_RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}gevent>=0:devel/py-gevent@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}google-api-python-client>=0:www/py-google-api-python-client@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}google-auth-httplib2>=0:security/py-google-auth-httplib2@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}greenlet>=0:devel/py-greenlet@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}oauth2client>=0:security/py-oauth2client@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}pyasn1-modules>=0:devel/py-pyasn1-modules@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}PyDrive2>=0:www/py-pydrive2@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}pyyaml>=0:devel/py-pyyaml@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}rsa>=0:security/py-rsa@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}uritemplate>=0:net/py-uritemplate@${PY_FLAVOR}
+GMAIL_RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}google-api-python-client>=0:www/py-google-api-python-client@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}google-auth-oauthlib>=0:security/py-google-auth-oauthlib@${PY_FLAVOR}
+GREADS_RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}Goodreads>=0:devel/py-goodreads@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}Levenshtein>=0:devel/py-Levenshtein@${PY_FLAVOR}
+IMAGICK6_NOX11_USES=	magick:6,run,nox11
+IMAGICK6_X11_USES=	magick:6,run
+IMAGICK7_NOX11_USES=	magick:7,run,nox11
+IMAGICK7_X11_USES=	magick:7,run
+KOBO_RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}jsonschema>=0:devel/py-jsonschema@${PY_FLAVOR} \
+			kepubify>=0:textproc/kepubify
+LDAP_RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}Flask-SimpleLDAP>=0:www/py-flask-simpleldap@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}python-ldap>=0:net/py-python-ldap@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}sqlalchemy-utils>=0:databases/py-sqlalchemy-utils@${PY_FLAVOR}
+METADATA_RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}beautifulsoup>=0:www/py-beautifulsoup@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}faust-cchardet>=0:textproc/py-faust-cchardet@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}html2text>=0:textproc/py-html2text@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}markdown2>=0:textproc/py-markdown2@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}mutagen>=0:audio/py-mutagen@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}py7zr>=0:archivers/py-py7zr@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}pycountry>=0:textproc/py-pycountry@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}python-dateutil>=0:devel/py-python-dateutil@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}rarfile>=0:archivers/py-rarfile@${PY_FLAVOR} \
+			${PYTHON_PKGNAMEPREFIX}scholarly>=0:devel/py-scholarly@${PY_FLAVOR} \
+			unrar>=0:archivers/unrar
+OAUTH_RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}flask-dance>=0:www/py-flask-dance@${PY_FLAVOR}
+SQLA14_RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}sqlalchemy14>=0:databases/py-sqlalchemy14@${PY_FLAVOR}
+SQLA20_RUN_DEPENDS=	${PYTHON_PKGNAMEPREFIX}sqlalchemy20>=0:databases/py-sqlalchemy20@${PY_FLAVOR}
+
+post-patch:
+	${FIND} ${PATCH_WRKSRC} -name '*.orig' -delete
+
+pre-install-DOCS-on:
+	@${MKDIR} ${STAGEDIR}${DOCSDIR}/
+	${INSTALL_DATA} ${PORTDOCS:S,^,${WRKSRC}/,} ${STAGEDIR}${DOCSDIR}
+
+post-install:
+# Remove .HOMEDIR so we can specify the location for the config files
+	(cd ${STAGEDIR}${PYTHONPREFIX_SITELIBDIR}/calibreweb/cps && ${RM} .HOMEDIR)
+
+fix-plist:
+	@${REINPLACE_CMD} -e "s|.*HOMEDIR$$||" ${TMPPLIST}
+
+.include <bsd.port.mk>
diff --git a/www/py-calibreweb/distinfo b/www/py-calibreweb/distinfo
new file mode 100644
index 000000000000..bc6e49d75283
--- /dev/null
+++ b/www/py-calibreweb/distinfo
@@ -0,0 +1,5 @@
+TIMESTAMP = 1731942101
+SHA256 (calibreweb-0.6.24.tar.gz) = 883c956ceb93a9bfa758428904d4122e64a1cf4778e5b6df14b8e50f465b6f9e
+SIZE (calibreweb-0.6.24.tar.gz) = 7126198
+SHA256 (f493d4e4e521b99964c0b2a744d54390fc3b663e.patch) = 38a80e7ab18d5f06216b5b0b3fbe45d7cd59c3d43aecea2eb4ba9510d6f118ca
+SIZE (f493d4e4e521b99964c0b2a744d54390fc3b663e.patch) = 1748
diff --git a/www/py-calibreweb/files/calibreweb.in b/www/py-calibreweb/files/calibreweb.in
new file mode 100644
index 000000000000..ba413bc6e6ff
--- /dev/null
+++ b/www/py-calibreweb/files/calibreweb.in
@@ -0,0 +1,91 @@
+#!/bin/sh
+#
+# PROVIDE: %%PORTNAME%%
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+#
+# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
+# to enable this service:
+#
+# %%RC_NAME%%_enable (bool):        Set to NO by default.
+#                       Set it to YES to enable it.
+# %%RC_NAME%%_ip_addr:      IP Address used to listen for connections
+#                       Default: 0.0.0.0
+# %%RC_NAME%%_conf_dir:     Directory where %%RC_NAME%% configuration
+#                       data is stored.
+#                       Default: %%PREFIX%%/%%RC_NAME%%
+# %%RC_NAME%%_settings:     Directory and file name of %%RC_NAME%% settings
+#                       db is stored.
+#                       Default: %%PREFIX%%/%%RC_NAME%%/app.db
+# %%RC_NAME%%_gdrive:       Directory and file name of %%RC_NAME%% gdrive
+#                       db is stored.
+#                       Default: %%PREFIX%%/%%RC_NAME%%/gdrive.db
+# %%RC_NAME%%_cert:         Directory and file name of %%RC_NAME%% gdrive
+#                       db is stored.
+#                       Default: None
+# %%RC_NAME%%_key:          Directory and file name of %%RC_NAME%% gdrive
+#                       db is stored.
+#                       Default: None
+# %%RC_NAME%%_flags:        Additonal flags as needed
+#                       Default: None
+# %%RC_NAME%%_user:         The user account %%RC_NAME%% daemon runs as what
+#                       you want it to be. It uses '%%RC_NAME%%' user by
+#                       default. Do not set it as empty or it will run
+#                       as root.
+# %%RC_NAME%%_group:        The group account %%RC_NAME%% daemon runs as what
+#                       you want it to be. It uses '%%RC_NAME%%' group by
+#                       default. Do not set it as empty or it will run
+#                       as wheel.
+# %%RC_NAME%%_pid:      Set the name of the %%RC_NAME%% pidfile
+#                       Default: %%PORTNAME%%.pid
+# %%RC_NAME%%_pid_dir:      Set the directory of the %%RC_NAME%% pidfile
+#                       Default: /var/run/%%PORTNAME%%
+# %%RC_NAME%%_log:      Set the name of the %%RC_NAME%% logfile
+#                       Default: %%PORTNAME%%.log
+# %%RC_NAME%%_log_dir:      Set the directory of the %%RC_NAME%% logfile
+#                       Default: /var/log/%%PORTNAME%%
+
+. /etc/rc.subr
+
+name=%%RC_NAME%%
+rcvar=%%RC_NAME%%_enable
+load_rc_config ${name}
+
+: ${%%RC_NAME%%_enable:=NO}
+: ${%%RC_NAME%%_user:=%%USER%%}
+: ${%%RC_NAME%%_group:=%%GROUP%%}
+: ${%%RC_NAME%%_ip_addr="0.0.0.0"}
+: ${%%RC_NAME%%_conf_dir="%%DATADIR%%"}
+: ${%%RC_NAME%%_settings="${%%RC_NAME%%_conf_dir}/app.db"}
+: ${%%RC_NAME%%_gdrive="${%%RC_NAME%%_conf_dir}/gdrive.db"}
+: ${%%RC_NAME%%_pid:="%%PORTNAME%%.pid"}
+: ${%%RC_NAME%%_pid_dir:="/var/run/%%PORTNAME%%"}
+: ${%%RC_NAME%%_log:="%%PORTNAME%%.log"}
+: ${%%RC_NAME%%_log_dir:="/var/log/%%PORTNAME%%"}
+
+pidfile=${%%RC_NAME%%_pid_dir}/${%%RC_NAME%%_pid}
+logfile=${%%RC_NAME%%_log_dir}/${%%RC_NAME%%_log}
+
+start_precmd="${name}_prestart"
+
+procname="%%PREFIX%%/bin/cps"
+command_interpreter="%%PYTHON_CMD%%"
+command="/usr/sbin/daemon"
+command_args="-p $pidfile $procname \
+		-i ${%%RC_NAME%%_ip_addr} \
+		-p ${%%RC_NAME%%_settings} \
+		-g ${%%RC_NAME%%_gdrive} \
+		${%%RC_NAME%%_cert:+-c ${%%RC_NAME%%_cert}} \
+		${%%RC_NAME%%_key:+-k ${%%RC_NAME%%_key}} \
+		-o $logfile"
+
+%%RC_NAME%%_prestart()
+{
+	PATH=${PATH}:%%PREFIX%%/bin:%%PREFIX%%/sbin
+
+	for calwebdir in ${%%RC_NAME%%_pid_dir} ${%%RC_NAME%%_log_dir} ${%%RC_NAME%%_conf_dir}; do
+		[ -d ${calwebdir} ] || install -d -g ${%%RC_NAME%%_group} -o ${%%RC_NAME%%_user} ${calwebdir}
+	done
+}
+
+run_rc_command $1
diff --git a/www/py-calibreweb/files/pkg-message.in b/www/py-calibreweb/files/pkg-message.in
new file mode 100644
index 000000000000..60247f520aec
--- /dev/null
+++ b/www/py-calibreweb/files/pkg-message.in
@@ -0,0 +1,17 @@
+[
+{ type: install
+  message: <<EOM
+To automatically start Calibre-Web at boot time:
+# sysrc calibreweb_enable="YES"
+
+To then manually start Calibre-Web without rebooting:
+# service calibreweb start
+
+Once started, visit the following webpage to configure:
+http://localhost:8083/
+
+Default User: admin
+Default Password: admin123
+EOM
+}
+]
diff --git a/www/py-calibreweb/pkg-descr b/www/py-calibreweb/pkg-descr
new file mode 100644
index 000000000000..0ab892da00d7
--- /dev/null
+++ b/www/py-calibreweb/pkg-descr
@@ -0,0 +1,3 @@
+Calibre-Web is a web app that offers a clean and intuitive
+interface for browsing, reading, and downloading eBooks using
+a valid Calibre database.