diff mbox series

[bug#65479,core-updates,v3,12/63] gnu: docbook2x: Import patches from debian.

Message ID 6b5e1ff27df3710beaf3238df4d1a603f9ce46a1.1696881354.git.mirai@makinata.eu
State New
Headers show
Series Docbook & XML/SGML improvements | expand

Commit Message

Bruno Victal Oct. 9, 2023, 8:06 p.m. UTC
* gnu/packages/docbook.scm (docbook2x)[source]: Import patches from
debian. Prefer patching in source over 'patch-sources phase. Drop docbook-xml
workaround.
[arguments]<#:phases>: Drop 'patch-sources.
[inputs]: Move after arguments. Remove docbook-xml-4.5.
[natine-inputs]: Add autoconf, automake and libtool.
* gnu/packages/patches/docbook2x-filename-handling.patch: New file.
* gnu/packages/patches/docbook2x-fix-synopsis.patch: Ditto.
* gnu/packages/patches/docbook2x-manpage-typo.patch: Ditto.
* gnu/packages/patches/docbook2x-preprocessor-declaration.patch: Ditto.
* gnu/packages/patches/docbook2x-static-datadir-evaluation.patch: Ditto.
* gnu/local.mk: Register it.
---
 gnu/local.mk                                  |  5 +
 gnu/packages/docbook.scm                      | 59 ++++++------
 .../patches/docbook2x-filename-handling.patch | 44 +++++++++
 .../patches/docbook2x-fix-synopsis.patch      | 26 ++++++
 .../patches/docbook2x-manpage-typo.patch      | 26 ++++++
 .../docbook2x-preprocessor-declaration.patch  | 91 +++++++++++++++++++
 .../docbook2x-static-datadir-evaluation.patch | 21 +++++
 7 files changed, 241 insertions(+), 31 deletions(-)
 create mode 100644 gnu/packages/patches/docbook2x-filename-handling.patch
 create mode 100644 gnu/packages/patches/docbook2x-fix-synopsis.patch
 create mode 100644 gnu/packages/patches/docbook2x-manpage-typo.patch
 create mode 100644 gnu/packages/patches/docbook2x-preprocessor-declaration.patch
 create mode 100644 gnu/packages/patches/docbook2x-static-datadir-evaluation.patch
diff mbox series

Patch

diff --git a/gnu/local.mk b/gnu/local.mk
index c4ad7cb901..d26a2e73b8 100644
--- a/gnu/local.mk
+++ b/gnu/local.mk
@@ -1076,6 +1076,11 @@  dist_patch_DATA =						\
   %D%/packages/patches/docbook-utils-respect-refentry-for-name.patch	\
   %D%/packages/patches/docbook-utils-source-date-epoch.patch	\
   %D%/packages/patches/docbook-utils-use-date-element.patch	\
+  %D%/packages/patches/docbook2x-filename-handling.patch	\
+  %D%/packages/patches/docbook2x-fix-synopsis.patch		\
+  %D%/packages/patches/docbook2x-manpage-typo.patch		\
+  %D%/packages/patches/docbook2x-preprocessor-declaration.patch	\
+  %D%/packages/patches/docbook2x-static-datadir-evaluation.patch	\
   %D%/packages/patches/doc++-include-directives.patch		\
   %D%/packages/patches/doc++-segfault-fix.patch			\
   %D%/packages/patches/dovecot-opensslv3.patch			\
diff --git a/gnu/packages/docbook.scm b/gnu/packages/docbook.scm
index f0e320ea9a..9d90779701 100644
--- a/gnu/packages/docbook.scm
+++ b/gnu/packages/docbook.scm
@@ -27,6 +27,7 @@ 
 
 (define-module (gnu packages docbook)
   #:use-module (gnu packages)
+  #:use-module (gnu packages autotools)
   #:use-module (gnu packages bash)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages imagemagick)
@@ -865,42 +866,27 @@  (define-public docbook2x
                                   version "/docbook2X-" version ".tar.gz"))
               (sha256
                (base32
-                "0ifwzk99rzjws0ixzimbvs83x6cxqk1xzmg84wa1p7bs6rypaxs0"))))
+                "0ifwzk99rzjws0ixzimbvs83x6cxqk1xzmg84wa1p7bs6rypaxs0"))
+              (patches
+               (search-patches "docbook2x-filename-handling.patch"
+                               "docbook2x-fix-synopsis.patch"
+                               "docbook2x-manpage-typo.patch"
+                               "docbook2x-preprocessor-declaration.patch"
+                               "docbook2x-static-datadir-evaluation.patch"))
+              (modules '((guix build utils)))
+              (snippet
+               ;; Fix a failing test (maybe it worked with old texinfo?)
+               #~(begin
+                   (substitute* "test/complete-manuals/at1.xml"
+                     (("<bridgehead>")
+                      "<bridgehead renderas=\"sect2\">"))
+                   ;; Force a new autoreconf run.
+                   (delete-file "configure")))))
     (build-system gnu-build-system)
-    (inputs
-     (list bash-minimal
-           docbook-xml-4.5
-           perl
-           perl-xml-namespacesupport
-           perl-xml-parser
-           perl-xml-sax
-           perl-xml-sax-base
-           texinfo
-           libxslt))
     (arguments
      (list
       #:phases
       #~(modify-phases %standard-phases
-          (add-after 'configure 'patch-sources
-            (lambda* (#:key inputs #:allow-other-keys)
-              ;; Fix failed substitution in config.pl
-              (substitute* "perl/config.pl"
-                (("\\$\\{prefix\\}")
-                 #$output))
-              ;; Fix a failing test (maybe it worked with old texinfo?)
-              (substitute* "test/complete-manuals/at1.xml"
-                (("<bridgehead>")
-                 "<bridgehead renderas=\"sect2\">"))
-              ;; Patch all the tests use DocBook 4.5
-              (substitute* (find-files "test" "\\.xml$")
-                (("\"-//OASIS//DTD DocBook XML V4\\..+//EN\"")
-                 "\"-//OASIS//DTD DocBook XML V4.5//EN\"")
-                (("\"http://www\\.oasis-open\\.org/docbook/xml/4\\..+/docbookx.dtd\"")
-                 "\"http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd\""))
-              ;; Set XML catalogs for tests to pass
-              (setenv "XML_CATALOG_FILES"
-                      (string-append (assoc-ref inputs "docbook-xml")
-                                     "/xml/dtd/docbook/catalog.xml"))))
           (add-after 'install 'wrap-programs
             (lambda* (#:key inputs outputs #:allow-other-keys)
               (let* ((programs
@@ -934,6 +920,17 @@  (define-public docbook2x
                      (symlink prog (string-append #$output
                                                   "/bin/db2x_" prog)))
                    '("docbook2man" "docbook2texi")))))))
+    (inputs
+     (list bash-minimal
+           perl
+           perl-xml-namespacesupport
+           perl-xml-parser
+           perl-xml-sax
+           perl-xml-sax-base
+           texinfo
+           libxslt))
+    (native-inputs
+     (list autoconf automake libtool))
     (home-page "https://docbook2x.sourceforge.net")
     (synopsis "Convert DocBook to man page and Texinfo format")
     (description
diff --git a/gnu/packages/patches/docbook2x-filename-handling.patch b/gnu/packages/patches/docbook2x-filename-handling.patch
new file mode 100644
index 0000000000..ebffd7b7ae
--- /dev/null
+++ b/gnu/packages/patches/docbook2x-filename-handling.patch
@@ -0,0 +1,44 @@ 
+# Source: <https://sources.debian.org/patches/docbook2x/0.8.8-18/03_fix_420153_filename_whitespace_handling.patch/>
+
+## 03_fix_420153_filename_whitespace_handling.dpatch by
+##     Daniel Leidert (dale) <daniel.leidert@wgdd.de>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Peter Eisentraut reported a regression in the whitespace handling of
+## DP: refentrytitle content during filename creation:
+## DP: http://bugs.debian.org/420153. The problem is, that upstream first
+## DP: replaces all spaces (but not linebreaks btw) with underlines and then
+## DP: it tries to normalize the result. This means, that a linebreak with
+## DP: additional whitespaces results in manpage names like 'foo_ ____bar.9'.
+## DP: So what we basically do in this patch is, that we first normalize the
+## DP: refentrytitle and then replace any spaces left with underlines.
+
+Edit by Bruno Victal <mirai@makinata.eu>:
+ Removed dpatch lines.
+
+--- docbook2x-0.8.8~/xslt/man/manpage.xsl	2006-04-20 15:45:55.000000000 +0200
++++ docbook2x-0.8.8/xslt/man/manpage.xsl	2007-04-20 16:19:28.000000000 +0200
+@@ -30,7 +30,7 @@
+ 
+ <xsl:template name="manpage-filename">
+   <xsl:param name="filename" />
+-  <xsl:value-of select="normalize-space(translate($filename, &quot; /&quot;, &quot;__&quot;))" />
++  <xsl:value-of select="translate(normalize-space($filename), ' /', '__')" />
+ </xsl:template>
+ 
+ 
+--- docbook2x-0.8.8~/xslt/man/refentry.xsl	2006-04-21 04:39:55.000000000 +0200
++++ docbook2x-0.8.8/xslt/man/refentry.xsl	2007-04-20 16:21:53.000000000 +0200
+@@ -38,7 +38,11 @@
+ <xsl:template name="refentry-filename">
+   <xsl:param name="title" />
+ 
+-  <xsl:variable name="title2" select="translate($title, &quot; /&quot;, &quot;__&quot;)" />
++  <xsl:variable name="title2">
++    <xsl:call-template name="manpage-filename">
++      <xsl:with-param name="filename" select="$title" />
++    </xsl:call-template>
++  </xsl:variable>
+ 
+   <!-- not using gentext here since man page names tend not to have
+        accented chars / non-Latin chars ...
diff --git a/gnu/packages/patches/docbook2x-fix-synopsis.patch b/gnu/packages/patches/docbook2x-fix-synopsis.patch
new file mode 100644
index 0000000000..315c93029b
--- /dev/null
+++ b/gnu/packages/patches/docbook2x-fix-synopsis.patch
@@ -0,0 +1,26 @@ 
+# Source: <https://sources.debian.org/patches/docbook2x/0.8.8-18/07_Fix-hyphens-in-commands-and-options-in-synopsis.patch/>
+
+From 06944d2bf8aa761ec6c145c964e59c3b1f41d7a5 Mon Sep 17 00:00:00 2001
+From: Samuel Thibault <sthibault@debian.org>
+Date: Wed, 6 Sep 2023 21:48:59 +0200
+Subject: man: Fix hyphens in commands and options in synopsis
+
+diff --git a/xslt/man/synop.xsl b/xslt/man/synop.xsl
+index 9713a1b..e535b75 100644
+--- a/xslt/man/synop.xsl
++++ b/xslt/man/synop.xsl
+@@ -107,9 +107,9 @@
+     <xsl:call-template name="cmdsynopsis-gentext-sepchar" />
+   </xsl:if>
+ 
+-  <b>
++  <xsl:call-template name="inline-bold-monospace">
+     <xsl:apply-templates mode="cmdsynopsis" />
+-  </b>
++  </xsl:call-template>
+ </xsl:template>
+ 
+ <xsl:template match="replaceable" mode="cmdsynopsis">
+-- 
+2.34.1
+
diff --git a/gnu/packages/patches/docbook2x-manpage-typo.patch b/gnu/packages/patches/docbook2x-manpage-typo.patch
new file mode 100644
index 0000000000..5b64ca837b
--- /dev/null
+++ b/gnu/packages/patches/docbook2x-manpage-typo.patch
@@ -0,0 +1,26 @@ 
+# Source: <https://sources.debian.org/patches/docbook2x/0.8.8-18/06_fix_man_typo.patch/>
+
+Author: Gianfranco Costamagna <costamagnagianfranco@yahoo.it>
+
+--- docbook2x-0.8.8.orig/doc/docbook2man.1
++++ docbook2x-0.8.8/doc/docbook2man.1
+@@ -187,7 +187,7 @@ parameter instead.
+ 
+ However, inside a custom stylesheet 
+ (\fInot on the command-line\fR)
+-this paramter can be set to the XPath expression
++this parameter can be set to the XPath expression
+ \*(T<document('')\*(T>,
+ which will cause the custom translations 
+ directly embedded inside the custom stylesheet to be read.
+--- docbook2x-0.8.8.orig/doc/docbook2texi.1
++++ docbook2x-0.8.8/doc/docbook2texi.1
+@@ -230,7 +230,7 @@ parameter instead.
+ 
+ However, inside a custom stylesheet 
+ (\fInot on the command-line\fR)
+-this paramter can be set to the XPath expression
++this parameter can be set to the XPath expression
+ \*(T<document('')\*(T>,
+ which will cause the custom translations 
+ directly embedded inside the custom stylesheet to be read.
diff --git a/gnu/packages/patches/docbook2x-preprocessor-declaration.patch b/gnu/packages/patches/docbook2x-preprocessor-declaration.patch
new file mode 100644
index 0000000000..34fb64c059
--- /dev/null
+++ b/gnu/packages/patches/docbook2x-preprocessor-declaration.patch
@@ -0,0 +1,91 @@ 
+# Source: <https://sources.debian.org/patches/docbook2x/0.8.8-18/04_fix_442782_preprocessor_declaration_syntax.patch/>
+
+## 04_fix_442782_preprocessor_declaration_syntax.dpatch by Colin Watson <cjwatson@debian.org>.
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Conventionally, preprocessor declarations should start with
+## DP:       '\"
+## DP:   rather than
+## DP:       .\"
+## DP:   Current man-db only supports the first (and recommended) syntax. So
+## DP:   Colin Watson provided this patch to fix docbook2x.
+## DP:
+## DP: <URL:http://bugs.debian.org/442782>
+## DP: <URL:http://lists.gnu.org/archive/html/groff/2007-11/msg00023.html>
+
+Edit by Bruno Victal <mirai@makinata.eu>:
+ Removed dpatch lines.
+
+--- trunk~/perl/db2x_manxml.pl	2006-04-22 17:21:32.000000000 +0200
++++ trunk/perl/db2x_manxml.pl	2007-11-24 01:27:37.000000000 +0100
+@@ -342,6 +342,25 @@
+     $self->{line_start} = 1;
+ }
+ 
++#
++# Print a comment in the output, without causing a break.
++# Params: comment - the comment text.  
++#                   May use any characters; they need not be escaped.
++#
++sub comment_nobreak
++{
++    my ($self, $comment) = @_;
++    $self->write("\n") unless $self->{line_start};
++
++    foreach my $line (split(/\n/, $comment)) {
++        $self->write('\'\" ');
++        $self->write($line);
++        $self->write("\n");
++    }
++
++    $self->{line_start} = 1;
++}
++
+ 
+ #
+ # Use a roff "escape" i.e. commands embedded in text starting with \
+@@ -510,16 +529,20 @@
+ 
+     $self->{'adjust-stack'} = [ 'b' ];
+ 
+-    $self->{rw}->comment($elem->attr('preprocessors'))
+-        if($elem->attr('preprocessors') ne '');
+-
++    my $preprocessors = $elem->attr('preprocessors');
+     # I've dug through the Internet to see if there was any
+     # standard way to specify encoding with man pages.
+     # The following seems to be a reasonable proposal:
+     # <URL:http://mail.nl.linux.org/linux-utf8/2001-04/msg00168.html>
+     my $encoding = $self->{options}->{'encoding'};
+     $encoding =~ s#//TRANSLIT$##i;
+-    $self->{rw}->comment("-*- coding: $encoding -*-");
++    $encoding = "-*- coding: $encoding -*-";
++    if ($preprocessors eq '') {
++        $preprocessors = $encoding;
++    } else {
++        $preprocessors = "$preprocessors $encoding";
++    }
++    $self->{rw}->comment_nobreak($preprocessors);
+     
+     # Define escapes for switching to and from monospace fonts (groff only)
+     $self->{rw}->request(qw{ .if \n(.g .ds T< \\\\FC});
+--- trunk~/xslt/backend/db2x_manxml.xsl	2006-04-23 16:44:52.000000000 +0200
++++ trunk/xslt/backend/db2x_manxml.xsl	2007-11-24 01:27:37.000000000 +0100
+@@ -528,7 +528,7 @@
+       <exslt:document method="text" 
+                       encoding="{$encoding}" 
+                       href="{$path}">
+-        <xsl:text>.\" -*- coding: </xsl:text>
++        <xsl:text>'\" -*- coding: </xsl:text>
+         <xsl:value-of select="$encoding" />
+         <xsl:text> -*-&#10;</xsl:text>
+         <xsl:copy-of select="$content" />
+@@ -538,7 +538,7 @@
+       <saxon:output method="text" 
+                     encoding="{$encoding}" 
+                     href="{$path}">
+-        <xsl:text>.\" -*- coding: </xsl:text>
++        <xsl:text>'\" -*- coding: </xsl:text>
+         <xsl:value-of select="$encoding" />
+         <xsl:text> -*-&#10;</xsl:text>
+         <xsl:copy-of select="$content" />
diff --git a/gnu/packages/patches/docbook2x-static-datadir-evaluation.patch b/gnu/packages/patches/docbook2x-static-datadir-evaluation.patch
new file mode 100644
index 0000000000..eb8844d379
--- /dev/null
+++ b/gnu/packages/patches/docbook2x-static-datadir-evaluation.patch
@@ -0,0 +1,21 @@ 
+# Source: <https://sources.debian.org/patches/docbook2x/0.8.8-18/01_fix_static_datadir_evaluation.patch/>
+
+Description:
+ 01_fix_static_datadir_evaluation.dpatch by Daniel Leidert (dale) <daniel.leidert@wgdd.de>
+ All lines beginning with `## DP:' are a description of the patch.
+ The evaluation of datadir results in "${prefix}/share" without
+ evaluation of the ${prefix} variable with autoconf 2.60.
+
+Index: docbook2X-0.8.8/configure.ac
+===================================================================
+--- docbook2X-0.8.8.orig/configure.ac
++++ docbook2X-0.8.8/configure.ac
+@@ -148,7 +148,7 @@
+ dnl they will reside and should use these static_* values.
+ dnl Ensure that all static_* are fully expanded.
+ 
+-eval static_datadir="$datadir"
++eval eval static_datadir="$datadir"
+ 
+ eval static_bindir="$bindir"
+ old_val=""