git: 0b7b6fa1b00c - main - print/sioyek: new port

From: Robert Clausecker <fuz_at_FreeBSD.org>
Date: Mon, 06 Mar 2023 22:24:02 UTC
The branch main has been updated by fuz:

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

commit 0b7b6fa1b00c114d8a8674e4d1504de28f043fdd
Author:     Robert Clausecker <fuz@FreeBSD.org>
AuthorDate: 2023-03-04 14:09:18 +0000
Commit:     Robert Clausecker <fuz@FreeBSD.org>
CommitDate: 2023-03-06 22:23:43 +0000

    print/sioyek: new port
    
    Sioyek is a PDF viewer with a focus on technical books and research
    papers.
    
    WWW: https://sioyek.info
    
     - unbundled mupdf and sqlite3 dependencies
    
    Requested by:   reddit user /u/cargolax
---
 print/Makefile                                     |  1 +
 print/sioyek/Makefile                              | 40 ++++++++++++++++++++++
 print/sioyek/distinfo                              |  3 ++
 .../files/patch-pdf__viewer__build__config.pro     | 28 +++++++++++++++
 print/sioyek/files/patch-pdf__viewer_main.cpp      | 22 ++++++++++++
 print/sioyek/files/patch-pdf__viewer_utils.cpp     | 11 ++++++
 print/sioyek/pkg-descr                             | 36 +++++++++++++++++++
 print/sioyek/pkg-plist                             | 19 ++++++++++
 8 files changed, 160 insertions(+)

diff --git a/print/Makefile b/print/Makefile
index 7b3b608a4c7f..b20e01b15ae9 100644
--- a/print/Makefile
+++ b/print/Makefile
@@ -232,6 +232,7 @@
     SUBDIR += sgf2tex
     SUBDIR += shrinkpdf
     SUBDIR += simple-fb2-reader
+    SUBDIR += sioyek
     SUBDIR += splix
     SUBDIR += system-config-printer
     SUBDIR += t1utils
diff --git a/print/sioyek/Makefile b/print/sioyek/Makefile
new file mode 100644
index 000000000000..7bf63885e131
--- /dev/null
+++ b/print/sioyek/Makefile
@@ -0,0 +1,40 @@
+PORTNAME=	sioyek
+DISTVERSIONPREFIX=	v
+DISTVERSION=	2.0.0
+CATEGORIES=	print
+
+MAINTAINER=	fuz@FreeBSD.org
+COMMENT=	PDF viewer with focus on technical books and research papers
+WWW=		https://sioyek.info
+
+LICENSE=	GPLv3
+LICENSE_FILE=	${WRKSRC}/LICENSE
+
+LIB_DEPENDS=	libmupdf.so:graphics/mupdf \
+		libharfbuzz.so:print/harfbuzz \
+		libfreetype.so:print/freetype2 \
+		libjbig2dec.so:graphics/jbig2dec \
+		libmujs.so:lang/mujs \
+		libopenjp2.so:graphics/openjpeg
+
+USES=		desktop-file-utils jpeg gl qmake qt:5 sqlite
+USE_GITHUB=	yes
+GH_ACCOUNT=	ahrm
+USE_GL=		gl
+USE_QT=		3d buildtools:build core gui network opengl widgets
+
+post-extract:
+.for f in sqlite3.h sqlite3ext.h sqlite3.c shell.c
+	${RM} ${WRKSRC}/pdf_viewer/$f
+.endfor
+
+pre-configure:
+	${REINPLACE_CMD} -e 's,%%ETCDIR%%,${ETCDIR},' \
+		-e 's,%%DATADIR%%,${DATADIR},' ${WRKSRC}/pdf_viewer/main.cpp
+
+post-install:
+.for f in keys prefs
+	${MV} ${STAGEDIR}${ETCDIR}/$f.config ${STAGEDIR}${ETCDIR}/$f.config.sample
+.endfor
+
+.include <bsd.port.mk>
diff --git a/print/sioyek/distinfo b/print/sioyek/distinfo
new file mode 100644
index 000000000000..74be77e7dd4f
--- /dev/null
+++ b/print/sioyek/distinfo
@@ -0,0 +1,3 @@
+TIMESTAMP = 1677891935
+SHA256 (ahrm-sioyek-v2.0.0_GH0.tar.gz) = 92398b6da5e297c59f22cd3c6b562194846f28bc17bb4ae9432869aafeb5df17
+SIZE (ahrm-sioyek-v2.0.0_GH0.tar.gz) = 4900368
diff --git a/print/sioyek/files/patch-pdf__viewer__build__config.pro b/print/sioyek/files/patch-pdf__viewer__build__config.pro
new file mode 100644
index 000000000000..c70267963043
--- /dev/null
+++ b/print/sioyek/files/patch-pdf__viewer__build__config.pro
@@ -0,0 +1,28 @@
+--- pdf_viewer_build_config.pro.orig	2022-12-16 16:06:01 UTC
++++ pdf_viewer_build_config.pro
+@@ -28,8 +28,6 @@ HEADERS += pdf_viewer/book.h \
+            pdf_viewer/checksum.h \
+            pdf_viewer/new_file_checker.h \
+            pdf_viewer/coordinates.h \
+-           pdf_viewer/sqlite3.h \
+-           pdf_viewer/sqlite3ext.h \
+            pdf_viewer/ui.h \
+            pdf_viewer/path.h \
+            pdf_viewer/utf8.h \
+@@ -55,7 +53,6 @@ SOURCES += pdf_viewer/book.cpp \
+            pdf_viewer/checksum.cpp \
+            pdf_viewer/new_file_checker.cpp \
+            pdf_viewer/coordinates.cpp \
+-           pdf_viewer/sqlite3.c \
+            pdf_viewer/ui.cpp \
+            pdf_viewer/path.cpp \
+            pdf_viewer/utils.cpp \
+@@ -82,7 +79,7 @@ unix:!mac {
+     } else {
+         DEFINES += NON_PORTABLE
+         DEFINES += LINUX_STANDARD_PATHS
+-        LIBS += -ldl -lmupdf -lmupdf-third -lgumbo -lharfbuzz -lfreetype -ljbig2dec -ljpeg -lmujs -lopenjp2 -lz
++        LIBS += -ldl -lmupdf -lmupdf-third -lharfbuzz -lfreetype -ljbig2dec -ljpeg -lmujs -lopenjp2 -lz -lsqlite3
+     }
+ 
+     isEmpty(PREFIX){
diff --git a/print/sioyek/files/patch-pdf__viewer_main.cpp b/print/sioyek/files/patch-pdf__viewer_main.cpp
new file mode 100644
index 000000000000..2fb5adc397e4
--- /dev/null
+++ b/print/sioyek/files/patch-pdf__viewer_main.cpp
@@ -0,0 +1,22 @@
+--- pdf_viewer/main.cpp.orig	2023-03-04 14:34:21 UTC
++++ pdf_viewer/main.cpp
+@@ -296,7 +296,7 @@ void configure_paths(){
+ 	user_config_paths.push_back(mac_standard_config_path.slash(L"prefs_user.config"));
+ #endif
+ 
+-#ifdef Q_OS_LINUX
++#if defined(Q_OS_LINUX) || defined(Q_OS_FREEBSD)
+ 	QStringList all_config_paths = QStandardPaths::standardLocations(QStandardPaths::AppConfigLocation);
+ 	for (int i = all_config_paths.size()-1; i >= 0; i--) {
+ 		user_config_paths.push_back(Path(all_config_paths.at(i).toStdWString()).slash(L"prefs_user.config"));
+@@ -306,8 +306,8 @@ void configure_paths(){
+ #ifdef LINUX_STANDARD_PATHS
+ 	Path home_path(QDir::homePath().toStdWString());
+ 	Path standard_data_path = home_path.slash(L".local").slash(L"share").slash(L"sioyek");
+-	Path standard_config_path = Path(L"/etc/sioyek");
+-	Path read_only_data_path = Path(L"/usr/share/sioyek");
++	Path standard_config_path = Path(L"%%ETCDIR%%");
++	Path read_only_data_path = Path(L"%%DATADIR%%");
+ 	standard_data_path.create_directories();
+ 
+ 	default_config_path = standard_config_path.slash(L"prefs.config");
diff --git a/print/sioyek/files/patch-pdf__viewer_utils.cpp b/print/sioyek/files/patch-pdf__viewer_utils.cpp
new file mode 100644
index 000000000000..f5214ad89f03
--- /dev/null
+++ b/print/sioyek/files/patch-pdf__viewer_utils.cpp
@@ -0,0 +1,11 @@
+--- pdf_viewer/utils.cpp.orig	2023-03-04 13:46:24 UTC
++++ pdf_viewer/utils.cpp
+@@ -1194,7 +1194,7 @@ void sleep_ms(unsigned int ms) {
+ #ifdef Q_OS_WIN
+ 	Sleep(ms);
+ #else
+-	struct timespec ts = { ms / 1000, (ms % 1000) * 1000 * 1000 };
++	struct timespec ts = { static_cast<time_t>(ms / 1000), static_cast<long>((ms % 1000) * 1000 * 1000) };
+ 	nanosleep(&ts, NULL);
+ #endif
+ }
diff --git a/print/sioyek/pkg-descr b/print/sioyek/pkg-descr
new file mode 100644
index 000000000000..97cdabd10541
--- /dev/null
+++ b/print/sioyek/pkg-descr
@@ -0,0 +1,36 @@
+Sioyek is a PDF viewer with a focus on technical books and research papers.
+
+Searchable
+	Quickly search your previously opened documents, table of
+	contents, bookmarks, and highlights.  Sioyek can even generate
+	the table of contents if the document doesn't have one!
+
+Smart Jump
+	You can preview or jump to references (e.g. bibliography, figures,
+	equations, etc.) even when the document doesn't have links.  You
+	can also search references in google scholar with one click!
+
+Portals
+	You can create portals from parts of documents to other parts
+	displayed in a second window.  So when you are reading a paragraph
+	that is talking about a figure, table, algorithm, theorem, etc.
+	you don't have to keep jumping between the two locations.
+
+Marks and Bookmarks
+	Mark locations with one-character symbols and then quickly jump
+	back to them. You can also create bookmarks which are like marks,
+	but use a descriptive text instead of a symbol and can be searched.
+
+Keyboard Focused
+	While sioyek fully supports many mouse actions, it is still
+	possible to use sioyek only using a keyboard. This includes
+	functionality such as text selection too!
+
+Synctex
+	Sioyek autoreloads the document so you can preview the changes
+	as you edit the latex file. You can also jump between the
+	corresponding locations in PDF and latex files with one click.
+
+Other features include configurability, extensibility with external
+commands and scripts, text highlighting, a discoverable command palette,
+and a visual ruler highlighting the current line.
diff --git a/print/sioyek/pkg-plist b/print/sioyek/pkg-plist
new file mode 100644
index 000000000000..405d13c1b80c
--- /dev/null
+++ b/print/sioyek/pkg-plist
@@ -0,0 +1,19 @@
+bin/sioyek
+@sample %%ETCDIR%%/keys.config.sample
+@sample %%ETCDIR%%/prefs.config.sample
+share/applications/sioyek.desktop
+share/pixmaps/sioyek-icon-linux.png
+%%DATADIR%%/shaders/custom_colors.fragment
+%%DATADIR%%/shaders/dark_mode.fragment
+%%DATADIR%%/shaders/debug.fragment
+%%DATADIR%%/shaders/highlight.fragment
+%%DATADIR%%/shaders/separator.fragment
+%%DATADIR%%/shaders/simple.fragment
+%%DATADIR%%/shaders/simple.vertex
+%%DATADIR%%/shaders/stencil.fragment
+%%DATADIR%%/shaders/stencil.vertex
+%%DATADIR%%/shaders/undendered_page.fragment
+%%DATADIR%%/shaders/unrendered_page.fragment
+%%DATADIR%%/shaders/vertical_bar.fragment
+%%DATADIR%%/shaders/vertical_bar_dark.fragment
+%%DATADIR%%/tutorial.pdf