Subject: [bug#78401] [PATCH] gnu: mupdf: Update to 1.26.0.

From: Divya Ranjan <[email-masked]>
Date: Fri, 16 May 2025 06:16:11 +0000

Maxim Cournoyer <[email-masked]> writes:

> Hi,

Hello Maxim,

> Divya Ranjan <[email-masked]> writes:
>
>> * gnu/packages/pdf.scm (mupdf): Update to 1.26.0.
>
> Various changes done here are not listed in the change log.  Please
> consult other commits for examples or (info "(standards) Style of Change
> Logs").

Please find the updated patch with the indentation and commit message fixed.
>From 77c6b79a43a2cd7982d417e5373c55af1b13fcd5 Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
From: Divya Ranjan <[email-masked]>
Date: Fri, 16 May 2025 05:58:06 +0000
Subject: [PATCH] gnu: mupdf: Update to 1.26.0.
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

* gnu/packages/pdf.scm (mupdf): Update to 1.26.0.
[inputs]: Add brotli
[arguments]: Build using system’s brotli
[arguments]: Enable SONAME to avoid symlink conflicts

Change-Id: I6dc7f08f9e21d6d5233e3fb7b886037c9d912ec7
---
 gnu/packages/pdf.scm | 63 +++++++++++++++++++++++---------------------
 1 file changed, 33 insertions(+), 30 deletions(-)

diff --git a/gnu/packages/pdf.scm b/gnu/packages/pdf.scm
index a1c9da2c8a..c8c636976a 100644
--- a/gnu/packages/pdf.scm
+++ b/gnu/packages/pdf.scm
@@ -862,14 +862,14 @@ (define-public python-pydyf
 (define-public mupdf
   (package
     (name "mupdf")
-    (version "1.25.2")
+    (version "1.26.0")
     (source
      (origin
        (method url-fetch)
-       (uri (string-append "https://mupdf.com/downloads/archive/"
-                           "mupdf-" version "-source.tar.lz"))
+       (uri (string-append "https://mupdf.com/downloads/archive/" "mupdf-"
+                           version "-source.tar.lz"))
        (sha256
-        (base32 "0lg45wp3ici2g2i49fmwa1k32bgkqqgl51nxnqqk0i8ilmdh8hnx"))
+        (base32 "1nncar9w0qdpwp4s00nazr7hbl2kpbp665a6gwpsmdz5d7j1hqz9"))
        (modules '((guix build utils)
                   (ice-9 ftw)
                   (srfi srfi-1)))
@@ -882,31 +882,32 @@ (define-public mupdf
                                          (scandir ".")
                                          (cons* "." ".." keep))))))))
     (build-system gnu-build-system)
-    (inputs
-     (list curl
-           libxrandr
-           libxi
-           freeglut                     ;for GL/gl.h
-           freetype
-           gumbo-parser
-           harfbuzz
-           jbig2dec
-           libjpeg-turbo
-           libx11
-           libxext
-           mujs
-           openjpeg
-           openssl
-           zlib))
-    (native-inputs
-     (list pkg-config))
+    (inputs (list curl
+                  libxrandr
+                  libxi
+                  freeglut ;for GL/gl.h
+                  freetype
+                  gumbo-parser
+                  harfbuzz
+                  jbig2dec
+                  libjpeg-turbo
+                  libx11
+                  libxext
+                  mujs
+                  brotli
+                  openjpeg
+                  openssl
+                  zlib))
+    (native-inputs (list pkg-config))
     (arguments
      (list
-      #:tests? #f                       ;no check target
+      #:tests? #f ;no check target
       #:make-flags
       #~(list "verbose=yes"
-              (string-append "CC=" #$(cc-for-target))
+              (string-append "CC="
+                             #$(cc-for-target))
               "XCFLAGS=-fpic"
+              "USE_SYSTEM_BROTLI=yes"
               "USE_SYSTEM_FREETYPE=yes"
               "USE_SYSTEM_GUMBO=yes"
               "USE_SYSTEM_HARFBUZZ=yes"
@@ -921,10 +922,12 @@ (define-public mupdf
               "USE_SYSTEM_CURL=yes"
               "USE_SYSTEM_LEPTONICA=yes"
               "USE_SYSTEM_TESSERACT=yes"
-              "USE_SONAME=no"           ;install as libmupdf.so
+              "USE_SONAME=yes"
               "shared=yes"
-              (string-append "LDFLAGS=-Wl,-rpath=" #$output "/lib")
-              (string-append "prefix=" #$output))
+              (string-append "LDFLAGS=-Wl,-rpath="
+                             #$output "/lib")
+              (string-append "prefix="
+                             #$output))
       #:phases
       #~(modify-phases %standard-phases
           (delete 'configure)))) ;no configure script
@@ -940,9 +943,9 @@ (define-public mupdf
 line tools for batch rendering @command{pdfdraw}, rewriting files
 @command{pdfclean}, and examining the file structure @command{pdfshow}.")
     (license (list license:agpl3+
-                   license:bsd-3        ;resources/cmaps
-                   license:x11          ;thirdparty/lcms2
-                   license:silofl1.1    ;resources/fonts/{han,noto,sil,urw}
+                   license:bsd-3 ;resources/cmaps
+                   license:x11 ;thirdparty/lcms2
+                   license:silofl1.1 ;resources/fonts/{han,noto,sil,urw}
                    license:asl2.0)))) ; resources/fonts/droid
 
 (define-public mupdf-1.24 ; Needed for sioyek

base-commit: efac01f19b65d7d77a98bbfd57fe2073fb13064a
-- 
2.49.0

>
>>         (modules '((guix build utils)
>>                    (ice-9 ftw)
>>                    (srfi srfi-1)))
>> @@ -895,6 +895,7 @@ (define-public mupdf
>>             libx11
>>             libxext
>>             mujs
>> +	   brotli
>
> Is this strictly needed for the update?  Otherwise, it'd be best done in
> a distinct, separated commit.

Indeed, it is a new dependency with the update.
>
>>             openjpeg
>>             openssl
>>             zlib))
>> @@ -907,6 +908,7 @@ (define-public mupdf
>>        #~(list "verbose=yes"
>>                (string-append "CC=" #$(cc-for-target))
>>                "XCFLAGS=-fpic"
>> +	      "USE_SYSTEM_BROTLI=yes"
>
> I assume that's necessary and not something the build system
> automatically tries?  If the later, do not explicit it (it makes inputs
> rewriting less useful).

Indeed, the build system doesn’t do that with USE_SYSTEM_LIBS=yes.

>>                "USE_SYSTEM_FREETYPE=yes"
>>                "USE_SYSTEM_GUMBO=yes"
>>                "USE_SYSTEM_HARFBUZZ=yes"
>> @@ -921,7 +923,7 @@ (define-public mupdf
>>                "USE_SYSTEM_CURL=yes"
>>                "USE_SYSTEM_LEPTONICA=yes"
>>                "USE_SYSTEM_TESSERACT=yes"
>> -              "USE_SONAME=no"           ;install as libmupdf.so
>> +              "USE_SONAME=yes"
>

Without enabling that, one runs in to "Too many levels of symbolic links" errors. This is due to a recent change in mupdf upstream that updated their symbol table for the library. I was part of the changes made for this, and the devs agree that USE_SONAME should be enabled. Here’s the backtrace with USE_SONAME=yes:

error: in phase 'validate-runpath': uncaught exception:
system-error "open-file" "~A: ~S" ("Too many levels of symbolic links" "/gnu/store/j6r6rgvmmm59a8i7vh330c7bpxmgicma-mupdf-1.26.0/lib/libmupdf.so") (40) 
phase `validate-runpath' failed after 0.0 seconds
Backtrace:
          13 (primitive-load "/gnu/store/304wldk8xn5xd2cnpvr66lbkn82…")
In guix/build/gnu-build-system.scm:
    966:2 12 (gnu-build #:source _ #:outputs _ #:inputs _ #:phases . #)
In ice-9/boot-9.scm:
  1752:10 11 (with-exception-handler _ _ #:unwind? _ # _)
In srfi/srfi-1.scm:
    634:9 10 (for-each #<procedure 7fffef021240 at guix/build/gnu-b…> …)
In ice-9/boot-9.scm:
  1752:10  9 (with-exception-handler _ _ #:unwind? _ # _)
In guix/build/gnu-build-system.scm:
   987:23  8 (_)
   605:16  7 (validate-runpath #:validate-runpath? _ # _ #:outputs _)
In guix/build/utils.scm:
   735:23  6 (loop ("/gnu/store/j6r6rgvmmm59a8i7vh330c7bpxmgicma…" …) …)
In guix/build/gnu-build-system.scm:
   587:36  5 (validate "/gnu/store/j6r6rgvmmm59a8i7vh330c7bpxmgicma-…")
In guix/build/utils.scm:
   549:10  4 (find-files "/gnu/store/j6r6rgvmmm59a8i7vh330c7bpxmgic…" …)
In ice-9/ftw.scm:
   505:39  3 (loop _ _ #(25 88653728 16877 1 999 30000 0 22 # # # …) …)
In guix/build/utils.scm:
   551:34  2 (_ "/gnu/store/j6r6rgvmmm59a8i7vh330c7bpxmgicma-mupdf-…" …)
In ice-9/boot-9.scm:
  1685:16  1 (raise-exception _ #:continuable? _)
  1685:16  0 (raise-exception _ #:continuable? _)

ice-9/boot-9.scm:1685:16: In procedure raise-exception:
In procedure open-file: Too many levels of symbolic links: "/gnu/store/j6r6rgvmmm59a8i7vh330c7bpxmgicma-mupdf-1.26.0/lib/libmupdf.so"
build process 18 exited with status 256

Also, I don’t want to open another bug report, but enabling SONAME breaks sioyek which depends on mupdf-1.24. Since the latter inherits from mupdf, thus also inheriting USE_SONAME=yes, it breaks sioyek that relies on having it disabled.

I’ve attached another patch that specifically disables SONAME for mupdf-1.24, allowing sioyek to build fine as usual.

>From 9e57a2805db3f870e5c0edc0d13eba308b0827a3 Mon Sep 17 00:00:00 2001
Message-ID: <[email-masked]>
From: Divya Ranjan <[email-masked]>
Date: Fri, 16 May 2025 06:01:18 +0000
Subject: [PATCH] gnu: mupdf: Modify #:make-flags

[arguments]: Disable SONAME

Change-Id: I070c59100ffedf9c451a7ce344ae6e210f1190f6
---
 gnu/packages/pdf.scm | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/gnu/packages/pdf.scm b/gnu/packages/pdf.scm
index c8c636976a..25a3f84533 100644
--- a/gnu/packages/pdf.scm
+++ b/gnu/packages/pdf.scm
@@ -948,7 +948,8 @@ (define-public mupdf
                    license:silofl1.1 ;resources/fonts/{han,noto,sil,urw}
                    license:asl2.0)))) ; resources/fonts/droid
 
-(define-public mupdf-1.24 ; Needed for sioyek
+(define-public mupdf-1.24
+   ;Needed for sioyek
   (package
     (inherit mupdf)
     (name "mupdf")
@@ -956,8 +957,8 @@ (define-public mupdf-1.24 ; Needed for sioyek
     (source
      (origin
        (method url-fetch)
-       (uri (string-append "https://mupdf.com/downloads/archive/"
-                           "mupdf-" version "-source.tar.lz"))
+       (uri (string-append "https://mupdf.com/downloads/archive/" "mupdf-"
+                           version "-source.tar.lz"))
        (sha256
         (base32 "0hydmp8sdnkrkpqyysa6klkxbwv9awf1xc753r27gcj7ds7375fj"))
        (modules '((guix build utils)
@@ -970,7 +971,14 @@ (define-public mupdf-1.24 ; Needed for sioyek
               (for-each delete-file-recursively
                         (lset-difference string=?
                                          (scandir ".")
-                                         (cons* "." ".." keep))))))))))
+                                         (cons* "." ".." keep))))))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments mupdf)
+       ((#:make-flags flags)
+        #~(append (filter (lambda (flag)
+                            (not (string-prefix? "USE_SONAME=" flag)))
+                          #$flags)
+                  (list "USE_SONAME=no")))))))

 (define-public qpdf

base-commit: efac01f19b65d7d77a98bbfd57fe2073fb13064a
prerequisite-patch-id: e0b65c11f00f64b0496909046ee872884b87653c
-- 
2.49.0

-- 
Divya Ranjan,
Philosophy, Mathematics, Libre Software.

PGP Fingerprint: F0B3 1A69 8006 8FB8 096A  2F12 B245 10C6 108C 8D4A