unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
* [bug#61015] [PATCH core-updates 0/9] Modernize and fix docbook-xml
@ 2023-01-23  3:31 Bruno Victal
  2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 1/9] gnu: docbook-xml: Use copy-build-system Bruno Victal
                   ` (10 more replies)
  0 siblings, 11 replies; 16+ messages in thread
From: Bruno Victal @ 2023-01-23  3:31 UTC (permalink / raw)
  To: 61015; +Cc: Bruno Victal

This patch-series modernizes docbook-xml package definitions and
properly patches the catalog.xml paths using XSLT.
I've used XSLT here as it seems easier (and better documented)
to perform XML operations with it. I did a small prototype with
(sxml transforms) but due to guile-bug #20339, it's impossible to go
from sxml->xml, ruling it out from being a suitable replacement for XSLT.

The situation for docbook-xml-4.1.2 could be considered extraordinary
since it's the only package that doesn't come with a catalog.xml file,
requiring a pre-built one to be used. (It can be generated from source,
by implementing a (PEG) parser for SGML catalogs but this seems
unnecessary for a file that is unlikely to see any changes.)

With these changes, it's no longer required for packages to do
substitute* or other workarounds to coerce docbook-xml
to play nicely, libxml2 will automatically find the DTDs
through its native-search-path. (XML_CATALOG_FILES variable)

A good follow-up to this patch-series would be to search and destroy
the workarounds currently employed by docbook-xml dependant packages
to discourage cargo-culting redundant procedures.


Bruno Victal (9):
  gnu: docbook-xml: Use copy-build-system.
  gnu: docbook-xml-4.1.2: Adapt to copy-build-system.
  gnu: docbook-xml: Adapt to copy-build-system.
  gnu: docbook-xml-4.4: Adapt to copy-build-system.
  gnu: docbook-xml-4.3: Adapt to copy-build-system.
  gnu: docbook-xml-4.2: Adapt to copy-build-system.
  gnu: docbook-xml: Fix permissions.
  gnu: docbook-xml: Use XSLT to patch catalog.xml.
  gnu: docbook-xml-4.1.2: Add missing catalog.xml.

 .../xml/docbook-xml/catalog-4.1.2.xml         |  31 +++++
 gnu/packages/aux-files/xml/patch-uri.xsl      |  24 ++++
 gnu/packages/docbook.scm                      | 127 +++++++++---------
 3 files changed, 116 insertions(+), 66 deletions(-)
 create mode 100644 gnu/packages/aux-files/xml/docbook-xml/catalog-4.1.2.xml
 create mode 100644 gnu/packages/aux-files/xml/patch-uri.xsl


base-commit: ca124b098dcc7ce7898df10faf9986f44a14e0a1
-- 
2.38.1





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

* [bug#61015] [PATCH core-updates 1/9] gnu: docbook-xml: Use copy-build-system.
  2023-01-23  3:31 [bug#61015] [PATCH core-updates 0/9] Modernize and fix docbook-xml Bruno Victal
@ 2023-01-23  3:32 ` Bruno Victal
  2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 2/9] gnu: docbook-xml-4.1.2: Adapt to copy-build-system Bruno Victal
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Bruno Victal @ 2023-01-23  3:32 UTC (permalink / raw)
  To: 61015; +Cc: Bruno Victal

* gnu/packages/docbook.scm (docbook-xml-5)
[build-system]: Switch to copy-build-system.
[source][arguments]: Adapt to copy-build-system.
---
 gnu/packages/docbook.scm | 28 ++++++++--------------------
 1 file changed, 8 insertions(+), 20 deletions(-)

diff --git a/gnu/packages/docbook.scm b/gnu/packages/docbook.scm
index f66ce4b959..a670eaa7f4 100644
--- a/gnu/packages/docbook.scm
+++ b/gnu/packages/docbook.scm
@@ -59,27 +59,15 @@ (define-public docbook-xml-5
               (sha256
                (base32
                 "1iz3hq1lqgnshvlz4j9gvh4jy1ml74qf90vqf2ikbq0h4i2xzybs"))))
-    (build-system trivial-build-system)
+    (build-system copy-build-system)
     (arguments
-     `(#:modules ((guix build utils))
-       #:builder
-       (begin
-         (use-modules (guix build utils))
-         (let* ((unzip
-                 (string-append (assoc-ref %build-inputs "unzip")
-                                "/bin/unzip"))
-                (source (assoc-ref %build-inputs "source"))
-                (out    (assoc-ref %outputs "out"))
-                (dtd    (string-append out "/xml/dtd/docbook")))
-           (invoke unzip source)
-           (mkdir-p dtd)
-           (copy-recursively (string-append "docbook-" ,version) dtd)
-           (with-directory-excursion dtd
-             (substitute* (string-append out "/xml/dtd/docbook/catalog.xml")
-               (("uri=\"")
-                (string-append
-                 "uri=\"file://" dtd "/")))
-             #t)))))
+     (list
+      #:phases
+      #~(modify-phases %standard-phases
+          (replace 'install
+            (lambda _
+              (let ((dtd-path (string-append #$output "/xml/dtd/docbook")))
+                (copy-recursively "." dtd-path)))))))
     (native-inputs (list unzip))
     (home-page "https://docbook.org")
     (synopsis "DocBook XML DTDs for document authoring")
-- 
2.38.1





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

* [bug#61015] [PATCH core-updates 2/9] gnu: docbook-xml-4.1.2: Adapt to copy-build-system.
  2023-01-23  3:31 [bug#61015] [PATCH core-updates 0/9] Modernize and fix docbook-xml Bruno Victal
  2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 1/9] gnu: docbook-xml: Use copy-build-system Bruno Victal
@ 2023-01-23  3:32 ` Bruno Victal
  2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 3/9] gnu: docbook-xml: " Bruno Victal
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Bruno Victal @ 2023-01-23  3:32 UTC (permalink / raw)
  To: 61015; +Cc: Bruno Victal

* gnu/packages/docbook.scm (docbook-xml-4.1.2)
[arguments]: Adapt to copy-build-system.
[source]: Switch to url-fetch/zipbomb.
---
 gnu/packages/docbook.scm | 25 ++-----------------------
 1 file changed, 2 insertions(+), 23 deletions(-)

diff --git a/gnu/packages/docbook.scm b/gnu/packages/docbook.scm
index a670eaa7f4..113039616e 100644
--- a/gnu/packages/docbook.scm
+++ b/gnu/packages/docbook.scm
@@ -147,33 +147,12 @@ (define-public docbook-xml-4.1.2
     (inherit docbook-xml)
     (version "4.1.2")
     (source (origin
-              (method url-fetch)
+              (method url-fetch/zipbomb)
               (uri (string-append "https://docbook.org/xml/" version
                                   "/docbkx412.zip"))
               (sha256
                (base32
-                "0wkp5rvnqj0ghxia0558mnn4c7s3n501j99q2isp3sp0ci069w1h"))))
-    (arguments
-     '(#:modules ((guix build utils))
-       #:builder
-       (begin
-         (use-modules (guix build utils))
-         (let* ((source (assoc-ref %build-inputs "source"))
-                (unzip  (string-append (assoc-ref %build-inputs "unzip")
-                                       "/bin/unzip"))
-                (xmlcatalog  (string-append (assoc-ref %build-inputs "libxml2")
-                                            "/bin/xmlcatalog"))
-                (dtd    (string-append (assoc-ref %outputs "out")
-                                       "/xml/dtd/docbook"))
-                (catalog.xml (string-append dtd "/catalog.xml")))
-           (mkdir-p dtd)
-           (invoke unzip source "-d" dtd)
-           ;; Create a minimal XML catalog, to use with libxml2 tools.
-           (invoke xmlcatalog "--noout" "--create" catalog.xml)
-           (invoke xmlcatalog "--noout" "--add" "public"
-                   "-//OASIS//DTD DocBook XML V4.1.2//EN"
-                   (string-append dtd "/docbookx.dtd") catalog.xml)))))
-    (native-inputs (list libxml2 unzip))))
+                "0wkp5rvnqj0ghxia0558mnn4c7s3n501j99q2isp3sp0ci069w1h"))))))
 
 ;;; There's an issue in docbook-xsl 1.79.2 that causes manpages to be
 ;;; generated incorrectly and embed raw nroff syntax such as '.PP' when there
-- 
2.38.1





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

* [bug#61015] [PATCH core-updates 3/9] gnu: docbook-xml: Adapt to copy-build-system.
  2023-01-23  3:31 [bug#61015] [PATCH core-updates 0/9] Modernize and fix docbook-xml Bruno Victal
  2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 1/9] gnu: docbook-xml: Use copy-build-system Bruno Victal
  2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 2/9] gnu: docbook-xml-4.1.2: Adapt to copy-build-system Bruno Victal
@ 2023-01-23  3:32 ` Bruno Victal
  2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 4/9] gnu: docbook-xml-4.4: " Bruno Victal
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Bruno Victal @ 2023-01-23  3:32 UTC (permalink / raw)
  To: 61015; +Cc: Bruno Victal

* gnu/packages/docbook.scm (docbook-xml)
[arguments]: Adapt to copy-build-system.
[source]: Switch to url-fetch/zipbomb.
---
 gnu/packages/docbook.scm | 23 ++---------------------
 1 file changed, 2 insertions(+), 21 deletions(-)

diff --git a/gnu/packages/docbook.scm b/gnu/packages/docbook.scm
index 113039616e..11e65b1091 100644
--- a/gnu/packages/docbook.scm
+++ b/gnu/packages/docbook.scm
@@ -83,31 +83,12 @@ (define-public docbook-xml
     (name "docbook-xml")
     (version "4.5")
     (source (origin
-              (method url-fetch)
+              (method url-fetch/zipbomb)
               (uri (string-append "https://docbook.org/xml/" version
                                   "/docbook-xml-" version ".zip"))
               (sha256
                (base32
-                "1d671lcjckjri28xfbf6dq7y3xnkppa910w1jin8rjc35dx06kjf"))))
-    (arguments
-     '(#:builder (begin
-                   (use-modules (guix build utils))
-
-                   (let* ((unzip
-                           (string-append (assoc-ref %build-inputs "unzip")
-                                          "/bin/unzip"))
-                          (source (assoc-ref %build-inputs "source"))
-                          (out    (assoc-ref %outputs "out"))
-                          (dtd    (string-append out "/xml/dtd/docbook")))
-                     (mkdir-p dtd)
-                     (with-directory-excursion dtd
-                       (invoke unzip source))
-                     (substitute* (string-append out "/xml/dtd/docbook/catalog.xml")
-                       (("uri=\"")
-                        (string-append
-                         "uri=\"file://" dtd "/")))
-                     #t))
-                 #:modules ((guix build utils))))))
+                "1d671lcjckjri28xfbf6dq7y3xnkppa910w1jin8rjc35dx06kjf"))))))
 
 (define-public docbook-xml-4.4
   (package (inherit docbook-xml)
-- 
2.38.1





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

* [bug#61015] [PATCH core-updates 4/9] gnu: docbook-xml-4.4: Adapt to copy-build-system.
  2023-01-23  3:31 [bug#61015] [PATCH core-updates 0/9] Modernize and fix docbook-xml Bruno Victal
                   ` (2 preceding siblings ...)
  2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 3/9] gnu: docbook-xml: " Bruno Victal
@ 2023-01-23  3:32 ` Bruno Victal
  2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 5/9] gnu: docbook-xml-4.3: " Bruno Victal
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Bruno Victal @ 2023-01-23  3:32 UTC (permalink / raw)
  To: 61015; +Cc: Bruno Victal

* gnu/packages/docbook.scm (docbook-xml-4.4)
[source]: Switch to url-fetch/zipbomb.
---
 gnu/packages/docbook.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gnu/packages/docbook.scm b/gnu/packages/docbook.scm
index 11e65b1091..7df07533aa 100644
--- a/gnu/packages/docbook.scm
+++ b/gnu/packages/docbook.scm
@@ -94,7 +94,7 @@ (define-public docbook-xml-4.4
   (package (inherit docbook-xml)
     (version "4.4")
     (source (origin
-              (method url-fetch)
+              (method url-fetch/zipbomb)
               (uri (string-append "https://docbook.org/xml/" version
                                   "/docbook-xml-" version ".zip"))
               (sha256
-- 
2.38.1





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

* [bug#61015] [PATCH core-updates 5/9] gnu: docbook-xml-4.3: Adapt to copy-build-system.
  2023-01-23  3:31 [bug#61015] [PATCH core-updates 0/9] Modernize and fix docbook-xml Bruno Victal
                   ` (3 preceding siblings ...)
  2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 4/9] gnu: docbook-xml-4.4: " Bruno Victal
@ 2023-01-23  3:32 ` Bruno Victal
  2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 6/9] gnu: docbook-xml-4.2: " Bruno Victal
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Bruno Victal @ 2023-01-23  3:32 UTC (permalink / raw)
  To: 61015; +Cc: Bruno Victal

* gnu/packages/docbook.scm (docbook-xml-4.3)
[source]: Switch to url-fetch/zipbomb.
---
 gnu/packages/docbook.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gnu/packages/docbook.scm b/gnu/packages/docbook.scm
index 7df07533aa..f0c734e74f 100644
--- a/gnu/packages/docbook.scm
+++ b/gnu/packages/docbook.scm
@@ -105,7 +105,7 @@ (define-public docbook-xml-4.3
   (package (inherit docbook-xml)
     (version "4.3")
     (source (origin
-              (method url-fetch)
+              (method url-fetch/zipbomb)
               (uri (string-append "https://docbook.org/xml/" version
                                   "/docbook-xml-" version ".zip"))
               (sha256
-- 
2.38.1





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

* [bug#61015] [PATCH core-updates 6/9] gnu: docbook-xml-4.2: Adapt to copy-build-system.
  2023-01-23  3:31 [bug#61015] [PATCH core-updates 0/9] Modernize and fix docbook-xml Bruno Victal
                   ` (4 preceding siblings ...)
  2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 5/9] gnu: docbook-xml-4.3: " Bruno Victal
@ 2023-01-23  3:32 ` Bruno Victal
  2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 7/9] gnu: docbook-xml: Fix permissions Bruno Victal
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Bruno Victal @ 2023-01-23  3:32 UTC (permalink / raw)
  To: 61015; +Cc: Bruno Victal

* gnu/packages/docbook.scm (docbook-xml-4.2)
[source]: Switch to url-fetch/zipbomb.
---
 gnu/packages/docbook.scm | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/gnu/packages/docbook.scm b/gnu/packages/docbook.scm
index f0c734e74f..e09d8395a5 100644
--- a/gnu/packages/docbook.scm
+++ b/gnu/packages/docbook.scm
@@ -116,7 +116,7 @@ (define-public docbook-xml-4.2
   (package (inherit docbook-xml)
     (version "4.2")
     (source (origin
-              (method url-fetch)
+              (method url-fetch/zipbomb)
               (uri (string-append "https://docbook.org/xml/" version
                                   "/docbook-xml-" version ".zip"))
               (sha256
-- 
2.38.1





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

* [bug#61015] [PATCH core-updates 7/9] gnu: docbook-xml: Fix permissions.
  2023-01-23  3:31 [bug#61015] [PATCH core-updates 0/9] Modernize and fix docbook-xml Bruno Victal
                   ` (5 preceding siblings ...)
  2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 6/9] gnu: docbook-xml-4.2: " Bruno Victal
@ 2023-01-23  3:32 ` Bruno Victal
  2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 8/9] gnu: docbook-xml: Use XSLT to patch catalog.xml Bruno Victal
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Bruno Victal @ 2023-01-23  3:32 UTC (permalink / raw)
  To: 61015; +Cc: Bruno Victal

* gnu/packages/docbook.scm (docbook-xml-5)
[arguments]: Remove unnecessary executable permissions.
---
 gnu/packages/docbook.scm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gnu/packages/docbook.scm b/gnu/packages/docbook.scm
index e09d8395a5..b1743baf5e 100644
--- a/gnu/packages/docbook.scm
+++ b/gnu/packages/docbook.scm
@@ -62,8 +62,15 @@ (define-public docbook-xml-5
     (build-system copy-build-system)
     (arguments
      (list
+      #:modules '((guix build copy-build-system)
+                  (guix build utils)
+                  (srfi srfi-26))
       #:phases
       #~(modify-phases %standard-phases
+          (add-after 'unpack 'fix-permissions
+            (lambda _
+              ;; XXX: These files do not need 0755 permission.
+              (for-each (cut chmod <> #o644) (find-files "."))))
           (replace 'install
             (lambda _
               (let ((dtd-path (string-append #$output "/xml/dtd/docbook")))
-- 
2.38.1





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

* [bug#61015] [PATCH core-updates 8/9] gnu: docbook-xml: Use XSLT to patch catalog.xml.
  2023-01-23  3:31 [bug#61015] [PATCH core-updates 0/9] Modernize and fix docbook-xml Bruno Victal
                   ` (6 preceding siblings ...)
  2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 7/9] gnu: docbook-xml: Fix permissions Bruno Victal
@ 2023-01-23  3:32 ` Bruno Victal
  2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 9/9] gnu: docbook-xml-4.1.2: Add missing catalog.xml Bruno Victal
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 16+ messages in thread
From: Bruno Victal @ 2023-01-23  3:32 UTC (permalink / raw)
  To: 61015; +Cc: Bruno Victal

(sxml transforms) are unsuited here due to guile-bug #20339.

* gnu/packages/aux-files/xml/patch-uri.xsl: New file.
* gnu/packages/docbook.scm (docbook-xml-5)
[native-inputs]: Add libxslt.
[arguments]: Patch catalog.xml using XSLT.
---
 gnu/packages/aux-files/xml/patch-uri.xsl | 24 ++++++++++++++++++++++++
 gnu/packages/docbook.scm                 | 13 ++++++++++++-
 2 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/aux-files/xml/patch-uri.xsl

diff --git a/gnu/packages/aux-files/xml/patch-uri.xsl b/gnu/packages/aux-files/xml/patch-uri.xsl
new file mode 100644
index 0000000000..947517476d
--- /dev/null
+++ b/gnu/packages/aux-files/xml/patch-uri.xsl
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+SPDX-FileCopyrightText: 2023 Bruno Victal <mirai@makinata.eu>
+SPDX-License-Identifier: ISC
+
+Fix uri attributes to point to paths in the store.
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+  <xsl:output method="xml"/>
+  <xsl:param name="prefix">/</xsl:param>
+  <!-- begin identity transform -->
+  <xsl:template match="@*|node()">
+    <xsl:copy>
+      <xsl:apply-templates select="@*|node()"/>
+    </xsl:copy>
+  </xsl:template>
+  <!-- end identity transform -->
+
+  <xsl:template match="@uri">
+    <xsl:attribute name="uri">
+      <xsl:value-of select="concat('file://', $prefix, '/', .)"/>
+    </xsl:attribute>
+  </xsl:template>
+</xsl:stylesheet>
diff --git a/gnu/packages/docbook.scm b/gnu/packages/docbook.scm
index b1743baf5e..ce0b823e3a 100644
--- a/gnu/packages/docbook.scm
+++ b/gnu/packages/docbook.scm
@@ -8,6 +8,7 @@
 ;;; Copyright © 2021 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2021 Andrew Whatson <whatson@gmail.com>
+;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -71,11 +72,21 @@ (define-public docbook-xml-5
             (lambda _
               ;; XXX: These files do not need 0755 permission.
               (for-each (cut chmod <> #o644) (find-files "."))))
+          (add-before 'install 'patch-uri
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((xsltproc (search-input-file inputs "/bin/xsltproc"))
+                    (dtd-path (string-append #$output "/xml/dtd/docbook")))
+                (invoke xsltproc "--nonet" "--noout"
+                        "--stringparam" "prefix" dtd-path
+                        "--output" "catalog.xml.new"
+                        #$(local-file (search-auxiliary-file "xml/patch-uri.xsl"))
+                        "catalog.xml")
+                (rename-file "catalog.xml.new" "catalog.xml"))))
           (replace 'install
             (lambda _
               (let ((dtd-path (string-append #$output "/xml/dtd/docbook")))
                 (copy-recursively "." dtd-path)))))))
-    (native-inputs (list unzip))
+    (native-inputs (list libxslt unzip))
     (home-page "https://docbook.org")
     (synopsis "DocBook XML DTDs for document authoring")
     (description
-- 
2.38.1





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

* [bug#61015] [PATCH core-updates 9/9] gnu: docbook-xml-4.1.2: Add missing catalog.xml.
  2023-01-23  3:31 [bug#61015] [PATCH core-updates 0/9] Modernize and fix docbook-xml Bruno Victal
                   ` (7 preceding siblings ...)
  2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 8/9] gnu: docbook-xml: Use XSLT to patch catalog.xml Bruno Victal
@ 2023-01-23  3:32 ` Bruno Victal
  2023-03-06 15:22 ` [bug#61015] [PATCH core-updates 0/9] Modernize and fix docbook-xml Bruno Victal
  2023-03-11 17:54 ` [bug#61015] [PATCH v2 1/4] gnu: docbook-xml: Use copy-build-system Bruno Victal
  10 siblings, 0 replies; 16+ messages in thread
From: Bruno Victal @ 2023-01-23  3:32 UTC (permalink / raw)
  To: 61015; +Cc: Bruno Victal

* gnu/packages/aux-files/xml/docbook-xml/catalog-4.1.2.xml: New file.
* gnu/packages/docbook.scm (docbook-xml-4.1.2)
[arguments]: Use prebuilt catalog.xml.
[native-inputs]: Add libxml2.
---
 .../xml/docbook-xml/catalog-4.1.2.xml         | 31 +++++++++++++++++++
 gnu/packages/docbook.scm                      | 31 ++++++++++++++++++-
 2 files changed, 61 insertions(+), 1 deletion(-)
 create mode 100644 gnu/packages/aux-files/xml/docbook-xml/catalog-4.1.2.xml

diff --git a/gnu/packages/aux-files/xml/docbook-xml/catalog-4.1.2.xml b/gnu/packages/aux-files/xml/docbook-xml/catalog-4.1.2.xml
new file mode 100644
index 0000000000..cfb1849202
--- /dev/null
+++ b/gnu/packages/aux-files/xml/docbook-xml/catalog-4.1.2.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
+  <public publicId="-//OASIS//DTD DocBook XML V4.1.2//EN" uri="docbookx.dtd"/>
+  <public publicId="-//OASIS//DTD DocBook XML CALS Table Model V4.1.2//EN" uri="calstblx.dtd"/>
+  <public publicId="-//OASIS//DTD XML Exchange Table Model 19990315//EN" uri="soextblx.dtd"/>
+  <public publicId="-//OASIS//ELEMENTS DocBook XML Information Pool V4.1.2//EN" uri="dbpoolx.mod"/>
+  <public publicId="-//OASIS//ELEMENTS DocBook XML Document Hierarchy V4.1.2//EN" uri="dbhierx.mod"/>
+  <public publicId="-//OASIS//ENTITIES DocBook XML Additional General Entities V4.1.2//EN" uri="dbgenent.mod"/>
+  <public publicId="-//OASIS//ENTITIES DocBook XML Notations V4.1.2//EN" uri="dbnotnx.mod"/>
+  <public publicId="-//OASIS//ENTITIES DocBook XML Character Entities V4.1.2//EN" uri="dbcentx.mod"/>
+  <public publicId="ISO 8879:1986//ENTITIES Diacritical Marks//EN" uri="ent/iso-dia.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN" uri="ent/iso-num.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Publishing//EN" uri="ent/iso-pub.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES General Technical//EN" uri="ent/iso-tech.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Added Latin 1//EN" uri="ent/iso-lat1.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Added Latin 2//EN" uri="ent/iso-lat2.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Greek Letters//EN" uri="ent/iso-grk1.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Monotoniko Greek//EN" uri="ent/iso-grk2.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Greek Symbols//EN" uri="ent/iso-grk3.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Alternative Greek Symbols//EN" uri="ent/iso-grk4.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Added Math Symbols: Arrow Relations//EN" uri="ent/iso-amsa.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Added Math Symbols: Binary Operators//EN" uri="ent/iso-amsb.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Added Math Symbols: Delimiters//EN" uri="ent/iso-amsc.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Added Math Symbols: Negated Relations//EN" uri="ent/iso-amsn.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN" uri="ent/iso-amso.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Added Math Symbols: Relations//EN" uri="ent/iso-amsr.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Box and Line Drawing//EN" uri="ent/iso-box.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Russian Cyrillic//EN" uri="ent/iso-cyr1.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Non-Russian Cyrillic//EN" uri="ent/iso-cyr2.ent"/>
+</catalog>
diff --git a/gnu/packages/docbook.scm b/gnu/packages/docbook.scm
index ce0b823e3a..6dc57d5d03 100644
--- a/gnu/packages/docbook.scm
+++ b/gnu/packages/docbook.scm
@@ -39,6 +39,7 @@ (define-module (gnu packages docbook)
   #:use-module (gnu packages web-browsers)
   #:use-module (gnu packages xml)
   #:use-module (guix gexp)
+  #:use-module (guix utils)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix download)
@@ -151,7 +152,35 @@ (define-public docbook-xml-4.1.2
                                   "/docbkx412.zip"))
               (sha256
                (base32
-                "0wkp5rvnqj0ghxia0558mnn4c7s3n501j99q2isp3sp0ci069w1h"))))))
+                "0wkp5rvnqj0ghxia0558mnn4c7s3n501j99q2isp3sp0ci069w1h"))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments docbook-xml)
+       ((#:phases phases)
+        #~(modify-phases #$phases
+            (add-after 'unpack 'copy-catalog-file
+              ;; docbook-xml-4.1.2 is unique in the fact that it doesn't come
+              ;; with a catalog.xml file, requiring it to be generated by hand from
+              ;; the docbook.cat SGML catalog. We could automatically generate it here
+              ;; at the cost of enlarging the package definition with a rudimentary
+              ;; (PEG) parser for the SGML catalog but this is overkill since this
+              ;; file is unlikely to change, therefore we use a pre-generated catalog.xml.
+              (lambda _
+                (copy-file #$(local-file
+                              (search-auxiliary-file "xml/docbook-xml/catalog-4.1.2.xml"))
+                           "catalog.xml")))
+            (add-after 'patch-uri 'add-rewrite-entries
+              (lambda* (#:key inputs #:allow-other-keys)
+                (let ((xmlcatalog (search-input-file inputs "/bin/xmlcatalog"))
+                      (dtd-path (string-append #$output "/xml/dtd/docbook")))
+                  (for-each (lambda (type)
+                              (invoke xmlcatalog "--noout"
+                                      "--add" type "http://www.oasis-open.org/docbook/xml/4.1.2/"
+                                      (string-append "file://" dtd-path "/")
+                                      "catalog.xml"))
+                            (list "rewriteSystem" "rewriteURI")))))))))
+    (native-inputs
+     (modify-inputs (package-native-inputs docbook-xml)
+       (prepend libxml2)))))
 
 ;;; There's an issue in docbook-xsl 1.79.2 that causes manpages to be
 ;;; generated incorrectly and embed raw nroff syntax such as '.PP' when there
-- 
2.38.1





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

* [bug#61015] [PATCH core-updates 0/9] Modernize and fix docbook-xml
  2023-01-23  3:31 [bug#61015] [PATCH core-updates 0/9] Modernize and fix docbook-xml Bruno Victal
                   ` (8 preceding siblings ...)
  2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 9/9] gnu: docbook-xml-4.1.2: Add missing catalog.xml Bruno Victal
@ 2023-03-06 15:22 ` Bruno Victal
  2023-03-11 17:54 ` [bug#61015] [PATCH v2 1/4] gnu: docbook-xml: Use copy-build-system Bruno Victal
  10 siblings, 0 replies; 16+ messages in thread
From: Bruno Victal @ 2023-03-06 15:22 UTC (permalink / raw)
  To: Bruno Victal; +Cc: 61015

Though this patch-set brings improvements to docbook handling and doesn't seem to break anything,
given that it's unlikely to make it to the upcoming core-updates merge, I'm thinking on reworking this
patch-series a bit further:

* Install the SGML and XML files in separate directories, supposedly some SGML tools choke if they find XML files
while looking for SGML files.

* Squash the 'copy-build-system' patches together since commits are not atomic due to package inheritance.

* Rename patch-uri.xsl to patch-uri-catalog.xml. (Register it in gnu/local.mk ?)

* Refactor the docbook-xsl packages.

* Possibly factor out all of the docbook workarounds used by docbook dependent packages.


Any thoughts before proceeding further?



On 2023-01-23 03:31, Bruno Victal wrote:
> This patch-series modernizes docbook-xml package definitions and
> properly patches the catalog.xml paths using XSLT.
> I've used XSLT here as it seems easier (and better documented)
> to perform XML operations with it. I did a small prototype with
> (sxml transforms) but due to guile-bug #20339, it's impossible to go
> from sxml->xml, ruling it out from being a suitable replacement for XSLT.
> 
> The situation for docbook-xml-4.1.2 could be considered extraordinary
> since it's the only package that doesn't come with a catalog.xml file,
> requiring a pre-built one to be used. (It can be generated from source,
> by implementing a (PEG) parser for SGML catalogs but this seems
> unnecessary for a file that is unlikely to see any changes.)
> 
> With these changes, it's no longer required for packages to do
> substitute* or other workarounds to coerce docbook-xml
> to play nicely, libxml2 will automatically find the DTDs
> through its native-search-path. (XML_CATALOG_FILES variable)
> 
> A good follow-up to this patch-series would be to search and destroy
> the workarounds currently employed by docbook-xml dependant packages
> to discourage cargo-culting redundant procedures.
> 
> 
> Bruno Victal (9):
>   gnu: docbook-xml: Use copy-build-system.
>   gnu: docbook-xml-4.1.2: Adapt to copy-build-system.
>   gnu: docbook-xml: Adapt to copy-build-system.
>   gnu: docbook-xml-4.4: Adapt to copy-build-system.
>   gnu: docbook-xml-4.3: Adapt to copy-build-system.
>   gnu: docbook-xml-4.2: Adapt to copy-build-system.
>   gnu: docbook-xml: Fix permissions.
>   gnu: docbook-xml: Use XSLT to patch catalog.xml.
>   gnu: docbook-xml-4.1.2: Add missing catalog.xml.
> 
>  .../xml/docbook-xml/catalog-4.1.2.xml         |  31 +++++
>  gnu/packages/aux-files/xml/patch-uri.xsl      |  24 ++++
>  gnu/packages/docbook.scm                      | 127 +++++++++---------
>  3 files changed, 116 insertions(+), 66 deletions(-)
>  create mode 100644 gnu/packages/aux-files/xml/docbook-xml/catalog-4.1.2.xml
>  create mode 100644 gnu/packages/aux-files/xml/patch-uri.xsl
> 
> 
> base-commit: ca124b098dcc7ce7898df10faf9986f44a14e0a1





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

* [bug#61015] [PATCH v2 1/4] gnu: docbook-xml: Use copy-build-system.
  2023-01-23  3:31 [bug#61015] [PATCH core-updates 0/9] Modernize and fix docbook-xml Bruno Victal
                   ` (9 preceding siblings ...)
  2023-03-06 15:22 ` [bug#61015] [PATCH core-updates 0/9] Modernize and fix docbook-xml Bruno Victal
@ 2023-03-11 17:54 ` Bruno Victal
  2023-03-11 17:54   ` [bug#61015] [PATCH v2 2/4] gnu: docbook-xml: Fix permissions Bruno Victal
                     ` (3 more replies)
  10 siblings, 4 replies; 16+ messages in thread
From: Bruno Victal @ 2023-03-11 17:54 UTC (permalink / raw)
  To: 61015; +Cc: Bruno Victal

* gnu/packages/docbook.scm
(docbook-xml-5)[build-system]: Switch to copy-build-system.
[source][arguments]: Adapt to copy-build-system.
(docbook-xml)[arguments]: Remove.
[source]: Switch to url-fetch/zipbomb.
(docbook-xml-4.4)[source]: Switch to url-fetch/zipbomb.
(docbook-xml-4.3)[source]: Switch to url-fetch/zipbomb.
(docbook-xml-4.2)[source]: Switch to url-fetch/zipbomb.
(docbook-xml-4.1.2)[arguments]: Remove.
[source]: Switch to url-fetch/zipbomb.
---
 gnu/packages/docbook.scm | 73 +++++++++-------------------------------
 1 file changed, 15 insertions(+), 58 deletions(-)

diff --git a/gnu/packages/docbook.scm b/gnu/packages/docbook.scm
index 8d4892b93b..7cfe550593 100644
--- a/gnu/packages/docbook.scm
+++ b/gnu/packages/docbook.scm
@@ -59,27 +59,15 @@ (define-public docbook-xml-5
               (sha256
                (base32
                 "1iz3hq1lqgnshvlz4j9gvh4jy1ml74qf90vqf2ikbq0h4i2xzybs"))))
-    (build-system trivial-build-system)
+    (build-system copy-build-system)
     (arguments
-     `(#:modules ((guix build utils))
-       #:builder
-       (begin
-         (use-modules (guix build utils))
-         (let* ((unzip
-                 (string-append (assoc-ref %build-inputs "unzip")
-                                "/bin/unzip"))
-                (source (assoc-ref %build-inputs "source"))
-                (out    (assoc-ref %outputs "out"))
-                (dtd    (string-append out "/xml/dtd/docbook")))
-           (invoke unzip source)
-           (mkdir-p dtd)
-           (copy-recursively (string-append "docbook-" ,version) dtd)
-           (with-directory-excursion dtd
-             (substitute* (string-append out "/xml/dtd/docbook/catalog.xml")
-               (("uri=\"")
-                (string-append
-                 "uri=\"file://" dtd "/")))
-             #t)))))
+     (list
+      #:phases
+      #~(modify-phases %standard-phases
+          (replace 'install
+            (lambda _
+              (let ((dtd-path (string-append #$output "/xml/dtd/docbook")))
+                (copy-recursively "." dtd-path)))))))
     (native-inputs (list unzip))
     (home-page "https://docbook.org")
     (synopsis "DocBook XML DTDs for document authoring")
@@ -95,37 +83,18 @@ (define-public docbook-xml
     (name "docbook-xml")
     (version "4.5")
     (source (origin
-              (method url-fetch)
+              (method url-fetch/zipbomb)
               (uri (string-append "https://docbook.org/xml/" version
                                   "/docbook-xml-" version ".zip"))
               (sha256
                (base32
-                "1d671lcjckjri28xfbf6dq7y3xnkppa910w1jin8rjc35dx06kjf"))))
-    (arguments
-     '(#:builder (begin
-                   (use-modules (guix build utils))
-
-                   (let* ((unzip
-                           (string-append (assoc-ref %build-inputs "unzip")
-                                          "/bin/unzip"))
-                          (source (assoc-ref %build-inputs "source"))
-                          (out    (assoc-ref %outputs "out"))
-                          (dtd    (string-append out "/xml/dtd/docbook")))
-                     (mkdir-p dtd)
-                     (with-directory-excursion dtd
-                       (invoke unzip source))
-                     (substitute* (string-append out "/xml/dtd/docbook/catalog.xml")
-                       (("uri=\"")
-                        (string-append
-                         "uri=\"file://" dtd "/")))
-                     #t))
-                 #:modules ((guix build utils))))))
+                "1d671lcjckjri28xfbf6dq7y3xnkppa910w1jin8rjc35dx06kjf"))))))
 
 (define-public docbook-xml-4.4
   (package (inherit docbook-xml)
     (version "4.4")
     (source (origin
-              (method url-fetch)
+              (method url-fetch/zipbomb)
               (uri (string-append "https://docbook.org/xml/" version
                                   "/docbook-xml-" version ".zip"))
               (sha256
@@ -136,7 +105,7 @@ (define-public docbook-xml-4.3
   (package (inherit docbook-xml)
     (version "4.3")
     (source (origin
-              (method url-fetch)
+              (method url-fetch/zipbomb)
               (uri (string-append "https://docbook.org/xml/" version
                                   "/docbook-xml-" version ".zip"))
               (sha256
@@ -147,7 +116,7 @@ (define-public docbook-xml-4.2
   (package (inherit docbook-xml)
     (version "4.2")
     (source (origin
-              (method url-fetch)
+              (method url-fetch/zipbomb)
               (uri (string-append "https://docbook.org/xml/" version
                                   "/docbook-xml-" version ".zip"))
               (sha256
@@ -158,24 +127,12 @@ (define-public docbook-xml-4.1.2
   (package (inherit docbook-xml)
     (version "4.1.2")
     (source (origin
-              (method url-fetch)
+              (method url-fetch/zipbomb)
               (uri (string-append "https://docbook.org/xml/" version
                                   "/docbkx412.zip"))
               (sha256
                (base32
-                "0wkp5rvnqj0ghxia0558mnn4c7s3n501j99q2isp3sp0ci069w1h"))))
-    (arguments
-     '(#:modules ((guix build utils))
-       #:builder
-       (begin
-         (use-modules (guix build utils))
-         (let ((source (assoc-ref %build-inputs "source"))
-               (unzip  (string-append (assoc-ref %build-inputs "unzip")
-                                      "/bin/unzip"))
-               (dtd    (string-append (assoc-ref %outputs "out")
-                                      "/xml/dtd/docbook")))
-           (mkdir-p dtd)
-           (invoke unzip source "-d" dtd)))))))
+                "0wkp5rvnqj0ghxia0558mnn4c7s3n501j99q2isp3sp0ci069w1h"))))))
 
 (define-public docbook-xsl
   (package
-- 
2.39.1





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

* [bug#61015] [PATCH v2 2/4] gnu: docbook-xml: Fix permissions.
  2023-03-11 17:54 ` [bug#61015] [PATCH v2 1/4] gnu: docbook-xml: Use copy-build-system Bruno Victal
@ 2023-03-11 17:54   ` Bruno Victal
  2023-03-11 17:54   ` [bug#61015] [PATCH v2 3/4] gnu: docbook-xml: Use XSLT to patch catalog.xml Bruno Victal
                     ` (2 subsequent siblings)
  3 siblings, 0 replies; 16+ messages in thread
From: Bruno Victal @ 2023-03-11 17:54 UTC (permalink / raw)
  To: 61015; +Cc: Bruno Victal

* gnu/packages/docbook.scm (docbook-xml-5)
[arguments]: Remove unnecessary executable permissions.
---
 gnu/packages/docbook.scm | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/gnu/packages/docbook.scm b/gnu/packages/docbook.scm
index 7cfe550593..6a8eeec386 100644
--- a/gnu/packages/docbook.scm
+++ b/gnu/packages/docbook.scm
@@ -62,8 +62,15 @@ (define-public docbook-xml-5
     (build-system copy-build-system)
     (arguments
      (list
+      #:modules '((guix build copy-build-system)
+                  (guix build utils)
+                  (srfi srfi-26))
       #:phases
       #~(modify-phases %standard-phases
+          (add-after 'unpack 'fix-permissions
+            (lambda _
+              ;; XXX: These files do not need 0755 permission.
+              (for-each (cut chmod <> #o644) (find-files "."))))
           (replace 'install
             (lambda _
               (let ((dtd-path (string-append #$output "/xml/dtd/docbook")))
-- 
2.39.1





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

* [bug#61015] [PATCH v2 3/4] gnu: docbook-xml: Use XSLT to patch catalog.xml.
  2023-03-11 17:54 ` [bug#61015] [PATCH v2 1/4] gnu: docbook-xml: Use copy-build-system Bruno Victal
  2023-03-11 17:54   ` [bug#61015] [PATCH v2 2/4] gnu: docbook-xml: Fix permissions Bruno Victal
@ 2023-03-11 17:54   ` Bruno Victal
  2023-03-11 17:54   ` [bug#61015] [PATCH v2 4/4] gnu: docbook-xml-4.1.2: Add missing catalog.xml Bruno Victal
  2023-04-21  4:45   ` bug#61015: [PATCH core-updates 0/9] Modernize and fix docbook-xml Maxim Cournoyer
  3 siblings, 0 replies; 16+ messages in thread
From: Bruno Victal @ 2023-03-11 17:54 UTC (permalink / raw)
  To: 61015; +Cc: Bruno Victal

(sxml transforms) are unsuited here due to guile-bug #20339.

* gnu/packages/aux-files/xml/patch-catalog-xml.xsl: New file.
* Makefile.am: Register it.
* gnu/packages/docbook.scm (docbook-xml-5)[native-inputs]: Add libxslt.
[arguments]: Add phase to patch catalog.xml using XSLT.
---
 Makefile.am                                   |  3 ++-
 .../aux-files/xml/patch-catalog-xml.xsl       | 24 +++++++++++++++++++
 gnu/packages/docbook.scm                      | 14 ++++++++++-
 3 files changed, 39 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/aux-files/xml/patch-catalog-xml.xsl

diff --git a/Makefile.am b/Makefile.am
index 23b939b674..73369c746c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -436,7 +436,8 @@ AUX_FILES =						\
   gnu/packages/aux-files/python/sanity-check-next.py	\
   gnu/packages/aux-files/python/sitecustomize.py	\
   gnu/packages/aux-files/renpy/renpy.in	\
-  gnu/packages/aux-files/run-in-namespace.c
+  gnu/packages/aux-files/run-in-namespace.c		\
+  gnu/packages/aux-files/xml/patch-catalog-xml.xsl
 
 # Templates, examples.
 EXAMPLES =					\
diff --git a/gnu/packages/aux-files/xml/patch-catalog-xml.xsl b/gnu/packages/aux-files/xml/patch-catalog-xml.xsl
new file mode 100644
index 0000000000..947517476d
--- /dev/null
+++ b/gnu/packages/aux-files/xml/patch-catalog-xml.xsl
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+SPDX-FileCopyrightText: 2023 Bruno Victal <mirai@makinata.eu>
+SPDX-License-Identifier: ISC
+
+Fix uri attributes to point to paths in the store.
+-->
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
+  <xsl:output method="xml"/>
+  <xsl:param name="prefix">/</xsl:param>
+  <!-- begin identity transform -->
+  <xsl:template match="@*|node()">
+    <xsl:copy>
+      <xsl:apply-templates select="@*|node()"/>
+    </xsl:copy>
+  </xsl:template>
+  <!-- end identity transform -->
+
+  <xsl:template match="@uri">
+    <xsl:attribute name="uri">
+      <xsl:value-of select="concat('file://', $prefix, '/', .)"/>
+    </xsl:attribute>
+  </xsl:template>
+</xsl:stylesheet>
diff --git a/gnu/packages/docbook.scm b/gnu/packages/docbook.scm
index 6a8eeec386..2d11333608 100644
--- a/gnu/packages/docbook.scm
+++ b/gnu/packages/docbook.scm
@@ -8,6 +8,7 @@
 ;;; Copyright © 2021 Mark H Weaver <mhw@netris.org>
 ;;; Copyright © 2021 Efraim Flashner <efraim@flashner.co.il>
 ;;; Copyright © 2021 Andrew Whatson <whatson@gmail.com>
+;;; Copyright © 2023 Bruno Victal <mirai@makinata.eu>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -71,11 +72,22 @@ (define-public docbook-xml-5
             (lambda _
               ;; XXX: These files do not need 0755 permission.
               (for-each (cut chmod <> #o644) (find-files "."))))
+          (add-before 'install 'patch-catalog-xml
+            (lambda* (#:key inputs #:allow-other-keys)
+              (let ((xsltproc (search-input-file inputs "/bin/xsltproc"))
+                    (dtd-path (string-append #$output "/xml/dtd/docbook")))
+                (invoke xsltproc "--nonet" "--noout"
+                        "--stringparam" "prefix" dtd-path
+                        "--output" "catalog.xml.new"
+                        #$(local-file
+                           (search-auxiliary-file "xml/patch-catalog-xml.xsl"))
+                        "catalog.xml")
+                (rename-file "catalog.xml.new" "catalog.xml"))))
           (replace 'install
             (lambda _
               (let ((dtd-path (string-append #$output "/xml/dtd/docbook")))
                 (copy-recursively "." dtd-path)))))))
-    (native-inputs (list unzip))
+    (native-inputs (list libxslt unzip))
     (home-page "https://docbook.org")
     (synopsis "DocBook XML DTDs for document authoring")
     (description
-- 
2.39.1





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

* [bug#61015] [PATCH v2 4/4] gnu: docbook-xml-4.1.2: Add missing catalog.xml.
  2023-03-11 17:54 ` [bug#61015] [PATCH v2 1/4] gnu: docbook-xml: Use copy-build-system Bruno Victal
  2023-03-11 17:54   ` [bug#61015] [PATCH v2 2/4] gnu: docbook-xml: Fix permissions Bruno Victal
  2023-03-11 17:54   ` [bug#61015] [PATCH v2 3/4] gnu: docbook-xml: Use XSLT to patch catalog.xml Bruno Victal
@ 2023-03-11 17:54   ` Bruno Victal
  2023-04-21  4:45   ` bug#61015: [PATCH core-updates 0/9] Modernize and fix docbook-xml Maxim Cournoyer
  3 siblings, 0 replies; 16+ messages in thread
From: Bruno Victal @ 2023-03-11 17:54 UTC (permalink / raw)
  To: 61015; +Cc: Bruno Victal

* gnu/packages/aux-files/xml/docbook-xml/catalog-4.1.2.xml: New file.
* Makefile.am: Register it.
* gnu/packages/docbook.scm (docbook-xml-4.1.2)[arguments]: Use prebuilt catalog.xml.
[native-inputs]: Add libxml2.
---
 Makefile.am                                   |  3 +-
 .../xml/docbook-xml/catalog-4.1.2.xml         | 31 ++++++++++++++++
 gnu/packages/docbook.scm                      | 36 ++++++++++++++++++-
 3 files changed, 68 insertions(+), 2 deletions(-)
 create mode 100644 gnu/packages/aux-files/xml/docbook-xml/catalog-4.1.2.xml

diff --git a/Makefile.am b/Makefile.am
index 73369c746c..310bbe1494 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -437,7 +437,8 @@ AUX_FILES =						\
   gnu/packages/aux-files/python/sitecustomize.py	\
   gnu/packages/aux-files/renpy/renpy.in	\
   gnu/packages/aux-files/run-in-namespace.c		\
-  gnu/packages/aux-files/xml/patch-catalog-xml.xsl
+  gnu/packages/aux-files/xml/patch-catalog-xml.xsl	\
+  gnu/packages/aux-files/xml/docbook-xml/catalog-4.1.2.xml
 
 # Templates, examples.
 EXAMPLES =					\
diff --git a/gnu/packages/aux-files/xml/docbook-xml/catalog-4.1.2.xml b/gnu/packages/aux-files/xml/docbook-xml/catalog-4.1.2.xml
new file mode 100644
index 0000000000..cfb1849202
--- /dev/null
+++ b/gnu/packages/aux-files/xml/docbook-xml/catalog-4.1.2.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0"?>
+<!DOCTYPE catalog PUBLIC "-//OASIS//DTD Entity Resolution XML Catalog V1.0//EN" "http://www.oasis-open.org/committees/entity/release/1.0/catalog.dtd">
+<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog">
+  <public publicId="-//OASIS//DTD DocBook XML V4.1.2//EN" uri="docbookx.dtd"/>
+  <public publicId="-//OASIS//DTD DocBook XML CALS Table Model V4.1.2//EN" uri="calstblx.dtd"/>
+  <public publicId="-//OASIS//DTD XML Exchange Table Model 19990315//EN" uri="soextblx.dtd"/>
+  <public publicId="-//OASIS//ELEMENTS DocBook XML Information Pool V4.1.2//EN" uri="dbpoolx.mod"/>
+  <public publicId="-//OASIS//ELEMENTS DocBook XML Document Hierarchy V4.1.2//EN" uri="dbhierx.mod"/>
+  <public publicId="-//OASIS//ENTITIES DocBook XML Additional General Entities V4.1.2//EN" uri="dbgenent.mod"/>
+  <public publicId="-//OASIS//ENTITIES DocBook XML Notations V4.1.2//EN" uri="dbnotnx.mod"/>
+  <public publicId="-//OASIS//ENTITIES DocBook XML Character Entities V4.1.2//EN" uri="dbcentx.mod"/>
+  <public publicId="ISO 8879:1986//ENTITIES Diacritical Marks//EN" uri="ent/iso-dia.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Numeric and Special Graphic//EN" uri="ent/iso-num.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Publishing//EN" uri="ent/iso-pub.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES General Technical//EN" uri="ent/iso-tech.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Added Latin 1//EN" uri="ent/iso-lat1.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Added Latin 2//EN" uri="ent/iso-lat2.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Greek Letters//EN" uri="ent/iso-grk1.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Monotoniko Greek//EN" uri="ent/iso-grk2.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Greek Symbols//EN" uri="ent/iso-grk3.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Alternative Greek Symbols//EN" uri="ent/iso-grk4.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Added Math Symbols: Arrow Relations//EN" uri="ent/iso-amsa.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Added Math Symbols: Binary Operators//EN" uri="ent/iso-amsb.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Added Math Symbols: Delimiters//EN" uri="ent/iso-amsc.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Added Math Symbols: Negated Relations//EN" uri="ent/iso-amsn.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Added Math Symbols: Ordinary//EN" uri="ent/iso-amso.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Added Math Symbols: Relations//EN" uri="ent/iso-amsr.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Box and Line Drawing//EN" uri="ent/iso-box.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Russian Cyrillic//EN" uri="ent/iso-cyr1.ent"/>
+  <public publicId="ISO 8879:1986//ENTITIES Non-Russian Cyrillic//EN" uri="ent/iso-cyr2.ent"/>
+</catalog>
diff --git a/gnu/packages/docbook.scm b/gnu/packages/docbook.scm
index 2d11333608..902e418b17 100644
--- a/gnu/packages/docbook.scm
+++ b/gnu/packages/docbook.scm
@@ -39,6 +39,7 @@ (define-module (gnu packages docbook)
   #:use-module (gnu packages web-browsers)
   #:use-module (gnu packages xml)
   #:use-module (guix gexp)
+  #:use-module (guix utils)
   #:use-module ((guix licenses) #:prefix license:)
   #:use-module (guix packages)
   #:use-module (guix download)
@@ -151,7 +152,40 @@ (define-public docbook-xml-4.1.2
                                   "/docbkx412.zip"))
               (sha256
                (base32
-                "0wkp5rvnqj0ghxia0558mnn4c7s3n501j99q2isp3sp0ci069w1h"))))))
+                "0wkp5rvnqj0ghxia0558mnn4c7s3n501j99q2isp3sp0ci069w1h"))))
+    (arguments
+     (substitute-keyword-arguments (package-arguments docbook-xml)
+       ((#:phases phases)
+        #~(modify-phases #$phases
+            (add-after 'unpack 'copy-catalog-file
+              ;; docbook-xml-4.1.2 is unique in the fact that it doesn't come
+              ;; with a catalog.xml file, requiring it to be generated by hand
+              ;; from the docbook.cat SGML catalog. We could automatically
+              ;; generate it here at the cost of enlarging the package
+              ;; definition with a rudimentary (PEG) parser for the SGML
+              ;; catalog but this is overkill since this file is unlikely to
+              ;; change, therefore we ship a pre-generated catalog.xml.
+              (lambda _
+                (copy-file
+                 #$(local-file
+                    (search-auxiliary-file
+                     "xml/docbook-xml/catalog-4.1.2.xml"))
+                 "catalog.xml")))
+            (add-after 'patch-catalog-xml 'add-rewrite-entries
+              (lambda* (#:key inputs #:allow-other-keys)
+                (let ((xmlcatalog (search-input-file inputs "/bin/xmlcatalog"))
+                      (dtd-path (string-append #$output "/xml/dtd/docbook")))
+                  (for-each
+                   (lambda (type)
+                     (invoke xmlcatalog "--noout"
+                             "--add" type
+                             "http://www.oasis-open.org/docbook/xml/4.1.2/"
+                             (string-append "file://" dtd-path "/")
+                             "catalog.xml"))
+                   (list "rewriteSystem" "rewriteURI")))))))))
+    (native-inputs
+     (modify-inputs (package-native-inputs docbook-xml)
+       (prepend libxml2)))))
 
 (define-public docbook-xsl
   (package
-- 
2.39.1





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

* bug#61015: [PATCH core-updates 0/9] Modernize and fix docbook-xml
  2023-03-11 17:54 ` [bug#61015] [PATCH v2 1/4] gnu: docbook-xml: Use copy-build-system Bruno Victal
                     ` (2 preceding siblings ...)
  2023-03-11 17:54   ` [bug#61015] [PATCH v2 4/4] gnu: docbook-xml-4.1.2: Add missing catalog.xml Bruno Victal
@ 2023-04-21  4:45   ` Maxim Cournoyer
  3 siblings, 0 replies; 16+ messages in thread
From: Maxim Cournoyer @ 2023-04-21  4:45 UTC (permalink / raw)
  To: Bruno Victal; +Cc: 61015-done

Hi,

Bruno Victal <mirai@makinata.eu> writes:

> * gnu/packages/docbook.scm
> (docbook-xml-5)[build-system]: Switch to copy-build-system.
> [source][arguments]: Adapt to copy-build-system.
> (docbook-xml)[arguments]: Remove.
> [source]: Switch to url-fetch/zipbomb.
> (docbook-xml-4.4)[source]: Switch to url-fetch/zipbomb.
> (docbook-xml-4.3)[source]: Switch to url-fetch/zipbomb.
> (docbook-xml-4.2)[source]: Switch to url-fetch/zipbomb.
> (docbook-xml-4.1.2)[arguments]: Remove.
> [source]: Switch to url-fetch/zipbomb.

Applied to core-updates, along multiple follow-up that cleaned things
up.  Thank you!

-- 
Thanks,
Maxim




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

end of thread, other threads:[~2023-04-21  4:46 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-01-23  3:31 [bug#61015] [PATCH core-updates 0/9] Modernize and fix docbook-xml Bruno Victal
2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 1/9] gnu: docbook-xml: Use copy-build-system Bruno Victal
2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 2/9] gnu: docbook-xml-4.1.2: Adapt to copy-build-system Bruno Victal
2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 3/9] gnu: docbook-xml: " Bruno Victal
2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 4/9] gnu: docbook-xml-4.4: " Bruno Victal
2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 5/9] gnu: docbook-xml-4.3: " Bruno Victal
2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 6/9] gnu: docbook-xml-4.2: " Bruno Victal
2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 7/9] gnu: docbook-xml: Fix permissions Bruno Victal
2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 8/9] gnu: docbook-xml: Use XSLT to patch catalog.xml Bruno Victal
2023-01-23  3:32 ` [bug#61015] [PATCH core-updates 9/9] gnu: docbook-xml-4.1.2: Add missing catalog.xml Bruno Victal
2023-03-06 15:22 ` [bug#61015] [PATCH core-updates 0/9] Modernize and fix docbook-xml Bruno Victal
2023-03-11 17:54 ` [bug#61015] [PATCH v2 1/4] gnu: docbook-xml: Use copy-build-system Bruno Victal
2023-03-11 17:54   ` [bug#61015] [PATCH v2 2/4] gnu: docbook-xml: Fix permissions Bruno Victal
2023-03-11 17:54   ` [bug#61015] [PATCH v2 3/4] gnu: docbook-xml: Use XSLT to patch catalog.xml Bruno Victal
2023-03-11 17:54   ` [bug#61015] [PATCH v2 4/4] gnu: docbook-xml-4.1.2: Add missing catalog.xml Bruno Victal
2023-04-21  4:45   ` bug#61015: [PATCH core-updates 0/9] Modernize and fix docbook-xml Maxim Cournoyer

Code repositories for project(s) associated with this public inbox

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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).