Skip to contentSkip to conversation

asciidoc: use local docbook XML catalogue

PATCH In review Ross Burton 1 participant 2 messages Apr 2, 2019

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 asciidoc: use local docbook XML catalogue

libxml-native by default uses a XML catalogue at /etc/xml/catalog, instead of the one in the sysroot. Until this is fixed (#13260) override the XML catalogue manually in the recipe.

---
 .../asciidoc/asciidoc/auto-catalogs.patch          | 27 ++++++++++++++++++++++
 meta/recipes-extended/asciidoc/asciidoc_8.6.9.bb   |  7 +++++-
 2 files changed, 33 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-extended/asciidoc/asciidoc/auto-catalogs.patch
meta/recipes-extended/asciidoc/asciidoc/auto-catalogs.patch new file +27 -0
new file mode 100644
index 00000000000..f507080cd3c
@@ -0,0 +1,27 @@
+If SGML_CATALOG_FILES is in the environment, pass --catalogs to xmllint.
+
+Upstream-Status: Submitted [https://github.com/asciidoc/asciidoc-py3/issues/61]
+Signed-off-by: Ross Burton <[email protected]>
+
+diff --git a/a2x.py b/a2x.py
+index 2d7699a..5bb995f 100755
+--- a/a2x.py
++++ b/a2x.py
+@@ -47,6 +47,8 @@ FOP = 'fop'                 # pdf generation (--fop option).
+ W3M = 'w3m'                 # primary text file generator.
+ LYNX = 'lynx'               # alternate text file generator.
+ XMLLINT = 'xmllint'         # Set to '' to disable.
++if "SGML_CATALOG_FILES" in os.environ:
++  XMLLINT += " --catalogs"
+ EPUBCHECK = 'epubcheck'     # Set to '' to disable.
+ # External executable default options.
+ ASCIIDOC_OPTS = ''
+@@ -634,7 +636,7 @@ class A2X(AttrDict):
+         shell('"%s" --backend docbook -a "a2x-format=%s" %s --out-file "%s" "%s"' %
+              (self.asciidoc, self.format, self.asciidoc_opts, docbook_file, self.asciidoc_file))
+         if not self.no_xmllint and XMLLINT:
+-            shell('"%s" --nonet --noout --valid "%s"' % (XMLLINT, docbook_file))
++            shell('%s --nonet --noout --valid "%s"' % (XMLLINT, docbook_file))
+ 
+     def to_xhtml(self):
+         self.to_docbook()
meta/recipes-extended/asciidoc/asciidoc_8.6.9.bb +6 -1
index d0d15171ac4..88ee93bfc10 100644
@@ -8,7 +8,8 @@ LICENSE = "GPLv2"
 LIC_FILES_CHKSUM = "file://COPYING;md5=8ca43cbc842c2336e835926c2166c28b \
                     file://COPYRIGHT;md5=029ad5428ba5efa20176b396222d4069"
 
-SRC_URI = "git://github.com/asciidoc/asciidoc-py3;protocol=https"
+SRC_URI = "git://github.com/asciidoc/asciidoc-py3;protocol=https \
+           file://auto-catalogs.patch"
 SRCREV = "618f6e6f6b558ed1e5f2588cd60a5a6b4f881ca0"
 PV .= "+py3-git${SRCPV}"
 
@@ -16,6 +17,10 @@ DEPENDS = "libxml2-native libxslt-native docbook-xml-dtd4-native"
 
 S = "${WORKDIR}/git"
 
+# Tell xmllint where to find the DocBook XML catalogue, because right now it
+# opens /etc/xml/catalog on the host. Depends on auto-catalogs.patch
+export SGML_CATALOG_FILES="file://${STAGING_ETCDIR_NATIVE}/xml/docbook-xml.xml"
+
 # Not using automake
 inherit autotools-brokensep
 CLEANBROKEN = "1"
Signature · 1 line
2.11.0
#1 lore raw

Retracting this: it then goes and downloads the xsl stylesheets during do_compile, which is slow and networking during a non-network phase. Easier hack incoming.

Ross

Quoted 73 lines · Ross Burton

libxml-native by default uses a XML catalogue at /etc/xml/catalog, instead of the one in the sysroot. Until this is fixed (#13260) override the XML catalogue manually in the recipe.

---
 .../asciidoc/asciidoc/auto-catalogs.patch          | 27 ++++++++++++++++++++++
 meta/recipes-extended/asciidoc/asciidoc_8.6.9.bb   |  7 +++++-
 2 files changed, 33 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-extended/asciidoc/asciidoc/auto-catalogs.patch
meta/recipes-extended/asciidoc/asciidoc/auto-catalogs.patch new file +27 -0
new file mode 100644
index 00000000000..f507080cd3c
@@ -0,0 +1,27 @@
+If SGML_CATALOG_FILES is in the environment, pass --catalogs to xmllint.
+
+Upstream-Status: Submitted [https://github.com/asciidoc/asciidoc-py3/issues/61]
+Signed-off-by: Ross Burton <[email protected]>
+
+diff --git a/a2x.py b/a2x.py
+index 2d7699a..5bb995f 100755
+--- a/a2x.py
++++ b/a2x.py
+@@ -47,6 +47,8 @@ FOP = 'fop'                 # pdf generation (--fop option).
+ W3M = 'w3m'                 # primary text file generator.
+ LYNX = 'lynx'               # alternate text file generator.
+ XMLLINT = 'xmllint'         # Set to '' to disable.
++if "SGML_CATALOG_FILES" in os.environ:
++  XMLLINT += " --catalogs"
+ EPUBCHECK = 'epubcheck'     # Set to '' to disable.
+ # External executable default options.
+ ASCIIDOC_OPTS = ''
+@@ -634,7 +636,7 @@ class A2X(AttrDict):
+         shell('"%s" --backend docbook -a "a2x-format=%s" %s --out-file "%s" "%s"' %
+              (self.asciidoc, self.format, self.asciidoc_opts, docbook_file, self.asciidoc_file))
+         if not self.no_xmllint and XMLLINT:
+-            shell('"%s" --nonet --noout --valid "%s"' % (XMLLINT, docbook_file))
++            shell('%s --nonet --noout --valid "%s"' % (XMLLINT, docbook_file))
+
+     def to_xhtml(self):
+         self.to_docbook()
meta/recipes-extended/asciidoc/asciidoc_8.6.9.bb +6 -2
index d0d15171ac4..88ee93bfc10 100644
@@ -8,7 +8,8 @@ LICENSE = "GPLv2"
 LIC_FILES_CHKSUM = "file://COPYING;md5=8ca43cbc842c2336e835926c2166c28b \
                     file://COPYRIGHT;md5=029ad5428ba5efa20176b396222d4069"
 
-SRC_URI = "git://github.com/asciidoc/asciidoc-py3;protocol=https"
+SRC_URI = "git://github.com/asciidoc/asciidoc-py3;protocol=https \
+           file://auto-catalogs.patch"
 SRCREV = "618f6e6f6b558ed1e5f2588cd60a5a6b4f881ca0"
 PV .= "+py3-git${SRCPV}"
 
@@ -16,6 +17,10 @@ DEPENDS = "libxml2-native libxslt-native docbook-xml-dtd4-native"
 
 S = "${WORKDIR}/git"
 
+# Tell xmllint where to find the DocBook XML catalogue, because right now it
+# opens /etc/xml/catalog on the host. Depends on auto-catalogs.patch
+export SGML_CATALOG_FILES="file://${STAGING_ETCDIR_NATIVE}/xml/docbook-xml.xml"
+
 # Not using automake
 inherit autotools-brokensep
 CLEANBROKEN = "1"
--

2.11.0