Subject: [bug#43249] Resolve Calibre run-time dependency

From: Prafulla Giri <[email-masked]>
Date: Mon, 7 Sep 2020 00:17:23 +0545

Esteemed maintainers,

Currently, Calibre can't open .epub files unless `qtwebengine` package is
also available in one's $GUIX_PROFILE. Neither can the stand-alone
`ebook-viewer` program supplied with Calibre. It exits with the complaint:
"Could not find QtWebEngineProcess".

Attached is a patch to fix the issue. QtWebEngineProcess is now made
available to all Calibre binaries via QTWEBENGINE_PATH set during a new
'wrap-program phase introduced with the patch.

Thank you
From cec0d8adf456eff2201fd89bb1fde6cba9d6fa77 Mon Sep 17 00:00:00 2001
From: Prafulla Giri <[email-masked]>
Date: Sun, 6 Sep 2020 23:57:14 +0545
Subject: [PATCH] gnu: calibre: make QtWebEngineProcess available during
 runtime

* gnu/packages/ebook.scm [arguments]: Add new phase 'wrap-program
to make QtWebEngineProcess available to the binaries during run-
time with QTWEBENGINEPROCESS_PATH.
---
 gnu/packages/ebook.scm | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/gnu/packages/ebook.scm b/gnu/packages/ebook.scm
index aab4155d3d..f63d284afb 100644
--- a/gnu/packages/ebook.scm
+++ b/gnu/packages/ebook.scm
@@ -262,6 +262,22 @@
                                             "/share/fonts/truetype")))
                (delete-file-recursively font-dest)
                (symlink font-src font-dest))
+             #t))
+         ;; Make run-time dependencies available to the binaries
+         (add-after 'wrap 'wrap-program
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             (let ((out (assoc-ref outputs "out"))
+                   (qtwebengine (assoc-ref inputs "qtwebengine")))
+               (with-directory-excursion (string-append out "/bin")
+                 (for-each
+                  (lambda (binary)
+                    (wrap-program binary
+                      ;; Make QtWebEngineProcess available
+                      `("QTWEBENGINEPROCESS_PATH" ":" =
+                        ,(list (string-append
+                                qtwebengine
+                                "/lib/qt5/libexec/QtWebEngineProcess")))))
+                  (find-files "." "."))))
              #t)))))
     (home-page "https://calibre-ebook.com/")
     (synopsis "E-book library management software")
-- 
2.28.0