diff mbox series

[bug#50131,2/3] gnu: Add docbook2x.

Message ID 20210820120907.83191-2-whatson@gmail.com
State Accepted
Headers show
Series Add docbook2x and generate lxc man pages. | expand

Checks

Context Check Description
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue
cbaines/applying patch fail View Laminar job
cbaines/issue success View issue

Commit Message

Andrew Whatson Aug. 20, 2021, 12:09 p.m. UTC
* gnu/packages/docbook.scm (docbook2x): New variable.
---
 gnu/packages/docbook.scm | 87 ++++++++++++++++++++++++++++++++++++++++
 1 file changed, 87 insertions(+)

Comments

Thiago Jung Bauermann Aug. 26, 2021, 3:36 p.m. UTC | #1
Hello Andrew,

Em sexta-feira, 20 de agosto de 2021, às 09:09:06 -03, Andrew Whatson 
escreveu:
> * gnu/packages/docbook.scm (docbook2x): New variable.
> ---
>  gnu/packages/docbook.scm | 87 ++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 87 insertions(+)

FWIW, this looks good to me. Just one minor comment below.
 
> @@ -473,3 +478,85 @@ DB2LaTeX.")
>     (package/inherit dblatex
>       (inputs (alist-replace "imagemagick" `(,imagemagick/stable)
>                              (package-inputs dblatex))))))
> +
> +(define-public docbook2x
> +  (package
> +    (name "docbook2x")
> +    (version "0.8.8")
> +    (source (origin
> +              (method url-fetch)
> +              (uri (string-append
> "mirror://sourceforge/docbook2x/docbook2x/" +                           
>       version "/docbook2X-" version ".tar.gz")) +              (sha256
> +               (base32
> +               
> "0ifwzk99rzjws0ixzimbvs83x6cxqk1xzmg84wa1p7bs6rypaxs0")))) +   
> (build-system gnu-build-system)
> +    (inputs
> +     `(("bash-minimal" ,bash-minimal)
> +       ("docbook-xml" ,docbook-xml)
> +       ("perl" ,perl)
> +       ("perl-xml-namespacesupport" ,perl-xml-namespacesupport)
> +       ("perl-xml-parser" ,perl-xml-parser)
> +       ("perl-xml-sax" ,perl-xml-sax)
> +       ("perl-xml-sax-base" ,perl-xml-sax-base)
> +       ("texinfo" ,texinfo)
> +       ("xsltproc" ,libxslt)))
> +    (arguments
> +     `(#:configure-flags
> +       (list (string-append "--prefix=" (assoc-ref %outputs "out")))

There’s no need to pass the prefix argument. ‘gnu-build-system’ already 
does it.
diff mbox series

Patch

diff --git a/gnu/packages/docbook.scm b/gnu/packages/docbook.scm
index 6a69f8cf89..fdc432eb20 100644
--- a/gnu/packages/docbook.scm
+++ b/gnu/packages/docbook.scm
@@ -6,6 +6,7 @@ 
 ;;; Copyright © 2020 Marius Bakke <marius@gnu.org>
 ;;; Copyright © 2021 Maxim Cournoyer <maxim.cournoyer@gmail.com>
 ;;; Copyright © 2021 Mark H Weaver <mhw@netris.org>
+;;; Copyright © 2021 Andrew Whatson <whatson@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -24,10 +25,13 @@ 
 
 (define-module (gnu packages docbook)
   #:use-module (gnu packages)
+  #:use-module (gnu packages bash)
   #:use-module (gnu packages compression)
   #:use-module (gnu packages imagemagick)
   #:use-module (gnu packages inkscape)
   #:use-module (gnu packages tex)
+  #:use-module (gnu packages texinfo)
+  #:use-module (gnu packages perl)
   #:use-module (gnu packages python)
   #:use-module (gnu packages base)
   #:use-module (gnu packages xml)
@@ -35,6 +39,7 @@ 
   #:use-module (guix packages)
   #:use-module (guix download)
   #:use-module ((guix build utils) #:select (alist-replace))
+  #:use-module (guix build-system gnu)
   #:use-module (guix build-system trivial)
   #:use-module (guix build-system python))
 
@@ -473,3 +478,85 @@  DB2LaTeX.")
    (package/inherit dblatex
      (inputs (alist-replace "imagemagick" `(,imagemagick/stable)
                             (package-inputs dblatex))))))
+
+(define-public docbook2x
+  (package
+    (name "docbook2x")
+    (version "0.8.8")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "mirror://sourceforge/docbook2x/docbook2x/"
+                                  version "/docbook2X-" version ".tar.gz"))
+              (sha256
+               (base32
+                "0ifwzk99rzjws0ixzimbvs83x6cxqk1xzmg84wa1p7bs6rypaxs0"))))
+    (build-system gnu-build-system)
+    (inputs
+     `(("bash-minimal" ,bash-minimal)
+       ("docbook-xml" ,docbook-xml)
+       ("perl" ,perl)
+       ("perl-xml-namespacesupport" ,perl-xml-namespacesupport)
+       ("perl-xml-parser" ,perl-xml-parser)
+       ("perl-xml-sax" ,perl-xml-sax)
+       ("perl-xml-sax-base" ,perl-xml-sax-base)
+       ("texinfo" ,texinfo)
+       ("xsltproc" ,libxslt)))
+    (arguments
+     `(#:configure-flags
+       (list (string-append "--prefix=" (assoc-ref %outputs "out")))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'configure 'patch-sources
+           (lambda* (#:key inputs outputs #:allow-other-keys)
+             ;; Fix failed substitution in config.pl
+             (substitute* "perl/config.pl"
+               (("\\$\\{prefix\\}")
+                (assoc-ref outputs "out")))
+             ;; 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* ((out (assoc-ref outputs "out"))
+                    (programs
+                     (map (lambda (p)
+                            (string-append out "/bin/" p))
+                          '("db2x_manxml" "db2x_texixml" "db2x_xsltproc"
+                            "docbook2man" "docbook2texi")))
+                    (perl5lib
+                     (map (lambda (i)
+                            (string-append (assoc-ref inputs i)
+                                           "/lib/perl5/site_perl"))
+                          '("perl-xml-namespacesupport"
+                            "perl-xml-parser"
+                            "perl-xml-sax"
+                            "perl-xml-sax-base")))
+                    (xml-catalog-files
+                     (list (string-append (assoc-ref inputs "docbook-xml")
+                                          "/xml/dtd/docbook/catalog.xml"))))
+               (map (lambda (program)
+                      (wrap-program program
+                        `("PERL5LIB" ":" prefix
+                          ,perl5lib)
+                        `("XML_CATALOG_FILES" " " prefix
+                          ,xml-catalog-files)))
+                    programs)))))))
+    (home-page "http://docbook2x.sourceforge.net")
+    (synopsis "Convert DocBook to man page and Texinfo format")
+    (description
+     "docbook2X is a software package that converts DocBook documents into the
+traditional Unix man page format and the GNU Texinfo format.  Notable features
+include table support for man pages, internationalization support, and easy
+customization of the output using XSLT.")
+    (license license:expat)))