Subject: [PATCH 24/27] gnu: calibre: Patch some paths.

From: Brendan Tildesley <[email-masked]>
Date: Wed, 10 Mar 2021 20:00:50 +1100

* gnu/packages/ebook.scm (calibre):
[inputs]: Add libjpeg and libjxz.
[arguments]: substitute Calibre's weird get_exe_path procedure that looks
in poppler's output directory for binaries with direct paths to
jpegtran, cjpeg, optipng, and JxrDecApp.
---
 gnu/packages/ebook.scm | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/ebook.scm b/gnu/packages/ebook.scm
index 124fcda4df..be367a5245 100644
--- a/gnu/packages/ebook.scm
+++ b/gnu/packages/ebook.scm
@@ -161,6 +161,8 @@
        ("icu4c" ,icu4c)
        ("libmtp" ,libmtp)
        ("libpng" ,libpng)
+       ("libjpeg" ,libjpeg-turbo)
+       ("libjxr" ,libjxr)
        ("libusb" ,libusb)
        ("openssl" ,openssl)
        ("optipng" ,optipng)
@@ -246,7 +248,12 @@ sip-include-dirs = [\"" pyqt "/share/sip" "\"]")))
                 (("PDFTOHTML = 'pdftohtml'")
                  (string-append "PDFTOHTML = \"" (assoc-ref inputs "poppler")
                                 "/bin/pdftohtml\"")))
-
+              ;; get_exe_path looks in poppler's output for these binaries.
+              (substitute* "src/calibre/utils/img.py"
+                (("get_exe_path..jpegtran..") (string-append "'" (which "jpegtran") "'"))
+                (("get_exe_path..cjpeg..") (string-append "'" (which "cjpeg") "'"))
+                (("get_exe_path..optipng..") (string-append "'" (which "optipng") "'"))
+                (("get_exe_path..JxrDecApp..") (string-append "'" (which "JxrDecApp") "'")))
               ;; Calibre thinks we are installing desktop files into a home
               ;; directory, but here we butcher the script in to installing
               ;; to calibres /share directory.
-- 
2.30.1