all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
* [bug#71787] [PATCH 00/12] Update and unbundle ghostscript and mupdf
@ 2024-06-26 19:24 David Elsing
  2024-06-26 19:26 ` [bug#71787] [PATCH 01/12] gnu: Add lcms2mt David Elsing
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: David Elsing @ 2024-06-26 19:24 UTC (permalink / raw)
  To: 71787; +Cc: David Elsing, skyvine

Hello,

this patch series unbundles the remaining dependencies of ghostscript and
mupdf and updates them to the latest version.

I also switched the sources of ghostscript and mupdf to the Git repository, as
the tarball contains some autogenerated files and (different) bundled
dependencies. For the licenses of the ghostscript source files, the Debian
package [1] has a very detailed list.

As the tesseract package has many dependencies (including a circular
dependency with ghostscript) and depends on the very large
tesseract-ocr-tessdata-fast package, I decided to disable tesseract for the
main packages and make package variants instead.

Previously, the ghostscript package was modified to omit non-reproducible
metadata when the GS_GENERATE_UUIDS environment variable was set to "0" or
"no". In the meantime, suitable options have been added upstream and I made a
patch to enable them depending on GS_GENERATE_UUIDS.

Building the ghostscript documentation transitively depends on ghostscript itself.
Therefore, I made a separate package (also for the missing Python dependencies).

[1] https://packages.debian.org/en/sid/ghostscript

David Elsing (12):
  gnu: Add lcms2mt.
  gnu: Add memento.
  gnu: Add extract.
  gnu: ijs: Remove unneeded files and build shared library.
  gnu: ghostscript: Unbundle dependencies and remove non-free parts.
  gnu: Add ghostscript/tesseract.
  gnu: mupdf: Update to 1.24.4 and unbundle remaining dependencies.
  gnu: Add mupdf/tesseract.
  gnu: Add python-pymupdf.
  gnu: Add python-svglib.
  gnu: Add python-rst2pdf.
  gnu: Add ghostscript-documentation.

 gnu/local.mk                                  |   8 +-
 gnu/packages/c.scm                            |  41 ++
 gnu/packages/ghostscript.scm                  | 359 ++++++++++++++----
 .../patches/extract-shared-library.patch      |  59 +++
 .../ghostscript-CVE-2023-36664-fixup.patch    |  56 ---
 .../patches/ghostscript-CVE-2023-36664.patch  | 142 -------
 .../patches/ghostscript-leptonica-hurd.patch  |  78 ----
 .../ghostscript-no-header-creationdate.patch  |  46 ---
 .../patches/ghostscript-no-header-id.patch    |  57 ---
 .../patches/ghostscript-no-header-uuid.patch  |  49 ---
 .../patches/ghostscript-reproducibility.patch |  26 ++
 gnu/packages/pdf.scm                          | 141 +++++--
 gnu/packages/python-xyz.scm                   | 143 +++++++
 13 files changed, 651 insertions(+), 554 deletions(-)
 create mode 100644 gnu/packages/patches/extract-shared-library.patch
 delete mode 100644 gnu/packages/patches/ghostscript-CVE-2023-36664-fixup.patch
 delete mode 100644 gnu/packages/patches/ghostscript-CVE-2023-36664.patch
 delete mode 100644 gnu/packages/patches/ghostscript-leptonica-hurd.patch
 delete mode 100644 gnu/packages/patches/ghostscript-no-header-creationdate.patch
 delete mode 100644 gnu/packages/patches/ghostscript-no-header-id.patch
 delete mode 100644 gnu/packages/patches/ghostscript-no-header-uuid.patch
 create mode 100644 gnu/packages/patches/ghostscript-reproducibility.patch

-- 
2.45.1





^ permalink raw reply	[flat|nested] 13+ messages in thread

* [bug#71787] [PATCH 01/12] gnu: Add lcms2mt.
  2024-06-26 19:24 [bug#71787] [PATCH 00/12] Update and unbundle ghostscript and mupdf David Elsing
@ 2024-06-26 19:26 ` David Elsing
  2024-06-26 19:26 ` [bug#71787] [PATCH 02/12] gnu: Add memento David Elsing
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: David Elsing @ 2024-06-26 19:26 UTC (permalink / raw)
  To: 71787; +Cc: David Elsing

* gnu/packages/ghostscript.scm (lcms2mt): New variable.
---
 gnu/packages/ghostscript.scm | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/gnu/packages/ghostscript.scm b/gnu/packages/ghostscript.scm
index 502b41bb99..5f0e2cf3c4 100644
--- a/gnu/packages/ghostscript.scm
+++ b/gnu/packages/ghostscript.scm
@@ -10,7 +10,8 @@
 ;;; Copyright © 2018, 2020, 2022 Marius Bakke <mbakke@fastmail.com>
 ;;; Copyright © 2019 Mathieu Othacehe <m.othacehe@gmail.com>
 ;;; Copyright © 2020, 2023 Janneke Nieuwenhuizen <janneke@gnu.org>
-;;;
+;;; Copyright © 2024 David Elsing <david.elsing@posteo.net>
+;;
 ;;; This file is part of GNU Guix.
 ;;;
 ;;; GNU Guix is free software; you can redistribute it and/or modify it
@@ -43,6 +44,7 @@ (define-module (gnu packages ghostscript)
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module (guix gexp)
+  #:use-module (guix git-download)
   #:use-module (guix utils)
   #:use-module (guix build-system gnu)
   #:use-module (srfi srfi-1))
@@ -73,6 +75,25 @@ (define-public lcms
     (home-page "https://www.littlecms.com/")
     (properties '((cpe-name . "little_cms_color_engine")))))
 
+;; Fork of LCMS 2 for Ghostscript and MuPDF
+(define-public lcms2mt
+  (package
+    (inherit lcms)
+    (name "lcms2mt")
+    (version "2.16")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "git://git.ghostscript.com/thirdparty-lcms2")
+             (commit (string-append "lcms" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "0dxpq59r1w3r1391fngpvka51r16505zmr32zjs2azjlrz49k3x4"))))
+    (synopsis "Little CMS, a small-footprint colour management engine
+(GhostScript fork)")
+    (home-page "https://www.ghostscript.com/")))
+
 (define-public libpaper
   (package
     (name "libpaper")
-- 
2.45.1





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [bug#71787] [PATCH 02/12] gnu: Add memento.
  2024-06-26 19:24 [bug#71787] [PATCH 00/12] Update and unbundle ghostscript and mupdf David Elsing
  2024-06-26 19:26 ` [bug#71787] [PATCH 01/12] gnu: Add lcms2mt David Elsing
@ 2024-06-26 19:26 ` David Elsing
  2024-06-26 19:26 ` [bug#71787] [PATCH 03/12] gnu: Add extract David Elsing
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: David Elsing @ 2024-06-26 19:26 UTC (permalink / raw)
  To: 71787; +Cc: David Elsing

* gnu/packages/c.scm (memento): New variable.
---
 gnu/packages/c.scm | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/gnu/packages/c.scm b/gnu/packages/c.scm
index d13b62b5e2..27be60aa98 100644
--- a/gnu/packages/c.scm
+++ b/gnu/packages/c.scm
@@ -1678,3 +1678,44 @@ (define-public pcg-c
 Linear Congruential Generator (LCG) with a permutation function to increase
 output randomness while retaining speed, simplicity, and conciseness.")
       (license (list license:expat license:asl2.0))))) ; dual licensed
+
+(define-public memento
+  (let ((commit "46f8beaad330b9b9e1dc1678cf41f78c1b902d11")
+        (revision "0"))
+    (package
+      (name "memento")
+      (version (git-version "0.0.0" revision commit))
+      (source
+       (origin
+         (method git-fetch)
+         (uri (git-reference
+               (url "https://github.com/ArtifexSoftware/memento")
+               (commit commit)))
+         (file-name (git-file-name name version))
+         (sha256
+          (base32
+           "1gmvbybm9s07g3n7k0zswv88s4bkk7yd66ydaljqwvf6w7d9dzg4"))))
+      (build-system gnu-build-system)
+      (arguments
+       (list
+        #:phases
+        #~(modify-phases %standard-phases
+            ;; There are no build system files
+            (delete 'configure)
+            (replace 'build
+              (lambda _
+                (invoke #$(cc-for-target) "memento.c" "-O2" "-g" "-shared"
+                        "-o" "libmemento.so")))
+            (replace 'install
+              (lambda _
+                (install-file "libmemento.so" (string-append #$output "/lib"))
+                (install-file "memento.h" (string-append #$output "/include"))
+                (install-file "docs/README.md"
+                              (string-append #$output "/share/doc/"
+                                             #$name "-" #$version)))))
+        #:tests? #f))
+      (home-page "https://github.com/ArtifexSoftware/memento")
+      (synopsis "Memory debugging library for C and C++ programs")
+      (description "Memento is a debugging library, which intercepts calls to
+malloc, free, realloc etc. to detect memory leaks and errors.")
+      (license license:isc))))
-- 
2.45.1





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [bug#71787] [PATCH 03/12] gnu: Add extract.
  2024-06-26 19:24 [bug#71787] [PATCH 00/12] Update and unbundle ghostscript and mupdf David Elsing
  2024-06-26 19:26 ` [bug#71787] [PATCH 01/12] gnu: Add lcms2mt David Elsing
  2024-06-26 19:26 ` [bug#71787] [PATCH 02/12] gnu: Add memento David Elsing
@ 2024-06-26 19:26 ` David Elsing
  2024-06-26 19:26 ` [bug#71787] [PATCH 04/12] gnu: ijs: Remove unneeded files and build shared library David Elsing
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: David Elsing @ 2024-06-26 19:26 UTC (permalink / raw)
  To: 71787; +Cc: David Elsing

* gnu/packages/ghostscript.scm (extract): New variable.
* gnu/packages/patches/extract-shared-library.patch: New file.
* gnu/local.mk (dist_patch_DATA): Register it.
---
 gnu/local.mk                                  |  1 +
 gnu/packages/ghostscript.scm                  | 47 +++++++++++++++
 .../patches/extract-shared-library.patch      | 59 +++++++++++++++++++
 3 files changed, 107 insertions(+)
 create mode 100644 gnu/packages/patches/extract-shared-library.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 282cf30f7f..2fc14e68fe 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1178,6 +1178,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/eudev-rules-directory.patch		\
   %D%/packages/patches/exercism-disable-self-update.patch	\
   %D%/packages/patches/extempore-unbundle-external-dependencies.patch	\
+  %D%/packages/patches/extract-shared-library.patch		\
   %D%/packages/patches/extundelete-e2fsprogs-1.44.patch		\
   %D%/packages/patches/fail2ban-0.11.2_CVE-2021-32749.patch	\
   %D%/packages/patches/fail2ban-0.11.2_fix-setuptools-drop-2to3.patch	\
diff --git a/gnu/packages/ghostscript.scm b/gnu/packages/ghostscript.scm
index 5f0e2cf3c4..2e24904fd4 100644
--- a/gnu/packages/ghostscript.scm
+++ b/gnu/packages/ghostscript.scm
@@ -30,6 +30,7 @@
 (define-module (gnu packages ghostscript)
   #:use-module (gnu packages)
   #:use-module (gnu packages autotools)
+  #:use-module (gnu packages c)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages cups)
   #:use-module (gnu packages fontutils)
@@ -94,6 +95,52 @@ (define-public lcms2mt
 (GhostScript fork)")
     (home-page "https://www.ghostscript.com/")))
 
+(define-public extract
+  (package
+    (name "extract")
+    (version "10.03.0")
+    (source (origin
+              (method git-fetch)
+              (uri (git-reference
+                    (url "git://git.ghostscript.com/extract.git")
+                    (commit (string-append "ghostpdl-" version))))
+              (file-name (git-file-name name version))
+              (sha256
+               (base32
+                "17mb96xpsbr26q2l3kahmi3f1mcqzn7n1q1783f40155lrkk88q9"))
+              (snippet
+               '(for-each
+                 delete-file
+                 '("src/docx_template.c" "src/docx_template.h"
+                   "src/odt_template.c" "src/odt_template.h"
+                   "src/memento.h" "src/memento.c")))
+              (patches (search-patches "extract-shared-library.patch"))))
+    (build-system gnu-build-system)
+    (arguments
+     (list
+      #:test-target "test"
+      #:make-flags
+      `(list
+        "build=debug-opt"
+        "flags_compile=-MMD -MP -Iinclude -Isrc -fPIC"
+        (string-append "CC=" ,(cc-for-target))
+        (string-append "CXX=" ,(cxx-for-target)))
+      #:phases
+      #~(modify-phases %standard-phases
+          (delete 'configure) ; no configure script
+          (replace 'install
+            (lambda _
+              (install-file "libextract.so" (string-append #$output "/lib"))
+              (copy-recursively
+               "include" (string-append #$output "/include")))))))
+    (inputs (list memento zlib))
+    (native-inputs (list python unzip))
+    (home-page "https://git.ghostscript.com/?p=extract.git")
+    (synopsis "Document content extraction library")
+    (description "extract is a library for exstracting dox, odt, html and text
+files from documents.")
+    (license license:agpl3+)))
+
 (define-public libpaper
   (package
     (name "libpaper")
diff --git a/gnu/packages/patches/extract-shared-library.patch b/gnu/packages/patches/extract-shared-library.patch
new file mode 100644
index 0000000000..b2ab37dcc6
--- /dev/null
+++ b/gnu/packages/patches/extract-shared-library.patch
@@ -0,0 +1,59 @@
+Adjust the Makefile to build a shared library.
+
+diff --git a/Makefile b/Makefile
+index e8933ea..5cf503c 100644
+--- a/Makefile
++++ b/Makefile
+@@ -130,6 +130,7 @@ endif
+ $(warning gs=$(gs))
+ endif
+ 
++build: libextract.so $(exe_dep) $(exe_buffer_test_dep) $(exe_misc_test_dep) $(exe_ziptest_dep)
+ 
+ # Default target - run all tests.
+ #
+@@ -294,7 +295,7 @@ test/generated/%.pdf.mutool.text.diff: test/generated/%.pdf.mutool.text test/%.p
+ # Main executable.
+ #
+ exe = src/build/extract-$(build).exe
+-exe_src = \
++lib_src = \
+         src/alloc.c \
+         src/astring.c \
+         src/boxer.c \
+@@ -302,10 +303,10 @@ exe_src = \
+         src/document.c \
+         src/docx.c \
+         src/docx_template.c \
+-        src/extract-exe.c \
+         src/extract.c \
+         src/html.c \
+         src/join.c \
++        src/json.c \
+         src/mem.c \
+         src/odt.c \
+         src/odt_template.c \
+@@ -318,16 +319,18 @@ exe_src = \
+ 
+ 
+ ifeq ($(build),memento)
+-    exe_src += src/memento.c
++    lib_src += src/memento.c
+     ifeq ($(uname),Linux)
+         flags_compile += -D HAVE_LIBDL
+         flags_link += -L $(libbacktrace) -l backtrace -l dl
+     endif
+ endif
+-exe_obj := $(exe_src)
+-exe_obj := $(patsubst src/%.c, src/build/%.c-$(build).o, $(exe_obj))
+-exe_obj := $(patsubst src/%.cpp, src/build/%.cpp-$(build).o, $(exe_obj))
+-exe_dep = $(exe_obj:.o=.d)
++lib_obj := $(lib_src)
++lib_obj := $(patsubst src/%.c, src/build/%.c-$(build).o, $(lib_obj))
++lib_obj := $(patsubst src/%.cpp, src/build/%.cpp-$(build).o, $(lib_obj))
++lib_dep = $(lib_obj:.o=.d)
++libextract.so: $(lib_obj)
++	$(CXX) $(flags_link) $^ -lz -lm -shared -o $@
+ exe: $(exe)
+ $(exe): $(exe_obj)
+ 	$(CXX) $(flags_link) -o $@ $^ -lz -lm
-- 
2.45.1





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [bug#71787] [PATCH 04/12] gnu: ijs: Remove unneeded files and build shared library.
  2024-06-26 19:24 [bug#71787] [PATCH 00/12] Update and unbundle ghostscript and mupdf David Elsing
                   ` (2 preceding siblings ...)
  2024-06-26 19:26 ` [bug#71787] [PATCH 03/12] gnu: Add extract David Elsing
@ 2024-06-26 19:26 ` David Elsing
  2024-06-26 19:26 ` [bug#71787] [PATCH 05/12] gnu: ghostscript: Unbundle dependencies and remove non-free parts David Elsing
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: David Elsing @ 2024-06-26 19:26 UTC (permalink / raw)
  To: 71787; +Cc: David Elsing

* gnu/packages/ghostscript.scm (ijs)[source]: Add snippet. Remove patches.
[phases] Rename 'autogen' phase to 'prepare' and adjust.
---
 gnu/packages/ghostscript.scm | 106 +++++++++++++++++++++--------------
 1 file changed, 64 insertions(+), 42 deletions(-)

diff --git a/gnu/packages/ghostscript.scm b/gnu/packages/ghostscript.scm
index 2e24904fd4..40891676b3 100644
--- a/gnu/packages/ghostscript.scm
+++ b/gnu/packages/ghostscript.scm
@@ -368,50 +368,72 @@ (define-public ghostscript/cups
 
 (define-public ijs
   (package
-   (name "ijs")
-   (version (package-version ghostscript))
-   (source (package-source ghostscript))
-   (build-system gnu-build-system)
-   (native-inputs
-    (append (if (target-riscv64?)
-              (list config)
-              '())
-            (list libtool automake autoconf)))
-   (arguments
-    `(#:phases
-      (modify-phases %standard-phases
-        (add-after 'unpack 'autogen
-          (lambda _
-            ;; need to regenerate macros
-            (system* "autoreconf" "-if")
-            ;; do not run configure
-            (substitute* "autogen.sh"
-              (("^.*\\$srcdir/configure.*") ""))
-            (system* "bash" "autogen.sh")
-            ;; create configure script in ./ijs/
-            (chdir "ijs")
-            ;; do not run configure
-            (substitute* "autogen.sh"
-              (("^.*\\$srcdir/configure.*") "")
-              (("^ + && echo Now type.*$")  ""))
-            (invoke "bash" "autogen.sh")))
-        ,@(if (target-riscv64?)
-            `((add-after 'unpack 'update-config-scripts
-                (lambda* (#:key native-inputs inputs #:allow-other-keys)
-                  (for-each (lambda (file)
-                              (install-file
-                               (search-input-file
-                                (or native-inputs inputs)
-                                (string-append "/bin/" file)) "ijs"))
-                            '("config.guess" "config.sub")))))
-            '()))))
-   (synopsis "IJS driver framework for inkjet and other raster devices")
-   (description
-    "IJS is a protocol for transmission of raster page images.  This package
+    (name "ijs")
+    (version (package-version ghostscript))
+    (source
+     (origin
+       (inherit
+        (package-source ghostscript))
+       (modules '((guix build utils)
+                  (srfi srfi-1)
+                  (ice-9 ftw)))
+       (snippet
+        '(begin
+           (for-each delete-file-recursively
+                     (lset-difference equal? (scandir ".")
+                                      '("." ".." "ijs")))
+           (chdir "ijs")
+           (for-each
+            delete-file
+            '("compile"
+              "config.guess"
+              "config.sub"
+              "configure"
+              "ijs_spec.pdf"
+              "ijs_spec.ps"
+              "install-sh"
+              "libtool"
+              "ltmain.sh"
+              "Makefile.in"
+              "missing"
+              "state.eps"
+              "state.fig"))))
+       (patches '())))
+    (build-system gnu-build-system)
+    (native-inputs
+     (append (if (target-riscv64?)
+                 (list config)
+                 '())
+             (list libtool automake autoconf)))
+    (arguments
+     `(#:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'prepare
+           (lambda _
+             (chdir "ijs")
+             ;; do not run configure
+             (substitute* "autogen.sh"
+               (("^.*\\$srcdir/configure.*") "")
+               (("^ + && echo Now type.*$")  ""))
+             (substitute* "configure.ac"
+               (("AC_DISABLE_SHARED") ""))))
+         ,@(if (target-riscv64?)
+               `((add-after 'unpack 'update-config-scripts
+                   (lambda* (#:key native-inputs inputs #:allow-other-keys)
+                     (for-each (lambda (file)
+                                 (install-file
+                                  (search-input-file
+                                   (or native-inputs inputs)
+                                   (string-append "/bin/" file)) "ijs"))
+                               '("config.guess" "config.sub")))))
+               '()))))
+    (synopsis "IJS driver framework for inkjet and other raster devices")
+    (description
+     "IJS is a protocol for transmission of raster page images.  This package
 provides the reference implementation of the raster printer driver
 architecture.")
-   (license license:expat)
-   (home-page (package-home-page ghostscript))))
+    (license license:expat)
+    (home-page (package-home-page ghostscript))))
 
 (define-public font-ghostscript
   (package
-- 
2.45.1





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [bug#71787] [PATCH 05/12] gnu: ghostscript: Unbundle dependencies and remove non-free parts.
  2024-06-26 19:24 [bug#71787] [PATCH 00/12] Update and unbundle ghostscript and mupdf David Elsing
                   ` (3 preceding siblings ...)
  2024-06-26 19:26 ` [bug#71787] [PATCH 04/12] gnu: ijs: Remove unneeded files and build shared library David Elsing
@ 2024-06-26 19:26 ` David Elsing
  2024-06-26 19:26 ` [bug#71787] [PATCH 06/12] gnu: Add ghostscript/tesseract David Elsing
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: David Elsing @ 2024-06-26 19:26 UTC (permalink / raw)
  To: 71787; +Cc: David Elsing

The fonts in pcl/urwfonts and the jpegxr library are non-free.
Autogenerated files are removed as well.

Due to a circular dependency with python-sphinx, the documentation is not
built.

* gnu/packages/ghostscript.scm (ghostscript)[source]: Use git-fetch. Adjust
snippet. Replace patches.
[outputs]: Delete field.
[arguments]<configure-flags>: Add "--without-xps". Remove "--enable-dynamic".
<#:phases>: Add 'unbundle' and 'generate-scfdtab' phases.
[native-inputs]: Add autoconf and automake.
[inputs]: Add extract, ijs, lcms2mt, memento and openjpeg.
[license]: Add missing licenses.
(ghostscript/fixed): Delete variable.
* gnu/packages/patches/ghostscript-CVE-2023-36664.patch: Delete file.
* gnu/packages/patches/ghostscript-CVE-2023-36664-fixup.patch: Delete file.
* gnu/packages/patches/ghostscript-leptonica-hurd.patch: Delete file.
* gnu/packages/patches/ghostscript-no-header-creationdate.patch: Delete file.
* gnu/packages/patches/ghostscript-no-header-id.patch: Delete file.
* gnu/packages/patches/ghostscript-no-header-uuid.patch: Delete file.
* gnu/packages/patches/ghostscript-reproducibility.patch: New file.
* gnu/local.mk (dist_patch_DATA): Adjust accordingly.
---
 gnu/local.mk                                  |   7 +-
 gnu/packages/ghostscript.scm                  | 142 +++++++++++++-----
 .../ghostscript-CVE-2023-36664-fixup.patch    |  56 -------
 .../patches/ghostscript-CVE-2023-36664.patch  | 142 ------------------
 .../patches/ghostscript-leptonica-hurd.patch  |  78 ----------
 .../ghostscript-no-header-creationdate.patch  |  46 ------
 .../patches/ghostscript-no-header-id.patch    |  57 -------
 .../patches/ghostscript-no-header-uuid.patch  |  49 ------
 .../patches/ghostscript-reproducibility.patch |  26 ++++
 9 files changed, 129 insertions(+), 474 deletions(-)
 delete mode 100644 gnu/packages/patches/ghostscript-CVE-2023-36664-fixup.patch
 delete mode 100644 gnu/packages/patches/ghostscript-CVE-2023-36664.patch
 delete mode 100644 gnu/packages/patches/ghostscript-leptonica-hurd.patch
 delete mode 100644 gnu/packages/patches/ghostscript-no-header-creationdate.patch
 delete mode 100644 gnu/packages/patches/ghostscript-no-header-id.patch
 delete mode 100644 gnu/packages/patches/ghostscript-no-header-uuid.patch
 create mode 100644 gnu/packages/patches/ghostscript-reproducibility.patch

diff --git a/gnu/local.mk b/gnu/local.mk
index 2fc14e68fe..c44c21ffa0 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1338,12 +1338,7 @@ dist_patch_DATA =						\
   %D%/packages/patches/ghc-language-haskell-extract-ghc-8.10.patch	\
   %D%/packages/patches/ghc-memory-fix-32bit.patch		\
   %D%/packages/patches/ghc-persistent-fix-32bit.patch		\
-  %D%/packages/patches/ghostscript-CVE-2023-36664.patch		\
-  %D%/packages/patches/ghostscript-CVE-2023-36664-fixup.patch	\
-  %D%/packages/patches/ghostscript-leptonica-hurd.patch		\
-  %D%/packages/patches/ghostscript-no-header-id.patch		\
-  %D%/packages/patches/ghostscript-no-header-uuid.patch		\
-  %D%/packages/patches/ghostscript-no-header-creationdate.patch \
+  %D%/packages/patches/ghostscript-reproducibility.patch	\
   %D%/packages/patches/git-filter-repo-generate-doc.patch	\
   %D%/packages/patches/gklib-suitesparse.patch			\
   %D%/packages/patches/glib-appinfo-watch.patch			\
diff --git a/gnu/packages/ghostscript.scm b/gnu/packages/ghostscript.scm
index 40891676b3..2bc168db68 100644
--- a/gnu/packages/ghostscript.scm
+++ b/gnu/packages/ghostscript.scm
@@ -215,43 +215,61 @@ (define-public psutils
 (define-public ghostscript
   (package
     (name "ghostscript")
-    (version "9.56.1")
-    (replacement ghostscript/fixed)
+    (version "10.03.1")
     (source
      (origin
-       (method url-fetch)
-       (uri (string-append "https://github.com/ArtifexSoftware/"
-                           "ghostpdl-downloads/releases/download/gs"
-                           (string-delete #\. version)
-                           "/ghostscript-" version ".tar.xz"))
+       (method git-fetch)
+       (uri (git-reference
+             (url "git://git.ghostscript.com/ghostpdl.git")
+             (commit (string-append "ghostpdl-" version))))
+       (file-name (git-file-name name version))
        (sha256
         (base32
-         "1r5qash65m6ignki6z72q4rlai9ka99xrxnmqd19n02has00cd6l"))
-       (patches (search-patches "ghostscript-no-header-creationdate.patch"
-                                "ghostscript-no-header-id.patch"
-                                "ghostscript-no-header-uuid.patch"))
+         "1rzgk12vmv3062l8w7vw5kdsgfphmpwbq38alv2qgiz5wpalsrds"))
+       (patches (search-patches "ghostscript-reproducibility.patch"))
        (modules '((guix build utils)))
        (snippet
-        ;; Remove bundled libraries. The bundled OpenJPEG is a patched fork so
-        ;; we leave it, at least for now.
-        ;; TODO Try unbundling ijs, which is developed alongside Ghostscript.
-        ;; Likewise for the thread-safe lcms2 fork called "lcms2art".
         '(begin
-           (for-each delete-file-recursively '("freetype" "jbig2dec" "jpeg"
-                                               "libpng" "tiff" "zlib"))))))
+           (for-each
+            delete-file-recursively
+            (append
+             (list
+              ;; Bundled software (some non-free)
+              "cups" "expat" "freetype" "ijs" "jbig2dec" "jpeg" "jpegxr"
+              "lcms2mt" "libpng" "openjpeg" "pcl" "tiff" "xps" "zlib"
+              ;; Non-free ICC profile
+              "doc/language-bindings/images"
+              ;; Contain autogenerated files
+              "demos/csharp/windows"
+              "toolbin/Acrobat2Tiff"
+              "base/scfdtab.c"
+              "demos/java/jni/gs_jni/com_artifex_gsjava_util_NativePointer.h"
+              "demos/java/jni/gs_jni/com_artifex_gsjava_GSAPI.h"
+              "doc/GS9_Color_Management.pdf"
+              "doc/Ghostscript.pdf"
+              "doc/pclxps/ghostpdl.pdf")
+             (find-files "doc/src/_static" "cm-fig.*\\.png")))
+           (for-each
+            (lambda (name)
+              (delete-file (string-append "arch/" name)))
+            '("osx-x86-x86_64-ppc-gcc.h"
+              "windows-arm-msvc.h"
+              "windows-x64-msvc.h"
+              "windows-x86-msvc.h"))
+           (delete-file "base/memento.c")
+           (delete-file "base/memento.h")))))
     (build-system gnu-build-system)
-    (outputs '("out" "doc"))            ;19 MiB of HTML/PS doc + examples
     (arguments
      (list
-      #:disallowed-references '("doc")
       #:configure-flags
       #~(list (string-append "LDFLAGS=-Wl,-rpath=" #$output "/lib")
               "--with-system-libtiff"
+              ;; Requires jpegxr, which has a nonfree license.
+              "--without-xps"
               "LIBS=-lz"
               (string-append "ZLIBDIR="
                              (dirname (search-input-file %build-inputs
                                                          "include/zlib.h")))
-              "--enable-dynamic"
               "--disable-compile-inits"
               (string-append "--with-fontpath="
                              (search-input-directory
@@ -270,16 +288,19 @@ (define-public ghostscript
                      '()))
       #:phases
       #~(modify-phases %standard-phases
-          #$@(if (target-hurd?)
-                 #~((add-after 'unpack 'patch-leptonica
-                      (lambda _
-                        (let ((patch-file
-                               #$(local-file
-                                  (search-patch
-                                   "ghostscript-leptonica-hurd.patch"))))
-                          (with-directory-excursion "leptonica"
-                            (invoke "patch" "--force" "-p1" "-i" patch-file))))))
-                 #~())
+          (add-after 'unpack 'unbundle
+            (lambda _
+              (substitute* '("base/lib.mak" "base/tiff.mak"
+                             "devices/dcontrib.mak" "devices/devs.mak"
+                             "psi/int.mak")
+                ((".*:\\$\\(GLSRC\\)memento\\.h".*) ""))
+              (substitute* "base/lib.mak"
+                ((" \\$\\(GLOBJ\\)memento\\.\\$\\(OBJ\\)") ""))))
+          (add-before 'bootstrap 'patch-autogen
+            (lambda _
+              (substitute* "autogen.sh"
+                (("^autoreconf.*" orig)
+                 (string-append orig "\nexit\n")))))
           (add-before 'configure 'create-output-directory
             (lambda _
               ;; The configure script refuses to function if the directory
@@ -287,7 +308,6 @@ (define-public ghostscript
               (mkdir-p (string-append #$output "/lib"))))
           (add-after 'configure 'remove-doc-reference
             (lambda _
-              ;; Don't retain a reference to the 'doc' output in 'gs'.
               ;; The only use of this definition is in the output of
               ;; 'gs --help', so this change is fine.
               (substitute* "base/gscdef.c"
@@ -305,6 +325,25 @@ (define-public ghostscript
                          (("^AUXEXTRALIBS=(.*)$" _ value)
                           (string-append "AUXEXTRALIBS = -lz " value "\n"))))))
                  '())
+          (add-before 'build 'generate-scfdtab
+            (lambda _
+              (invoke "make" "obj/arch.h")
+              ;; These changes are necessary for cross builds, where there can
+              ;; be a conflict for int64_t.
+              (with-directory-excursion "base"
+                (copy-file "scommon.h" "tmpfile")
+                (substitute* "scommon.h"
+                  ((".*#include \"stdint_\\.h\".*") ""))
+                (let ((include-path (getenv "C_INCLUDE_PATH")))
+                  ;; For cross builds
+                  (setenv "C_INCLUDE_PATH"
+                          (string-append #$(this-package-input "memento")
+                                         "/include"))
+                  (invoke "gcc" "-Dfopen=fopen" "-I../obj"
+                          "scfdgen.c" "scfetab.c" "-o" "scfdgen")
+                  (setenv "C_INCLUDE_PATH" include-path))
+                (rename-file "tmpfile" "scommon.h")
+                (invoke "./scfdgen"))))
           (replace 'build
             (lambda _
               ;; Build 'libgs.so', but don't build the statically-linked 'gs'
@@ -320,7 +359,9 @@ (define-public ghostscript
               (symlink "gsc" (string-append #$output "/bin/gs")))))))
     (native-inputs
      (append
-      (list perl
+      (list autoconf
+            automake
+            perl
             pkg-config                  ;needed for freetype
             python-minimal-wrapper
             tcl)
@@ -330,14 +371,19 @@ (define-public ghostscript
           (list zlib libjpeg-turbo)
           '())))
     (inputs
-     (list fontconfig
+     (list extract
+           fontconfig
            freetype
            font-ghostscript
+           ijs
            jbig2dec
+           lcms2mt
            libjpeg-turbo
            libpaper
            libpng
            libtiff
+           memento
+           openjpeg
            zlib))
     (synopsis "PostScript and PDF interpreter")
     (description
@@ -346,13 +392,29 @@ (define-public ghostscript
 capabilities of the PostScript language.  It supports a wide variety of
 output file formats and printers.")
     (home-page "https://www.ghostscript.com/")
-    (license license:agpl3+)))
-
-(define ghostscript/fixed
-  (package-with-patches
-   ghostscript
-   (search-patches "ghostscript-CVE-2023-36664.patch"
-                   "ghostscript-CVE-2023-36664-fixup.patch")))
+    (license
+     (list
+      ;; Most of the code is distributed under the AGPLv3+.
+      license:agpl3+
+      ;; Some files (or parts of files) are distributed under other,
+      ;; compatible licenses.
+      (license:non-copyleft "file://devices/gdev4693.c")
+      (license:non-copyleft "file://devices/gdevifno.c")
+      (license:non-copyleft "file://base/icc34.h")
+      (license:non-copyleft "file://base/CMap/78-EUC-H")
+      license:asl2.0
+      license:bsd-3
+      license:expat
+      license:freetype
+      license:gpl1+
+      license:gpl2+
+      license:isc
+      license:lgpl2.1
+      license:public-domain
+      license:zlib
+      ;; Additional exception for the font files in Resource/Font for
+      ;; inclusion in Postscript and PDF files.
+      (license:non-copyleft "file://LICENSE")))))
 
 (define-public ghostscript/x
   (package/inherit ghostscript
diff --git a/gnu/packages/patches/ghostscript-CVE-2023-36664-fixup.patch b/gnu/packages/patches/ghostscript-CVE-2023-36664-fixup.patch
deleted file mode 100644
index c2a222701f..0000000000
--- a/gnu/packages/patches/ghostscript-CVE-2023-36664-fixup.patch
+++ /dev/null
@@ -1,56 +0,0 @@
-From 0974e4f2ac0005d3731e0b5c13ebc7e965540f4d Mon Sep 17 00:00:00 2001
-From: Chris Liddell <chris.liddell@artifex.com>
-Date: Wed, 14 Jun 2023 09:08:12 +0100
-Subject: [PATCH] Bug 706778: 706761 revisit
-
-Two problems with the original commit. The first a silly typo inverting the
-logic of a test.
-
-The second was forgetting that we actually actually validate two candidate
-strings for pipe devices. One with the expected "%pipe%" prefix, the other
-using the pipe character prefix: "|".
-
-This addresses both those.
----
- base/gpmisc.c   | 2 +-
- base/gslibctx.c | 4 ++--
- 2 files changed, 3 insertions(+), 3 deletions(-)
-
-diff --git a/base/gpmisc.c b/base/gpmisc.c
-index 58511270e..2b0064bea 100644
---- a/base/gpmisc.c
-+++ b/base/gpmisc.c
-@@ -1081,7 +1081,7 @@ gp_validate_path_len(const gs_memory_t *mem,
-     /* "%pipe%" do not follow the normal rules for path definitions, so we
-        don't "reduce" them to avoid unexpected results
-      */
--    if (len > 5 && memcmp(path, "%pipe", 5) != 0) {
-+    if (path[0] == '|' || (len > 5 && memcmp(path, "%pipe", 5) == 0)) {
-         bufferfull = buffer = (char *)gs_alloc_bytes(mem->thread_safe_memory, len + 1, "gp_validate_path");
-         if (buffer == NULL)
-             return gs_error_VMerror;
-diff --git a/base/gslibctx.c b/base/gslibctx.c
-index d2a1aa91d..42af99090 100644
---- a/base/gslibctx.c
-+++ b/base/gslibctx.c
-@@ -743,7 +743,7 @@ gs_add_control_path_len_flags(const gs_memory_t *mem, gs_path_control_t type, co
-     /* "%pipe%" do not follow the normal rules for path definitions, so we
-        don't "reduce" them to avoid unexpected results
-      */
--    if (len > 5 && memcmp(path, "%pipe", 5) != 0) {
-+    if (path[0] == '|' || (len > 5 && memcmp(path, "%pipe", 5) == 0)) {
-         buffer = (char *)gs_alloc_bytes(core->memory, len + 1, "gs_add_control_path_len");
-         if (buffer == NULL)
-             return gs_error_VMerror;
-@@ -850,7 +850,7 @@ gs_remove_control_path_len_flags(const gs_memory_t *mem, gs_path_control_t type,
-     /* "%pipe%" do not follow the normal rules for path definitions, so we
-        don't "reduce" them to avoid unexpected results
-      */
--    if (len > 5 && memcmp(path, "%pipe", 5) != 0) {
-+    if (path[0] == '|' || (len > 5 && memcmp(path, "%pipe", 5) == 0)) {
-         buffer = (char *)gs_alloc_bytes(core->memory, len + 1, "gs_remove_control_path_len");
-         if (buffer == NULL)
-             return gs_error_VMerror;
--- 
-2.34.1
-
diff --git a/gnu/packages/patches/ghostscript-CVE-2023-36664.patch b/gnu/packages/patches/ghostscript-CVE-2023-36664.patch
deleted file mode 100644
index e9c53c1f87..0000000000
--- a/gnu/packages/patches/ghostscript-CVE-2023-36664.patch
+++ /dev/null
@@ -1,142 +0,0 @@
-From 505eab7782b429017eb434b2b95120855f2b0e3c Mon Sep 17 00:00:00 2001
-From: Chris Liddell <chris.liddell@artifex.com>
-Date: Wed, 7 Jun 2023 10:23:06 +0100
-Subject: [PATCH] Bug 706761: Don't "reduce" %pipe% file names for permission
- validation
-
-For regular file names, we try to simplfy relative paths before we use them.
-
-Because the %pipe% device can, effectively, accept command line calls, we
-shouldn't be simplifying that string, because the command line syntax can end
-up confusing the path simplifying code. That can result in permitting a pipe
-command which does not match what was originally permitted.
-
-Special case "%pipe" in the validation code so we always deal with the entire
-string.
----
- base/gpmisc.c   | 31 +++++++++++++++++++--------
- base/gslibctx.c | 56 ++++++++++++++++++++++++++++++++++++-------------
- 2 files changed, 64 insertions(+), 23 deletions(-)
-
-diff --git a/base/gpmisc.c b/base/gpmisc.c
-index 5f39ebba7..2fb87f769 100644
---- a/base/gpmisc.c
-+++ b/base/gpmisc.c
-@@ -1076,16 +1076,29 @@ gp_validate_path_len(const gs_memory_t *mem,
-              && !memcmp(path + cdirstrl, dirsepstr, dirsepstrl)) {
-           prefix_len = 0;
-     }
--    rlen = len+1;
--    bufferfull = (char *)gs_alloc_bytes(mem->thread_safe_memory, rlen + prefix_len, "gp_validate_path");
--    if (bufferfull == NULL)
--        return gs_error_VMerror;
--
--    buffer = bufferfull + prefix_len;
--    if (gp_file_name_reduce(path, (uint)len, buffer, &rlen) != gp_combine_success)
--        return gs_error_invalidfileaccess;
--    buffer[rlen] = 0;
- 
-+    /* "%pipe%" do not follow the normal rules for path definitions, so we
-+       don't "reduce" them to avoid unexpected results
-+     */
-+    if (len > 5 && memcmp(path, "%pipe", 5) != 0) {
-+        bufferfull = buffer = (char *)gs_alloc_bytes(mem->thread_safe_memory, len + 1, "gp_validate_path");
-+        if (buffer == NULL)
-+            return gs_error_VMerror;
-+        memcpy(buffer, path, len);
-+        buffer[len] = 0;
-+        rlen = len;
-+    }
-+    else {
-+        rlen = len+1;
-+        bufferfull = (char *)gs_alloc_bytes(mem->thread_safe_memory, rlen + prefix_len, "gp_validate_path");
-+        if (bufferfull == NULL)
-+            return gs_error_VMerror;
-+
-+        buffer = bufferfull + prefix_len;
-+        if (gp_file_name_reduce(path, (uint)len, buffer, &rlen) != gp_combine_success)
-+            return gs_error_invalidfileaccess;
-+        buffer[rlen] = 0;
-+    }
-     while (1) {
-         switch (mode[0])
-         {
-diff --git a/base/gslibctx.c b/base/gslibctx.c
-index eb566ed06..d2a1aa91d 100644
---- a/base/gslibctx.c
-+++ b/base/gslibctx.c
-@@ -740,14 +740,28 @@ gs_add_control_path_len_flags(const gs_memory_t *mem, gs_path_control_t type, co
-             return gs_error_rangecheck;
-     }
- 
--    rlen = len+1;
--    buffer = (char *)gs_alloc_bytes(core->memory, rlen, "gp_validate_path");
--    if (buffer == NULL)
--        return gs_error_VMerror;
-+    /* "%pipe%" do not follow the normal rules for path definitions, so we
-+       don't "reduce" them to avoid unexpected results
-+     */
-+    if (len > 5 && memcmp(path, "%pipe", 5) != 0) {
-+        buffer = (char *)gs_alloc_bytes(core->memory, len + 1, "gs_add_control_path_len");
-+        if (buffer == NULL)
-+            return gs_error_VMerror;
-+        memcpy(buffer, path, len);
-+        buffer[len] = 0;
-+        rlen = len;
-+    }
-+    else {
-+        rlen = len + 1;
- 
--    if (gp_file_name_reduce(path, (uint)len, buffer, &rlen) != gp_combine_success)
--        return gs_error_invalidfileaccess;
--    buffer[rlen] = 0;
-+        buffer = (char *)gs_alloc_bytes(core->memory, rlen, "gs_add_control_path_len");
-+        if (buffer == NULL)
-+            return gs_error_VMerror;
-+
-+        if (gp_file_name_reduce(path, (uint)len, buffer, &rlen) != gp_combine_success)
-+            return gs_error_invalidfileaccess;
-+        buffer[rlen] = 0;
-+    }
- 
-     n = control->num;
-     for (i = 0; i < n; i++)
-@@ -833,14 +847,28 @@ gs_remove_control_path_len_flags(const gs_memory_t *mem, gs_path_control_t type,
-             return gs_error_rangecheck;
-     }
- 
--    rlen = len+1;
--    buffer = (char *)gs_alloc_bytes(core->memory, rlen, "gp_validate_path");
--    if (buffer == NULL)
--        return gs_error_VMerror;
-+    /* "%pipe%" do not follow the normal rules for path definitions, so we
-+       don't "reduce" them to avoid unexpected results
-+     */
-+    if (len > 5 && memcmp(path, "%pipe", 5) != 0) {
-+        buffer = (char *)gs_alloc_bytes(core->memory, len + 1, "gs_remove_control_path_len");
-+        if (buffer == NULL)
-+            return gs_error_VMerror;
-+        memcpy(buffer, path, len);
-+        buffer[len] = 0;
-+        rlen = len;
-+    }
-+    else {
-+        rlen = len+1;
- 
--    if (gp_file_name_reduce(path, (uint)len, buffer, &rlen) != gp_combine_success)
--        return gs_error_invalidfileaccess;
--    buffer[rlen] = 0;
-+        buffer = (char *)gs_alloc_bytes(core->memory, rlen, "gs_remove_control_path_len");
-+        if (buffer == NULL)
-+            return gs_error_VMerror;
-+
-+        if (gp_file_name_reduce(path, (uint)len, buffer, &rlen) != gp_combine_success)
-+            return gs_error_invalidfileaccess;
-+        buffer[rlen] = 0;
-+    }
- 
-     n = control->num;
-     for (i = 0; i < n; i++) {
--- 
-2.34.1
-
diff --git a/gnu/packages/patches/ghostscript-leptonica-hurd.patch b/gnu/packages/patches/ghostscript-leptonica-hurd.patch
deleted file mode 100644
index 124365b3e6..0000000000
--- a/gnu/packages/patches/ghostscript-leptonica-hurd.patch
+++ /dev/null
@@ -1,78 +0,0 @@
-Upstream status: This patch was taken from leptonica upstream.
-
-Backported to ghostscripts bundled leptonica.
-
-From f04da7c816feb1d5f689c34f3d0e7e3621edf1f5 Mon Sep 17 00:00:00 2001
-From: Samuel Thibault <samuel.thibault@ens-lyon.org>
-Date: Wed, 1 Feb 2023 19:35:43 +0100
-Subject: [PATCH] Fix GNU/Hurd build
-
-There is no PATH_MAX limitation on GNU/Hurd, and realpath() can be
-safely be used with its second parameter set to NULL (as required by
-posix since its version 2001).
----
- src/sarray1.c | 29 +++++++++++++++++++++++------
- 1 file changed, 23 insertions(+), 6 deletions(-)
-
---- a/src/sarray1.c	2023-06-13 12:31:13.393672916 +0200
-+++ a/src/sarray1.c	2023-06-13 12:34:13.574237149 +0200
-@@ -1953,7 +1953,11 @@
- SARRAY *
- getFilenamesInDirectory(const char  *dirname)
- {
-+#if _POSIX_VERSION >= 200112 || defined(__GLIBC__)
-+char           *dir;
-+#else
- char            dir[PATH_MAX + 1];
-+#endif
- char           *realdir, *stat_path, *ignore;
- size_t          size;
- SARRAY         *safiles;
-@@ -1976,17 +1980,28 @@
-             * If the file or directory exists, realpath returns its path;
-               else it returns NULL.
-             * If the second arg to realpath is passed in, the canonical path
--              is returned there.  Use a buffer of sufficient size.  If the
--              second arg is NULL, the path is malloc'd and returned if the
--              file or directory exists.
--           We pass in a buffer for the second arg, and check that the canonical
--           directory path was made.  The existence of the directory is checked
--           later, after its actual path is returned by genPathname().  */
-+              is returned there.  Use a buffer of sufficient size.
-+              We pass in a buffer for the second arg, and check that the
-+              canonical directory path was made.  The existence of the
-+              directory is checked later, after its actual path is returned by
-+              genPathname().
-+              With GNU libc or Posix 2001, if the second arg is NULL, the path
-+              is malloc'd and returned if the file or directory exists.
-+           */
-+#if _POSIX_VERSION >= 200112 || defined(__GLIBC__)
-+    dir = realpath(dirname, NULL);
-+    if (dir == NULL)
-+        return (SARRAY *)ERROR_PTR("dir not made", __func__, NULL);
-+#else
-     dir[0] = '\0';  /* init empty in case realpath() fails to write it */
-     ignore = realpath(dirname, dir);
-     if (dir[0] == '\0')
-         return (SARRAY *)ERROR_PTR("dir not made", procName, NULL);
-+#endif
-     realdir = genPathname(dir, NULL);
-+#if _POSIX_VERSION >= 200112 || defined(__GLIBC__)
-+    LEPT_FREE(dir);
-+#endif
-     if ((pdir = opendir(realdir)) == NULL) {
-         LEPT_FREE(realdir);
-         return (SARRAY *)ERROR_PTR("pdir not opened", procName, NULL);
-@@ -1998,10 +2013,12 @@
-         stat_ret = fstatat(dfd, pdirentry->d_name, &st, 0);
- #else
-         size = strlen(realdir) + strlen(pdirentry->d_name) + 2;
-+#if _POSIX_VERSION < 200112 && !defined(__GLIBC__)
-         if (size > PATH_MAX) {
-             L_ERROR("size = %zu too large; skipping\n", procName, size);
-             continue;
-         }
-+#endif
-         stat_path = (char *)LEPT_CALLOC(size, 1);
-         snprintf(stat_path, size, "%s/%s", realdir, pdirentry->d_name);
-         stat_ret = stat(stat_path, &st);
diff --git a/gnu/packages/patches/ghostscript-no-header-creationdate.patch b/gnu/packages/patches/ghostscript-no-header-creationdate.patch
deleted file mode 100644
index 493693b78d..0000000000
--- a/gnu/packages/patches/ghostscript-no-header-creationdate.patch
+++ /dev/null
@@ -1,46 +0,0 @@
-This patch makes emission of /CreationDate and /ModDate headers optional.
-
-If the environment variable GS_GENERATE_UUIDS is set to "0" or "no", it will
-not write out the "/ID" field (if that's permissible).
-
-Upstream does not want to do this.
-
-See: https://bugs.ghostscript.com/show_bug.cgi?id=698208
-diff --git a/devices/vector/gdevpdf.c b/devices/vector/gdevpdf.c
-index cb268f62e..c5abefde2 100644
---- a/devices/vector/gdevpdf.c
-+++ b/devices/vector/gdevpdf.c
-@@ -425,6 +425,9 @@ pdf_initialize_ids(gx_device_pdf * pdev)
-      * date and time, rather than (for example) %%CreationDate from the
-      * PostScript file.  We think this is wrong, but we do the same.
-      */
-+    if (!getenv("GS_GENERATE_UUIDS") ||
-+        (strcasecmp(getenv("GS_GENERATE_UUIDS"), "0") != 0 &&
-+         strcasecmp(getenv("GS_GENERATE_UUIDS"), "no") != 0))
-     {
-         struct tm tms;
-         time_t t;
-diff --git a/devices/vector/gdevpdfe.c b/devices/vector/gdevpdfe.c
-index ec011d8ba..f083f1e93 100644
---- a/devices/vector/gdevpdfe.c
-+++ b/devices/vector/gdevpdfe.c
-@@ -696,6 +696,9 @@ pdf_write_document_metadata(gx_device_pdf *pdev, const byte digest[6])
-             pdf_xml_attribute_name(s, "xmlns:xmp");
-             pdf_xml_attribute_value(s, "http://ns.adobe.com/xap/1.0/");
-             pdf_xml_tag_end(s);
-+            if (!getenv("GS_GENERATE_UUIDS") ||
-+                (strcasecmp(getenv("GS_GENERATE_UUIDS"), "0") != 0 &&
-+                 strcasecmp(getenv("GS_GENERATE_UUIDS"), "no") != 0))
-             {
-                 pdf_xml_tag_open_beg(s, "xmp:ModifyDate");
-                 pdf_xml_tag_end(s);
-@@ -704,6 +707,9 @@ pdf_write_document_metadata(gx_device_pdf *pdev, const byte digest[6])
-                 pdf_xml_tag_close(s, "xmp:ModifyDate");
-                 pdf_xml_newline(s);
-             }
-+            if (!getenv("GS_GENERATE_UUIDS") ||
-+                (strcasecmp(getenv("GS_GENERATE_UUIDS"), "0") != 0 &&
-+                 strcasecmp(getenv("GS_GENERATE_UUIDS"), "no") != 0))
-             {
-                 pdf_xml_tag_open_beg(s, "xmp:CreateDate");
-                 pdf_xml_tag_end(s);
diff --git a/gnu/packages/patches/ghostscript-no-header-id.patch b/gnu/packages/patches/ghostscript-no-header-id.patch
deleted file mode 100644
index ef518b0fb2..0000000000
--- a/gnu/packages/patches/ghostscript-no-header-id.patch
+++ /dev/null
@@ -1,57 +0,0 @@
-This patch makes the "/ID" field optional.
-
-If the environment variable GS_GENERATE_UUIDS is set to "0" or "no", it will
-not write out the "/ID" field (if that's permissible).
-
-Upstream does not want to do this.
-
-See: https://bugs.ghostscript.com/show_bug.cgi?id=698208
-diff --git a/devices/vector/gdevpdf.c b/devices/vector/gdevpdf.c
-index c5abefde2..3859fc088 100644
---- a/devices/vector/gdevpdf.c
-+++ b/devices/vector/gdevpdf.c
-@@ -1909,8 +1909,11 @@ static int pdf_linearise(gx_device_pdf *pdev, pdf_linearisation_t *linear_params
-      * +1 for the linearisation dict and +1 for the primary hint stream.
-      */
-     linear_params->FirsttrailerOffset = gp_ftell(linear_params->Lin_File.file);
--    gs_snprintf(LDict, sizeof(LDict), "\ntrailer\n<</Size %ld/Info %d 0 R/Root %d 0 R/ID[%s%s]/Prev %d>>\nstartxref\r\n0\n%%%%EOF\n        \n",
--        linear_params->LastResource + 3, pdev->ResourceUsage[linear_params->Info_id].NewObjectNumber, pdev->ResourceUsage[linear_params->Catalog_id].NewObjectNumber, fileID, fileID, 0);
-+    gs_snprintf(LDict, sizeof(LDict), "\ntrailer\n<</Size %ld/Info %d 0 R/Root %d 0 R",
-+        linear_params->LastResource + 3, pdev->ResourceUsage[linear_params->Info_id].NewObjectNumber, pdev->ResourceUsage[linear_params->Catalog_id].NewObjectNumber);
-+    if (pdev->OwnerPassword.size > 0 || !(!getenv("GS_GENERATE_UUIDS") || (strcasecmp(getenv("GS_GENERATE_UUIDS"), "0") != 0 && strcasecmp(getenv("GS_GENERATE_UUIDS"), "no") != 0))) /* ID is mandatory when encrypting */
-+        gs_snprintf(LDict, sizeof(LDict), "/ID[%s%s]", fileID, fileID);
-+    gs_snprintf(LDict, sizeof(LDict), "/Prev %d>>\nstartxref\r\n0\n%%%%EOF\n        \n", 0);
-     gp_fwrite(LDict, strlen(LDict), 1, linear_params->Lin_File.file);
- 
-     /* Write document catalog (Part 4) */
-@@ -2445,8 +2448,11 @@ static int pdf_linearise(gx_device_pdf *pdev, pdf_linearisation_t *linear_params
-     if (code != 0)
-         return_error(gs_error_ioerror);
- 
--    gs_snprintf(LDict, sizeof(LDict), "\ntrailer\n<</Size %ld/Info %d 0 R/Root %d 0 R/ID[%s%s]/Prev %"PRId64">>\nstartxref\r\n0\n%%%%EOF\n",
--        linear_params->LastResource + 3, pdev->ResourceUsage[linear_params->Info_id].NewObjectNumber, pdev->ResourceUsage[linear_params->Catalog_id].NewObjectNumber, fileID, fileID, mainxref);
-+    gs_snprintf(LDict, sizeof(LDict), "\ntrailer\n<</Size %ld/Info %d 0 R/Root %d 0 R",
-+        linear_params->LastResource + 3, pdev->ResourceUsage[linear_params->Info_id].NewObjectNumber, pdev->ResourceUsage[linear_params->Catalog_id].NewObjectNumber);
-+    if (pdev->OwnerPassword.size > 0 || !(!getenv("GS_GENERATE_UUIDS") || (strcasecmp(getenv("GS_GENERATE_UUIDS"), "0") != 0 || strcasecmp(getenv("GS_GENERATE_UUIDS"), "no") != 0))) /* ID is mandatory when encrypting */
-+        gs_snprintf(LDict, sizeof(LDict), "/ID[%s%s]", fileID, fileID);
-+    gs_snprintf(LDict, sizeof(LDict), "/Prev %"PRId64">>\nstartxref\r\n0\n%%%%EOF\n", mainxref);
-     gp_fwrite(LDict, strlen(LDict), 1, linear_params->sfile);
- 
-     code = gp_fseek(linear_params->sfile, pdev->ResourceUsage[HintStreamObj].LinearisedOffset, SEEK_SET);
-@@ -3139,10 +3145,12 @@ pdf_close(gx_device * dev)
-             stream_puts(s, "trailer\n");
-             pprintld3(s, "<< /Size %ld /Root %ld 0 R /Info %ld 0 R\n",
-                   pdev->next_id, Catalog_id, Info_id);
--            stream_puts(s, "/ID [");
--            psdf_write_string(pdev->strm, pdev->fileID, sizeof(pdev->fileID), 0);
--            psdf_write_string(pdev->strm, pdev->fileID, sizeof(pdev->fileID), 0);
--            stream_puts(s, "]\n");
-+            if (pdev->OwnerPassword.size > 0 || !(!getenv("GS_GENERATE_UUIDS") || (strcasecmp(getenv("GS_GENERATE_UUIDS"), "0") != 0 || strcasecmp(getenv("GS_GENERATE_UUIDS"), "no") != 0))) { /* ID is mandatory when encrypting */
-+                stream_puts(s, "/ID [");
-+                psdf_write_string(pdev->strm, pdev->fileID, sizeof(pdev->fileID), 0);
-+                psdf_write_string(pdev->strm, pdev->fileID, sizeof(pdev->fileID), 0);
-+                stream_puts(s, "]\n");
-+            }
-             if (pdev->OwnerPassword.size > 0) {
-                 pprintld1(s, "/Encrypt %ld 0 R ", Encrypt_id);
-             }
diff --git a/gnu/packages/patches/ghostscript-no-header-uuid.patch b/gnu/packages/patches/ghostscript-no-header-uuid.patch
deleted file mode 100644
index b277a4bc2e..0000000000
--- a/gnu/packages/patches/ghostscript-no-header-uuid.patch
+++ /dev/null
@@ -1,49 +0,0 @@
-This patch makes the UUIDs in the XMP header optional, depending on the
-setting of the environment variable GS_GENERATE_UUIDS.
-
-If the environment variable GS_GENERATE_UUIDS is set to "0" or "no", it will
-not write out the Document UUID field and also will write the Instance ID
-field value as "".
-
-Upstream does not want to do this.
-
-See: https://bugs.ghostscript.com/show_bug.cgi?id=698208
-diff --git a/devices/vector/gdevpdfe.c b/devices/vector/gdevpdfe.c
-index f083f1e93..a19c64ac0 100644
---- a/devices/vector/gdevpdfe.c
-+++ b/devices/vector/gdevpdfe.c
-@@ -624,7 +624,7 @@ pdf_write_document_metadata(gx_device_pdf *pdev, const byte digest[6])
-         return code;
- 
-     /* PDF/A XMP reference recommends setting UUID to empty. If not empty must be a URI */
--    if (pdev->PDFA != 0)
-+    if (pdev->PDFA != 0 || (getenv("GS_GENERATE_UUIDS") && (strcasecmp(getenv("GS_GENERATE_UUIDS"), "0") == 0 || strcasecmp(getenv("GS_GENERATE_UUIDS"), "no") == 0)))
-         instance_uuid[0] = 0x00;
- 
-     cre_date_time_len = pdf_get_docinfo_item(pdev, "/CreationDate", cre_date_time, sizeof(cre_date_time));
-@@ -730,14 +730,17 @@ pdf_write_document_metadata(gx_device_pdf *pdev, const byte digest[6])
-             pdf_xml_tag_close(s, "rdf:Description");
-             pdf_xml_newline(s);
- 
--            pdf_xml_tag_open_beg(s, "rdf:Description");
--            pdf_xml_copy(s, " rdf:about=\"\"");
--            pdf_xml_attribute_name(s, "xmlns:xapMM");
--            pdf_xml_attribute_value(s, "http://ns.adobe.com/xap/1.0/mm/");
--            pdf_xml_attribute_name(s, "xapMM:DocumentID");
--            pdf_xml_attribute_value(s, document_uuid);
--            pdf_xml_tag_end_empty(s);
--            pdf_xml_newline(s);
-+            if (!getenv("GS_GENERATE_UUIDS") || (strcasecmp(getenv("GS_GENERATE_UUIDS"), "0") != 0 && strcasecmp(getenv("GS_GENERATE_UUIDS"), "no") != 0))
-+            {
-+                pdf_xml_tag_open_beg(s, "rdf:Description");
-+                pdf_xml_copy(s, " rdf:about=\"\"");
-+                pdf_xml_attribute_name(s, "xmlns:xapMM");
-+                pdf_xml_attribute_value(s, "http://ns.adobe.com/xap/1.0/mm/");
-+                pdf_xml_attribute_name(s, "xapMM:DocumentID");
-+                pdf_xml_attribute_value(s, document_uuid);
-+                pdf_xml_tag_end_empty(s);
-+                pdf_xml_newline(s);
-+            }
- 
-             pdf_xml_tag_open_beg(s, "rdf:Description");
-             pdf_xml_copy(s, " rdf:about=\"\"");
diff --git a/gnu/packages/patches/ghostscript-reproducibility.patch b/gnu/packages/patches/ghostscript-reproducibility.patch
new file mode 100644
index 0000000000..9afb052a09
--- /dev/null
+++ b/gnu/packages/patches/ghostscript-reproducibility.patch
@@ -0,0 +1,26 @@
+Set the OmitDateInfo, OmitXMP and OmitID controls to 1 if the environment
+variable GS_GENERATE_UUIDS is set to "0" or "no".
+
+For reference, see:
+https://git.ghostscript.com/?p=ghostpdl.git;a=commit;h=1158b25fe28f9d60c65417712f16a0f9cccac95c
+and https://bugs.ghostscript.com/show_bug.cgi?id=698208
+
+diff --git a/devices/vector/gdevpdfp.c b/devices/vector/gdevpdfp.c
+index 1fdfeae..6c79157 100644
+--- a/devices/vector/gdevpdfp.c
++++ b/devices/vector/gdevpdfp.c
+@@ -669,6 +669,14 @@ gdev_pdf_put_params_impl(gx_device * dev, const gx_device_pdf * save_dev, gs_par
+         param_signal_error(plist, param_name, code);
+     }
+ 
++    if (getenv("GS_GENERATE_UUIDS") &&
++        (strcasecmp(getenv("GS_GENERATE_UUIDS"), "0") == 0 ||
++         strcasecmp(getenv("GS_GENERATE_UUIDS"), "no") == 0)) {
++        pdev->OmitInfoDate = 1;
++        pdev->OmitID = 1;
++        pdev->OmitXMP = 1;
++    }
++
+     if (pdev->OmitInfoDate && pdev->PDFX != 0) {
+         emprintf(pdev->memory, "\nIt is not possible to omit the CreationDate when creating PDF/X\nOmitInfoDate is being ignored.\n");
+         pdev->OmitInfoDate = 0;
-- 
2.45.1





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [bug#71787] [PATCH 06/12] gnu: Add ghostscript/tesseract.
  2024-06-26 19:24 [bug#71787] [PATCH 00/12] Update and unbundle ghostscript and mupdf David Elsing
                   ` (4 preceding siblings ...)
  2024-06-26 19:26 ` [bug#71787] [PATCH 05/12] gnu: ghostscript: Unbundle dependencies and remove non-free parts David Elsing
@ 2024-06-26 19:26 ` David Elsing
  2024-06-26 19:27 ` [bug#71787] [PATCH 07/12] gnu: mupdf: Update to 1.24.4 and unbundle remaining dependencies David Elsing
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: David Elsing @ 2024-06-26 19:26 UTC (permalink / raw)
  To: 71787; +Cc: David Elsing

* gnu/packages/ghostscript.scm (ghostscript/tesseract): New variable.
---
 gnu/packages/ghostscript.scm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gnu/packages/ghostscript.scm b/gnu/packages/ghostscript.scm
index 2bc168db68..8c4cccb06e 100644
--- a/gnu/packages/ghostscript.scm
+++ b/gnu/packages/ghostscript.scm
@@ -36,6 +36,7 @@ (define-module (gnu packages ghostscript)
   #:use-module (gnu packages fontutils)
   #:use-module (gnu packages image)
   #:use-module (gnu packages man)
+  #:use-module (gnu packages ocr)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
@@ -428,6 +429,12 @@ (define-public ghostscript/cups
     (inputs (modify-inputs (package-inputs ghostscript)
               (prepend cups-minimal)))))
 
+(define-public ghostscript/tesseract
+  (package/inherit ghostscript
+    (name (string-append (package-name ghostscript) "-with-tesseract"))
+    (inputs (modify-inputs (package-inputs ghostscript)
+              (prepend tesseract-ocr)))))
+
 (define-public ijs
   (package
     (name "ijs")
-- 
2.45.1





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [bug#71787] [PATCH 07/12] gnu: mupdf: Update to 1.24.4 and unbundle remaining dependencies.
  2024-06-26 19:24 [bug#71787] [PATCH 00/12] Update and unbundle ghostscript and mupdf David Elsing
                   ` (5 preceding siblings ...)
  2024-06-26 19:26 ` [bug#71787] [PATCH 06/12] gnu: Add ghostscript/tesseract David Elsing
@ 2024-06-26 19:27 ` David Elsing
  2024-06-26 19:27 ` [bug#71787] [PATCH 08/12] gnu: Add mupdf/tesseract David Elsing
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: David Elsing @ 2024-06-26 19:27 UTC (permalink / raw)
  To: 71787; +Cc: David Elsing

* gnu/packages/pdf.scm (mupdf): Update to 1.24.4.
[source]: Use git-fetch. Adjust snippet.
[inputs]: Add extract, lcms2mt and memento.
[arguments]<make-flags>: Set USE_SYSTEM_LCMS2 and USE_SYTEM_GLUT to
'yes'. Remove USE_SYSTEM_LEPTONICA and USE_SYSTEM_TESSERACT. Add "LIBS=...".
<phases>: Add 'unbundle' and 'symlink-memento-header' phases.
---
 gnu/packages/pdf.scm | 127 ++++++++++++++++++++++++++++++-------------
 1 file changed, 89 insertions(+), 38 deletions(-)

diff --git a/gnu/packages/pdf.scm b/gnu/packages/pdf.scm
index 4e260d614d..232cafcbf1 100644
--- a/gnu/packages/pdf.scm
+++ b/gnu/packages/pdf.scm
@@ -27,6 +27,7 @@
 ;;; Copyright © 2023 Felix Gruber <felgru@posteo.net>
 ;;; Copyright © 2024 dan <i@dan.games>
 ;;; Copyright © 2023 Benjamin Slade <slade@lambda-y.net>
+;;; Copyright © 2024 David Elsing <david.elsing@posteo.net>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -64,6 +65,7 @@ (define-module (gnu packages pdf)
   #:use-module (gnu packages base)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages build-tools)
+  #:use-module (gnu packages c)
   #:use-module (gnu packages check)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages cups)
@@ -87,6 +89,7 @@ (define-module (gnu packages pdf)
   #:use-module (gnu packages lesstif)
   #:use-module (gnu packages libffi)
   #:use-module (gnu packages linux)
+  #:use-module (gnu packages llvm)
   #:use-module (gnu packages lua)
   #:use-module (gnu packages man)
   #:use-module (gnu packages markup)
@@ -107,6 +110,7 @@ (define-module (gnu packages pdf)
   #:use-module (gnu packages sdl)
   #:use-module (gnu packages sphinx)
   #:use-module (gnu packages sqlite)
+  #:use-module (gnu packages swig)
   #:use-module (gnu packages tex)
   #:use-module (gnu packages time)
   #:use-module (gnu packages tcl)
@@ -833,28 +837,23 @@ (define-public python-pydyf
 (define-public mupdf
   (package
     (name "mupdf")
-    (version "1.23.11")
+    (version "1.24.4")
     (source
      (origin
-       (method url-fetch)
-       (uri (string-append "https://mupdf.com/downloads/archive/"
-                           "mupdf-" version "-source.tar.lz"))
+       (method git-fetch)
+       (uri (git-reference
+             (url "git://git.ghostscript.com/mupdf")
+             (commit (string-append version))))
+       (file-name (git-file-name name version))
        (sha256
-        (base32 "1kv44zqijkvljc9fcqmgb8zqkj7hmasga70fsz98aimmrfc2rmyv"))
-       (modules '((guix build utils)
-                  (ice-9 ftw)
-                  (srfi srfi-1)))
+        (base32 "1h97zkdnnr6wfi42d23x6lr037mkl4cab181f34d9cbri4y5sf39"))
        (snippet
-        ;; Remove bundled software.  Keep patched variants.
-        #~(with-directory-excursion "thirdparty"
-            (let ((keep '("README" "extract" "freeglut" "lcms2")))
-              (for-each delete-file-recursively
-                        (lset-difference string=?
-                                         (scandir ".")
-                                         (cons* "." ".." keep))))))))
+        '(begin (delete-file "include/mupdf/memento.h")
+                (delete-file "source/fitz/memento.c")))))
     (build-system gnu-build-system)
     (inputs
      (list curl
+           extract
            libxrandr
            libxi
            freeglut                     ;for GL/gl.h
@@ -865,39 +864,91 @@ (define-public mupdf
            libjpeg-turbo
            libx11
            libxext
+           lcms2mt
+           memento
            mujs
            openjpeg
            openssl
            zlib))
     (native-inputs
-     (list pkg-config))
+     (list
+      pkg-config
+      python
+      python-clang-13
+      python-setuptools
+      swig))
     (arguments
      (list
       #:tests? #f                       ;no check target
+      #:imported-modules `((guix build python-build-system)
+                           ,@%gnu-build-system-modules)
+      #:modules '(((guix build python-build-system)
+                   #:select (python-version))
+                  (guix build gnu-build-system)
+                  (guix build utils))
       #:make-flags
-      #~(list "verbose=yes"
-              (string-append "CC=" #$(cc-for-target))
-              "XCFLAGS=-fpic"
-              "USE_SYSTEM_FREETYPE=yes"
-              "USE_SYSTEM_GUMBO=yes"
-              "USE_SYSTEM_HARFBUZZ=yes"
-              "USE_SYSTEM_JBIG2DEC=yes"
-              "USE_SYSTEM_JPEGXR=no # not available"
-              "USE_SYSTEM_LCMS2=no # lcms2mt is strongly preferred"
-              "USE_SYSTEM_LIBJPEG=yes"
-              "USE_SYSTEM_MUJS=yes"
-              "USE_SYSTEM_OPENJPEG=yes"
-              "USE_SYSTEM_ZLIB=yes"
-              "USE_SYSTEM_GLUT=no"
-              "USE_SYSTEM_CURL=yes"
-              "USE_SYSTEM_LEPTONICA=yes"
-              "USE_SYSTEM_TESSERACT=yes"
-              "shared=yes"
-              (string-append "LDFLAGS=-Wl,-rpath=" #$output "/lib")
-              (string-append "prefix=" #$output))
+      #~(list
+         "verbose=yes"
+         (string-append "CC=" #$(cc-for-target))
+         "XCFLAGS=-fpic"
+         "USE_SYSTEM_LIBS=yes"
+         "USE_SYSTEM_FREETYPE=yes"
+         "USE_SYSTEM_GUMBO=yes"
+         "USE_SYSTEM_HARFBUZZ=yes"
+         "USE_SYSTEM_JBIG2DEC=yes"
+         "USE_SYSTEM_JPEGXR=no" ; non-free, also not bundled
+         "USE_SYSTEM_LCMS2=yes"
+         "USE_SYSTEM_LIBJPEG=yes"
+         "USE_SYSTEM_MUJS=yes"
+         "USE_SYSTEM_OPENJPEG=yes"
+         "USE_SYSTEM_ZLIB=yes"
+         "USE_SYSTEM_GLUT=yes"
+         "USE_SYSTEM_CURL=yes"
+         "VENV_FLAG="
+         "shared=yes"
+         (string-append "LDFLAGS=-Wl,-rpath=" #$output "/lib")
+         (string-append "prefix=" #$output)
+         (string-append "pydir=" #$output "/lib/python"
+                        (python-version #$(this-package-native-input "python"))
+                        "/site-packages")
+         "XLIBS=-lextract -lmemento")
       #:phases
-      #~(modify-phases %standard-phases
-          (delete 'configure)))) ;no configure script
+      #~(let ((memento-header-orig
+               (string-append #$(this-package-input "memento")
+                              "/include/memento.h"))
+              (memento-header-out
+               (string-append #$output "/include/mupdf/memento.h")))
+          (modify-phases %standard-phases
+            (add-after 'unpack 'unbundle
+              (lambda _
+                (substitute* "Makethird"
+                  ((".*THIRD_SRC \\+=.*") ""))
+                ;; This bundled header is part of the mupdf API.
+                (symlink memento-header-orig "include/mupdf/memento.h")))
+            (delete 'configure)  ; no configure script
+            (replace 'build
+              (lambda* (#:key make-flags parallel-build? #:allow-other-keys)
+                ;; Run seperately to prevent concurrency problems
+                (for-each
+                 (lambda (make-targets)
+                   (display (string-append
+                             "Building " (string-join make-targets " ") "\n"))
+                   (apply invoke "make"
+                          `(,@make-targets
+                            ,@(if parallel-build?
+                                  `("-j" ,(number->string (parallel-job-count)))
+                                  '())
+                            ,@make-flags)))
+                 '(("libs" "apps") ("c++") ("python")))))
+            ;; Install Python binding
+            (add-after 'install 'install-python
+              (lambda* (#:key make-flags #:allow-other-keys)
+                (apply invoke "make" "install-shared-python" make-flags)))
+            ;; Change the copy back to a symlink.
+            (add-after 'install 'symlink-memento-header
+              (lambda _
+                (delete-file memento-header-out)
+                (symlink memento-header-orig memento-header-out)))))))
     (home-page "https://mupdf.com")
     (synopsis "Lightweight PDF viewer and toolkit")
     (description
-- 
2.45.1





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [bug#71787] [PATCH 08/12] gnu: Add mupdf/tesseract.
  2024-06-26 19:24 [bug#71787] [PATCH 00/12] Update and unbundle ghostscript and mupdf David Elsing
                   ` (6 preceding siblings ...)
  2024-06-26 19:27 ` [bug#71787] [PATCH 07/12] gnu: mupdf: Update to 1.24.4 and unbundle remaining dependencies David Elsing
@ 2024-06-26 19:27 ` David Elsing
  2024-06-26 19:27 ` [bug#71787] [PATCH 09/12] gnu: Add python-pymupdf David Elsing
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: David Elsing @ 2024-06-26 19:27 UTC (permalink / raw)
  To: 71787; +Cc: David Elsing

* gnu/packages/pdf.scm (mupdf/tesseract): New variable.
---
 gnu/packages/pdf.scm | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/gnu/packages/pdf.scm b/gnu/packages/pdf.scm
index 232cafcbf1..9e10264fad 100644
--- a/gnu/packages/pdf.scm
+++ b/gnu/packages/pdf.scm
@@ -966,6 +966,20 @@ (define-public mupdf
                    license:silofl1.1    ;resources/fonts/{han,noto,sil,urw}
                    license:asl2.0)))) ; resources/fonts/droid
 
+(define-public mupdf/tesseract
+  (package/inherit mupdf
+    (name (string-append (package-name mupdf) "-with-tesseract"))
+    (inputs (modify-inputs (package-inputs mupdf)
+              (prepend leptonica tesseract-ocr)))
+    (arguments
+     (substitute-keyword-arguments (package-arguments mupdf)
+       ((#:make-flags flags)
+        #~(cons*
+           "tesseract=yes"
+           "USE_SYSTEM_LEPTONICA=yes"
+           "USE_SYSTEM_TESSERACT=yes"
+           #$flags))))))
+
 (define-public qpdf
   (package
     (name "qpdf")
-- 
2.45.1





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [bug#71787] [PATCH 09/12] gnu: Add python-pymupdf.
  2024-06-26 19:24 [bug#71787] [PATCH 00/12] Update and unbundle ghostscript and mupdf David Elsing
                   ` (7 preceding siblings ...)
  2024-06-26 19:27 ` [bug#71787] [PATCH 08/12] gnu: Add mupdf/tesseract David Elsing
@ 2024-06-26 19:27 ` David Elsing
  2024-06-26 19:27 ` [bug#71787] [PATCH 10/12] gnu: Add python-svglib David Elsing
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: David Elsing @ 2024-06-26 19:27 UTC (permalink / raw)
  To: 71787; +Cc: David Elsing

* gnu/packages/python-xyz.scm (python-pymupdf): New variable.
---
 gnu/packages/python-xyz.scm | 49 +++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index ff507e1855..111a3dd56c 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -8990,6 +8990,55 @@ (define-public python-pdftotext
     (description "Pdftotext is a Python library of PDF text extraction.")
     (license license:expat)))
 
+(define-public python-pymupdf
+  (package
+    (name "python-pymupdf")
+    (version "1.24.7")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "PyMuPDF" version))
+       (sha256
+        (base32 "1f2r7c0nfw2g49q8fgf0kwkadihnf6c47pa93zavl5gj0kiflk53"))))
+    (build-system pyproject-build-system)
+    (inputs
+     (list
+      mupdf/tesseract))
+    (native-inputs
+     (list
+      python-pillow
+      python-pytest
+      python-psutil
+      swig))
+    (propagated-inputs (list mupdf))
+    (arguments
+     (list
+      ;; Disable failing tests
+      #:test-flags
+      '(list
+        "-k" (string-append
+              "not test_flake8"
+              " and not test_fontarchive"
+              " and not test_subset_fonts"
+              " and not test_color_count"
+              " and not test_3050"
+              " and not test_pylint"
+              " and not test_textbox3"))
+      #:phases
+      '(modify-phases %standard-phases
+         (add-after 'unpack 'setenv
+           (lambda _
+             (setenv "PYMUPDF_SETUP_MUPDF_BUILD" "")
+             (setenv "PYMUPDF_SETUP_IMPLEMENTATIONS" "b"))))))
+    (home-page "https://github.com/pymupdf/PyMuPDF")
+    (synopsis
+     "Python library for the analysis and manipulation of PDF files")
+    (description
+     "This package provides a high performance Python library for data
+extraction, analysis, conversion & manipulation of PDF (and other)
+documents.")
+    (license license:agpl3+)))
+
 (define-public python-pluginbase
   (package
     (name "python-pluginbase")
-- 
2.45.1





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [bug#71787] [PATCH 10/12] gnu: Add python-svglib.
  2024-06-26 19:24 [bug#71787] [PATCH 00/12] Update and unbundle ghostscript and mupdf David Elsing
                   ` (8 preceding siblings ...)
  2024-06-26 19:27 ` [bug#71787] [PATCH 09/12] gnu: Add python-pymupdf David Elsing
@ 2024-06-26 19:27 ` David Elsing
  2024-06-26 19:27 ` [bug#71787] [PATCH 11/12] gnu: Add python-rst2pdf David Elsing
  2024-06-26 19:27 ` [bug#71787] [PATCH 12/12] gnu: Add ghostscript-documentation David Elsing
  11 siblings, 0 replies; 13+ messages in thread
From: David Elsing @ 2024-06-26 19:27 UTC (permalink / raw)
  To: 71787; +Cc: David Elsing

* gnu/packages/python-xyz.scm (python-svglib): New variable.
---
 gnu/packages/python-xyz.scm | 41 +++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index 111a3dd56c..d1385ffdef 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -29611,6 +29611,47 @@ (define-public python-cairosvg
 qvarious formats: PDF, PostScript, PNG and even SVG.")
     (license license:lgpl3+)))
 
+(define-public python-svglib
+  (package
+    (name "python-svglib")
+    (version "1.5.1")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "svglib" version))
+       (sha256
+        (base32 "11z5jl38zjbzrmdly197m5x6303axcnlrlml1w6fd7j0m79nbrrs"))))
+    (build-system pyproject-build-system)
+    (propagated-inputs
+     (list python-cssselect2
+           python-lxml
+           python-reportlab
+           python-tinycss2))
+    (native-inputs
+     (list python-pytest))
+    (arguments
+     (list
+      #:phases
+      '(modify-phases %standard-phases
+         (replace 'check
+           (lambda* (#:key tests? inputs outputs #:allow-other-keys)
+             (if tests?
+                 (setenv "PYTHONPATH" (getcwd))
+                 (invoke
+                  "pytest" "-vv"
+                  ;; These tests download additional data
+                  "--deselect"
+                  "tests/test_samples.py::TestW3CSVG::test_convert_pdf_png"
+                  "--deselect"
+                  (string-append
+                   "tests/test_samples.py::TestWikipediaFlags"
+                   "::test_convert_pdf"))))))))
+    (home-page "https://github.com/deeplook/svglib")
+    (synopsis "Python library for reading and converting SVG files")
+    (description "This package provides a pure-Python library for reading SVG
+files and converting them to other formats.")
+    (license license:lgpl3+)))
+
 (define-public python-pyphen
   (package
     (name "python-pyphen")
-- 
2.45.1





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [bug#71787] [PATCH 11/12] gnu: Add python-rst2pdf.
  2024-06-26 19:24 [bug#71787] [PATCH 00/12] Update and unbundle ghostscript and mupdf David Elsing
                   ` (9 preceding siblings ...)
  2024-06-26 19:27 ` [bug#71787] [PATCH 10/12] gnu: Add python-svglib David Elsing
@ 2024-06-26 19:27 ` David Elsing
  2024-06-26 19:27 ` [bug#71787] [PATCH 12/12] gnu: Add ghostscript-documentation David Elsing
  11 siblings, 0 replies; 13+ messages in thread
From: David Elsing @ 2024-06-26 19:27 UTC (permalink / raw)
  To: 71787; +Cc: David Elsing

* gnu/packages/python-xyz.scm (python-rst2pdf): New variable.
---
 gnu/packages/python-xyz.scm | 53 +++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/gnu/packages/python-xyz.scm b/gnu/packages/python-xyz.scm
index d1385ffdef..1688999d56 100644
--- a/gnu/packages/python-xyz.scm
+++ b/gnu/packages/python-xyz.scm
@@ -6877,6 +6877,59 @@ (define-public python-docutils
     ;; licensed under the PFSL, BSD 2-clause, and GPLv3+ licenses.
     (license (list license:public-domain license:psfl license:bsd-2 license:gpl3+))))
 
+(define-public python-rst2pdf
+  (package
+    (name "python-rst2pdf")
+    (version "0.102")
+    (source
+     (origin
+       (method url-fetch)
+       (uri (pypi-uri "rst2pdf" version))
+       (sha256
+        (base32 "09gl8h457p4ackgmisxy41y4dx8fccj6zbnbvpfkx9skx4j0cc1p"))))
+    (build-system pyproject-build-system)
+    (propagated-inputs
+     (list python-docutils
+           python-importlib-metadata
+           python-jinja2
+           python-packaging
+           python-pygments
+           python-pyyaml
+           python-reportlab
+           python-smartypants))
+    (native-inputs
+     (list fontconfig
+           python-pymupdf
+           python-pytest
+           python-svglib))
+    (arguments
+     (list
+      ;; These tests fail
+      #:test-flags
+      '(list
+        "-k"
+        (string-join
+         '("not test-referencing-an-aliased-font"
+           "test_aafigure"
+           "test_aafigure_extra"
+           "test_docutils_math"
+           "test_issue_231"
+           "test_issue_349"
+           "test_issue_363"
+           "test_issue_73_unicode_box_drawing_characters_renders_without_errors"
+           "test_issue_785"
+           "test_math"
+           "test_math_role"
+           "test_raw_html"
+           "test_slides")
+         " and not "))))
+    (home-page "https://rst2pdf.org")
+    (synopsis "Tool to convert reStructuredText to PDF via ReportLab")
+    (description
+     "@code{rst2pdf} is a command line tool for converting @code{reStructured}
+text to PDF files via the @code{ReportLab} library.")
+    (license license:expat)))
+
 ;; awscli refuses to be built with docutils < 0.16.
 (define-public python-docutils-0.15
   (package
-- 
2.45.1





^ permalink raw reply related	[flat|nested] 13+ messages in thread

* [bug#71787] [PATCH 12/12] gnu: Add ghostscript-documentation.
  2024-06-26 19:24 [bug#71787] [PATCH 00/12] Update and unbundle ghostscript and mupdf David Elsing
                   ` (10 preceding siblings ...)
  2024-06-26 19:27 ` [bug#71787] [PATCH 11/12] gnu: Add python-rst2pdf David Elsing
@ 2024-06-26 19:27 ` David Elsing
  11 siblings, 0 replies; 13+ messages in thread
From: David Elsing @ 2024-06-26 19:27 UTC (permalink / raw)
  To: 71787; +Cc: David Elsing

* gnu/packages/ghostscript.scm (ghostscript-documentation): New variable.
---
 gnu/packages/ghostscript.scm | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/gnu/packages/ghostscript.scm b/gnu/packages/ghostscript.scm
index 8c4cccb06e..6d2653e26e 100644
--- a/gnu/packages/ghostscript.scm
+++ b/gnu/packages/ghostscript.scm
@@ -40,6 +40,8 @@ (define-module (gnu packages ghostscript)
   #:use-module (gnu packages perl)
   #:use-module (gnu packages pkg-config)
   #:use-module (gnu packages python)
+  #:use-module (gnu packages python-xyz)
+  #:use-module (gnu packages sphinx)
   #:use-module (gnu packages tcl)
   #:use-module (gnu packages xorg)
   #:use-module ((guix licenses) #:prefix license:)
@@ -49,6 +51,7 @@ (define-module (gnu packages ghostscript)
   #:use-module (guix git-download)
   #:use-module (guix utils)
   #:use-module (guix build-system gnu)
+  #:use-module (guix build-system trivial)
   #:use-module (srfi srfi-1))
 
 (define-public lcms
@@ -417,6 +420,39 @@ (define-public ghostscript
       ;; inclusion in Postscript and PDF files.
       (license:non-copyleft "file://LICENSE")))))
 
+;; Put the documentation in a separate package due to a circular dependency of
+;; ghostscript with python-sphinx.
+(define-public ghostscript-documentation
+  (package
+    (inherit ghostscript)
+    (name (string-append (package-name ghostscript) "-documentation"))
+    (native-inputs
+     (list
+      python
+      python-pymupdf
+      python-rst2pdf
+      python-sphinx
+      python-sphinx-copybutton
+      python-sphinx-rtd-theme))
+    (inputs '())
+    (arguments
+     (list
+      #:tests? #f
+      #:phases
+      #~(modify-phases %standard-phases
+          (delete 'bootstrap)
+          (delete 'configure)
+          (replace 'build
+            (lambda _
+              (chdir "doc")
+              (invoke "sphinx-build" "-b" "html" "src" "build")))
+          (replace 'install
+            (lambda _
+              (copy-recursively
+               "build" (string-append #$output "/share/doc/ghostscript/"
+                                      #$(package-version this-package))))))))
+    (license license:agpl3+)))
+
 (define-public ghostscript/x
   (package/inherit ghostscript
     (name (string-append (package-name ghostscript) "-with-x"))
-- 
2.45.1





^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2024-06-26 19:29 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-26 19:24 [bug#71787] [PATCH 00/12] Update and unbundle ghostscript and mupdf David Elsing
2024-06-26 19:26 ` [bug#71787] [PATCH 01/12] gnu: Add lcms2mt David Elsing
2024-06-26 19:26 ` [bug#71787] [PATCH 02/12] gnu: Add memento David Elsing
2024-06-26 19:26 ` [bug#71787] [PATCH 03/12] gnu: Add extract David Elsing
2024-06-26 19:26 ` [bug#71787] [PATCH 04/12] gnu: ijs: Remove unneeded files and build shared library David Elsing
2024-06-26 19:26 ` [bug#71787] [PATCH 05/12] gnu: ghostscript: Unbundle dependencies and remove non-free parts David Elsing
2024-06-26 19:26 ` [bug#71787] [PATCH 06/12] gnu: Add ghostscript/tesseract David Elsing
2024-06-26 19:27 ` [bug#71787] [PATCH 07/12] gnu: mupdf: Update to 1.24.4 and unbundle remaining dependencies David Elsing
2024-06-26 19:27 ` [bug#71787] [PATCH 08/12] gnu: Add mupdf/tesseract David Elsing
2024-06-26 19:27 ` [bug#71787] [PATCH 09/12] gnu: Add python-pymupdf David Elsing
2024-06-26 19:27 ` [bug#71787] [PATCH 10/12] gnu: Add python-svglib David Elsing
2024-06-26 19:27 ` [bug#71787] [PATCH 11/12] gnu: Add python-rst2pdf David Elsing
2024-06-26 19:27 ` [bug#71787] [PATCH 12/12] gnu: Add ghostscript-documentation David Elsing

Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.