From: Tom Lane <tgl@sss.pgh.pa.us>
To: Aleksander Alekseev <aleksander@timescale.com>
Cc: PostgreSQL Hackers <pgsql-hackers@lists.postgresql.org>
Cc: Peter Eisentraut <peter.eisentraut@enterprisedb.com>
Subject: Re: MacOS: xsltproc fails with "warning: failed to load external entity"
Date: Tue, 31 Jan 2023 18:54:31 -0500
Message-ID: <1275436.1675209271@sss.pgh.pa.us> (raw)
In-Reply-To: <1234349.1675196522@sss.pgh.pa.us>
References: <CAJ7c6TO8Aro2nxg=EQsVGiSDe-TstP4EsSvDHd7DSRsP40PgGA@mail.gmail.com>
<CAJ7c6TO0mA_wPDuUT8b+DdwzUe+SBfGqHE+XXb52GrRnLWu1iQ@mail.gmail.com>
<CAJ7c6TNq3phiefEopG8X7ZJ7oj7kZyQdPefHM+kt=XvVPkd08Q@mail.gmail.com>
<489604.1675095648@sss.pgh.pa.us>
<CAJ7c6TO3w+F8TvhNq-_GCOa8KUGbZjCdqynb7hCEAr5jq0giTQ@mail.gmail.com>
<1182c94f-bd43-262c-9452-597ca7d7a742@enterprisedb.com>
<CAJ7c6TMSsn2r0VLJ6zYM=9TRh5j6JDDSARczFG+wa+BS1A9LWQ@mail.gmail.com>
<1234349.1675196522@sss.pgh.pa.us>
I wrote:
> It's worse than that: I find that
> export XML_CATALOG_FILES=/dev/null
> breaks the docs build on RHEL8 and Fedora 37 (latest) too, with the
> same "failed to load external entity" symptom. I conclude from this
> that there is no version of xsltproc anywhere that can still download
> the required files automatically. So we need to take out the advice
> that says you can rely on auto-download for everybody, not just macOS.
> If this is indeed the case, perhaps we ought to start inserting --nonet
> into the invocations. There's not much use in allowing these tools to
> perform internet access when the best-case scenario is that they fail.
Concretely, I'm thinking something like the attached. Notes:
1. I have not tested the meson changes.
2. As this is written, you can't override the --nonet options very
easily in the Makefile build (you could do so at runtime by setting
XSLTPROC, but not at configure time); and you can't override them at
all in the meson build. Given the lack of evidence that it's still
useful to allow net access, I'm untroubled by that. I did intentionally
skip using "override" in the Makefile, though, to allow that case.
3. For consistency with the directions for other platforms, I made
the package lists for macOS just mention libxslt. That should
be enough to pull in libxml2 as well.
4. Use of --nonet changes the error message you get if xsltproc
can't find the DTDs. I copied the error I get from MacPorts'
version of xsltproc, but can you confirm it's the same on Homebrew?
regards, tom lane
Attachments:
[text/x-diff] force-use-of-nonet-for-docs-build-1.patch (4.6K, ../1275436.1675209271@sss.pgh.pa.us/2-force-use-of-nonet-for-docs-build-1.patch)
download | inline diff:diff --git a/doc/src/sgml/Makefile b/doc/src/sgml/Makefileindex 4f0e39223c..b96c7cbf22 100644--- a/doc/src/sgml/Makefile+++ b/doc/src/sgml/Makefile@@ -41,11 +41,15 @@ endif
XMLINCLUDE = --path .
-ifndef XMLLINT+ifdef XMLLINT+XMLLINT := $(XMLLINT) --nonet+else
XMLLINT = $(missing) xmllint
endif
-ifndef XSLTPROC+ifdef XSLTPROC+XSLTPROC := $(XSLTPROC) --nonet+else
XSLTPROC = $(missing) xsltproc
endif
diff --git a/doc/src/sgml/docguide.sgml b/doc/src/sgml/docguide.sgmlindex 787caef70d..cf9d4d4389 100644--- a/doc/src/sgml/docguide.sgml+++ b/doc/src/sgml/docguide.sgml@@ -151,18 +151,6 @@
here.
</para>
- <para>- You can get away with not installing DocBook XML and the DocBook XSLT- stylesheets locally, because the required files will be downloaded from the- Internet and cached locally. This may in fact be the preferred solution if- your operating system packages provide only an old version of these files,- or if no packages are available at all.- If you want to prevent any attempt to access the Internet while building- the documentation, you need to pass the <option>--nonet</option> option- to <command>xmllint</command> and <command>xsltproc</command>; see below- for an example.- </para>-
<sect2 id="docguide-toolsets-inst-fedora-et-al">
<title>Installation on Fedora, RHEL, and Derivatives</title>
@@ -207,22 +195,38 @@ apt-get install docbook-xml docbook-xsl fop libxml2-utils xsltproc
<sect2 id="docguide-toolsets-inst-macos">
<title>macOS</title>
- <para>- On macOS, you can build the HTML and man documentation without installing- anything extra. If you want to build PDFs or want to install a local copy- of DocBook, you can get those from your preferred package manager.- </para>-
<para>
If you use MacPorts, the following will get you set up:
<programlisting>
-sudo port install docbook-xml-4.5 docbook-xsl fop+sudo port install docbook-xml docbook-xsl-nons fop libxslt
</programlisting>
If you use Homebrew, use this:
<programlisting>
-brew install docbook docbook-xsl fop+brew install docbook docbook-xsl fop libxslt
</programlisting>
</para>
++ <para>+ The Homebrew-supplied programs require the following environment variable+ to be set:+<programlisting>+export XML_CATALOG_FILES=/usr/local/etc/xml/catalog+</programlisting>+ Without it, <command>xsltproc</command> will throw errors like this:+<programlisting>+I/O error : Attempt to load network entity http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd+postgres.sgml:21: warning: failed to load external entity "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd"+...+</programlisting>+ </para>++ <para>+ While it is possible to use the Apple-provided versions+ of <command>xmllint</command> and <command>xsltproc</command>+ instead of those from MacPorts or Homebrew, you'll still need+ to install the DocBook DTD and stylesheets, and set up a catalog+ file that points to them.+ </para>
</sect2>
<sect2 id="docguide-toolsets-configure">
@@ -253,12 +257,6 @@ checking for dbtoepub... dbtoepub
these programs, for example
<screen>
./configure ... XMLLINT=/opt/local/bin/xmllint ...
-</screen>- Also, if you want to ensure that <filename>xmllint</filename>- and <filename>xsltproc</filename> will not perform any network access,- you can do something like-<screen>-./configure ... XMLLINT="xmllint --nonet" XSLTPROC="xsltproc --nonet" ...
</screen>
</para>
</sect2>
diff --git a/doc/src/sgml/images/Makefile b/doc/src/sgml/images/Makefileindex f9e356348b..645519095d 100644--- a/doc/src/sgml/images/Makefile+++ b/doc/src/sgml/images/Makefile@@ -9,7 +9,7 @@ ALL_IMAGES = \
DITAA = ditaa
DOT = dot
-XSLTPROC = xsltproc+XSLTPROC = xsltproc --nonet
all: $(ALL_IMAGES)
diff --git a/doc/src/sgml/meson.build b/doc/src/sgml/meson.buildindex b9f4c6a05b..524a4e00e4 100644--- a/doc/src/sgml/meson.build+++ b/doc/src/sgml/meson.build@@ -87,7 +87,8 @@ postgres_full_xml = custom_target('postgres-full.xml',
input: 'postgres.sgml',
output: 'postgres-full.xml',
depfile: 'postgres-full.xml.d',
- command: [xmllint, '--noent', '--valid', '--path', '@OUTDIR@', '-o', '@OUTPUT@', '@INPUT@'],+ command: [xmllint, '--nonet', '--noent', '--valid',+ '--path', '@OUTDIR@', '-o', '@OUTPUT@', '@INPUT@'],
depends: doc_generated,
build_by_default: false,
)
@@ -100,6 +101,7 @@ alldocs += postgres_full_xml
#
if xsltproc_bin.found()
xsltproc_flags = [
+ '--nonet',
'--stringparam', 'pg.version', pg_version,
'--param', 'website.stylesheet', '1'
]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: tgl@sss.pgh.pa.us, aleksander@timescale.com, pgsql-hackers@lists.postgresql.org, peter.eisentraut@enterprisedb.com
Subject: Re: MacOS: xsltproc fails with "warning: failed to load external entity"
In-Reply-To: <1275436.1675209271@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox