[PATCH core-updates 0/9] Modernize and fix docbook-xml

  • Open
  • quality assurance status badge
Details
One participant
  • Bruno Victal
Owner
unassigned
Submitted by
Bruno Victal
Severity
normal
B
B
Bruno Victal wrote on 23 Jan 04:31 +0100
(address . guix-patches@gnu.org)(name . Bruno Victal)(address . mirai@makinata.eu)
cover.1674443296.git.mirai@makinata.eu
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
B
B
Bruno Victal wrote on 23 Jan 04:32 +0100
[PATCH core-updates 1/9] gnu: docbook-xml: Use copy-build-system.
(address . 61015@debbugs.gnu.org)(name . Bruno Victal)(address . mirai@makinata.eu)
c84f097b5bb97a836c554f1fe8f271da42d50d6c.1674443296.git.mirai@makinata.eu
* 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(-)

Toggle diff (42 lines)
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
B
B
Bruno Victal wrote on 23 Jan 04:32 +0100
[PATCH core-updates 2/9] gnu: docbook-xml-4.1.2: Adapt to copy-build-system.
(address . 61015@debbugs.gnu.org)(name . Bruno Victal)(address . mirai@makinata.eu)
1a3d04377283b56ff657f64317aad2fd91922b96.1674443296.git.mirai@makinata.eu
* 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(-)

Toggle diff (42 lines)
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
B
B
Bruno Victal wrote on 23 Jan 04:32 +0100
[PATCH core-updates 3/9] gnu: docbook-xml: Adapt to copy-build-system.
(address . 61015@debbugs.gnu.org)(name . Bruno Victal)(address . mirai@makinata.eu)
d2385967e3daadb984b53ef748f9201cdf0238d8.1674443296.git.mirai@makinata.eu
* 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(-)

Toggle diff (40 lines)
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
B
B
Bruno Victal wrote on 23 Jan 04:32 +0100
[PATCH core-updates 4/9] gnu: docbook-xml-4.4: Adapt to copy-build-system.
(address . 61015@debbugs.gnu.org)(name . Bruno Victal)(address . mirai@makinata.eu)
0bbaed834af8621439ef732d5173b7b554480524.1674443296.git.mirai@makinata.eu
* 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(-)

Toggle diff (15 lines)
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
B
B
Bruno Victal wrote on 23 Jan 04:32 +0100
[PATCH core-updates 5/9] gnu: docbook-xml-4.3: Adapt to copy-build-system.
(address . 61015@debbugs.gnu.org)(name . Bruno Victal)(address . mirai@makinata.eu)
3b071541e8b9d71e1bd5f2c6f122900adffcbdb7.1674443296.git.mirai@makinata.eu
* 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(-)

Toggle diff (15 lines)
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
B
B
Bruno Victal wrote on 23 Jan 04:32 +0100
[PATCH core-updates 6/9] gnu: docbook-xml-4.2: Adapt to copy-build-system.
(address . 61015@debbugs.gnu.org)(name . Bruno Victal)(address . mirai@makinata.eu)
49b473b13d01393b36c5494a8bb5372b4ee4bea9.1674443296.git.mirai@makinata.eu
* 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(-)

Toggle diff (15 lines)
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
B
B
Bruno Victal wrote on 23 Jan 04:32 +0100
[PATCH core-updates 7/9] gnu: docbook-xml: Fix permissions.
(address . 61015@debbugs.gnu.org)(name . Bruno Victal)(address . mirai@makinata.eu)
87d74d07fd74d7ce0ffbe330aa72d327f7dc7708.1674443296.git.mirai@makinata.eu
* gnu/packages/docbook.scm (docbook-xml-5)
[arguments]: Remove unnecessary executable permissions.
---
gnu/packages/docbook.scm | 7 +++++++
1 file changed, 7 insertions(+)

Toggle diff (22 lines)
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
B
B
Bruno Victal wrote on 23 Jan 04:32 +0100
[PATCH core-updates 8/9] gnu: docbook-xml: Use XSLT to patch catalog.xml.
(address . 61015@debbugs.gnu.org)(name . Bruno Victal)(address . mirai@makinata.eu)
6c949db09590acc43d9af65726a9471240fc0bce.1674443296.git.mirai@makinata.eu
(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

Toggle diff (67 lines)
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
B
B
Bruno Victal wrote on 23 Jan 04:32 +0100
[PATCH core-updates 9/9] gnu: docbook-xml-4.1.2: Add missing catalog.xml.
(address . 61015@debbugs.gnu.org)(name . Bruno Victal)(address . mirai@makinata.eu)
547d75c1c95c3334a6d985c397651c84b660e49c.1674443296.git.mirai@makinata.eu
* 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

Toggle diff (88 lines)
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
?