packages: sioyek: Add broken packaging of sioyek

sioyek
Luis Guilherme Coelho 2024-02-17 20:15:06 -03:00
parent cab512e17f
commit ea380bd2c1
No known key found for this signature in database
GPG Key ID: 1F2E76ACE3F531C8
2 changed files with 173 additions and 0 deletions

View File

@ -0,0 +1,98 @@
diff --git a/community/sioyek/APKBUILD b/community/sioyek/APKBUILD
index 283f5d2287a..8f4316d9769 100644
--- a/community/sioyek/APKBUILD
+++ b/community/sioyek/APKBUILD
@@ -16,6 +16,7 @@ makedepends="
subpackages="$pkgname-doc"
source="https://github.com/ahrm/sioyek/archive/v$pkgver/sioyek-$pkgver.tar.gz
fix-mupdf-libs.patch
+ mupdf-0.23.0.patch
$pkgname.desktop
"
options="!check" # no tests provided
@@ -39,5 +40,6 @@ package() {
sha512sums="
3ed9959ddbc133b9c7bb241f8076da886b74790a475646911dc6d38724160ae8335020db308e405c60fce49b9260536861e8946199f1670dc8c2331e9fbd2e00 sioyek-2.0.0.tar.gz
d2b802b75804a0986a2ad39b7609e503655780d96eec18e0f2dd378797f273d055d75265ad949f471b8befa287279be79e8b6215eb2ff63b168b574ca66d0e9c fix-mupdf-libs.patch
+9c8bdeca3e572df5c7587225148f816dcea7e7842340a8884c466a5504f0afb38cb86390538f64913d8f6f20208084dbe081abf91597f730f6ab3773108d4350 mupdf-0.23.0.patch
f2f227ae181d695da979c84444f2f53402d904b9c2ddab3bb589483ad98168365c15c2052eb2192defa2131a8c27eada2936e82e1b8c3f37b86abd4159994d15 sioyek.desktop
"
diff --git a/community/sioyek/mupdf-0.23.0.patch b/community/sioyek/mupdf-0.23.0.patch
new file mode 100644
index 00000000000..4e0ee6de37a
--- /dev/null
+++ b/community/sioyek/mupdf-0.23.0.patch
@@ -0,0 +1,73 @@
+diff --git a/pdf_viewer/document_view.cpp b/pdf_viewer/document_view.cpp
+index f48d05e..0bc3855 100644
+--- a/pdf_viewer/document_view.cpp
++++ b/pdf_viewer/document_view.cpp
+@@ -1121,7 +1121,7 @@ std::vector<DocumentPos> DocumentView::find_line_definitions() {
+
+ std::optional<PdfLink> pdf_link = current_document->get_link_in_page_rect(get_center_page_number(), line_rects[line_index]);
+ if (pdf_link.has_value()) {
+- auto parsed_uri = parse_uri(mupdf_context, pdf_link.value().uri);
++ auto parsed_uri = parse_uri(mupdf_context, current_document->doc, pdf_link.value().uri);
+ result.push_back({ parsed_uri.page - 1, parsed_uri.x, parsed_uri.y });
+ return result;
+ }
+diff --git a/pdf_viewer/main_widget.cpp b/pdf_viewer/main_widget.cpp
+index 19b568b..335a93f 100644
+--- a/pdf_viewer/main_widget.cpp
++++ b/pdf_viewer/main_widget.cpp
+@@ -170,7 +170,7 @@ void MainWidget::set_overview_position(int page, float offset) {
+
+ void MainWidget::set_overview_link(PdfLink link) {
+
+- auto [page, offset_x, offset_y] = parse_uri(mupdf_context, link.uri);
++ auto [page, offset_x, offset_y] = parse_uri(mupdf_context, doc()->doc, link.uri);
+ if (page >= 1) {
+ set_overview_position(page - 1, offset_y);
+ }
+@@ -3178,7 +3178,7 @@ void MainWidget::handle_pending_text_command(std::wstring text) {
+ open_web_url(utf8_decode(selected_link->uri));
+ }
+ else{
+- auto [page, offset_x, offset_y] = parse_uri(mupdf_context, selected_link->uri);
++ auto [page, offset_x, offset_y] = parse_uri(mupdf_context, doc()->doc, selected_link->uri);
+ long_jump_to_destination(page-1, offset_y);
+ }
+ }
+@@ -3863,7 +3863,7 @@ void MainWidget::handle_link_click(const PdfLink& link) {
+ return;
+ }
+
+- auto [page, offset_x, offset_y] = parse_uri(mupdf_context, link.uri);
++ auto [page, offset_x, offset_y] = parse_uri(mupdf_context, doc()->doc, link.uri);
+
+ // convert one indexed page to zero indexed page
+ page--;
+diff --git a/pdf_viewer/utils.cpp b/pdf_viewer/utils.cpp
+index 22d4265..3150e66 100644
+--- a/pdf_viewer/utils.cpp
++++ b/pdf_viewer/utils.cpp
+@@ -116,8 +116,9 @@ bool rects_intersect(fz_rect rect1, fz_rect rect2) {
+ return range_intersects(rect1.x0, rect1.x1, rect2.x0, rect2.x1) && range_intersects(rect1.y0, rect1.y1, rect2.y0, rect2.y1);
+ }
+
+-ParsedUri parse_uri(fz_context* mupdf_context, std::string uri) {
+- fz_link_dest dest = pdf_parse_link_uri(mupdf_context, uri.c_str());
++ParsedUri parse_uri(fz_context* mupdf_context, fz_document* fz_doc, std::string uri) {
++ pdf_document* doc = pdf_document_from_fz_document(mupdf_context, fz_doc);
++ fz_link_dest dest = pdf_resolve_link_dest(mupdf_context, doc, uri.c_str());
+ return { dest.loc.page + 1, dest.x, dest.y };
+ }
+
+diff --git a/pdf_viewer/utils.h b/pdf_viewer/utils.h
+index 2a12211..643b030 100644
+--- a/pdf_viewer/utils.h
++++ b/pdf_viewer/utils.h
+@@ -55,7 +55,7 @@ void get_flat_toc(const std::vector<TocNode*>& roots, std::vector<std::wstring>&
+ int mod(int a, int b);
+ bool range_intersects(float range1_start, float range1_end, float range2_start, float range2_end);
+ bool rects_intersect(fz_rect rect1, fz_rect rect2);
+-ParsedUri parse_uri(fz_context* mupdf_context, std::string uri);
++ParsedUri parse_uri(fz_context* mupdf_context, fz_document* fz_doc, std::string uri);
+ char get_symbol(int key, bool is_shift_pressed, const std::vector<char>&special_symbols);
+
+ template<typename T>

View File

@ -0,0 +1,75 @@
(define-module (radix packages pdf)
#:use-module (guix gexp)
#:use-module (guix packages)
#:use-module (guix git-download)
#:use-module (guix build-system qt)
#:use-module ((guix build utils) #:hide (delete))
#:use-module (gnu packages qt)
#:use-module (gnu packages web)
#:use-module (gnu packages gtk)
#:use-module (gnu packages pdf)
#:use-module (gnu packages image)
#:use-module (gnu packages fontutils)
#:use-module (gnu packages javascript)
#:use-module ((guix licenses) #:prefix license:))
;; Currently broken
(define-public sioyek
(package
(name "sioyek")
(version "2.0.0")
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/ahrm/sioyek")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(patches (find-files "patches" "sioyek-parse-link-uri.patch"))
(sha256
(base32 "1vmmp2s032ygh1byz77pg9aljmp8hx745fr7mmz11831f96mlmhq"))))
(inputs
(list gumbo-parser
freetype
harfbuzz
jbig2dec
mujs
mupdf
openjpeg
libjpeg-turbo
qt3d-5
qtbase-5))
(build-system qt-build-system)
(arguments
(list #:tests? #f
#:phases
#~(modify-phases
%standard-phases
(replace 'configure
(lambda* (#:key outputs #:allow-other-keys)
(let ((out (assoc-ref outputs "out")))
(invoke "qmake" (string-append "PREFIX=" out)))))
(add-after 'unpack 'patch-source-files
(lambda* (#:key inputs outputs #:allow-other-keys)
(let* ((out (assoc-ref outputs "out"))
(share (string-append out "/share/sioyek"))
(etc (string-append out "/etc/sioyek")))
(substitute* "pdf_viewer/main.cpp"
(("/usr/share/sioyek") share)
(("/etc/sioyek") etc))
(substitute* "pdf_viewer_build_config.pro"
(("-lmupdf-third ") ""))
#t))))))
(home-page "https://sioyek.info")
(synopsis "A PDF viewer designed for research papers and technical books")
(description "Sioyek is a PDF viewer with a focus on technical books and research papers.")
(license license:gpl3)))
;; Currently broken
(define-public sioyek/wayland
(package
(inherit sioyek)
(name "sioyek-wayland")
(inputs
(modify-inputs (package-inputs sioyek)
(append qtwayland-5)))))