diff mbox series

[bug#65479,core-updates,v3,02/63] search-paths: Add $XML_CATALOG_FILES and $SGML_CATALOG_FILES.

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

Commit Message

Bruno Victal Oct. 9, 2023, 8:05 p.m. UTC
These variables are used by some packages for XML/SGML catalog lookups.

* guix/search-paths ($XML_CATALOG_FILES, $SGML_CATALOG_FILES): New variable,
extracted from …
* gnu/packages/xml.scm (libxml2, opensp)[native-search-paths]: … here. Refer
to the variables from (guix search-paths) respectively.
* gnu/packages/perl.scm
(perl-app-xml-docbook-builder)[native-search-paths]: Use $XML_CATALOG_FILES.
* doc/guix.texi (Search Paths): Update documentation to reflect changes.
---
 doc/guix.texi         | 33 ++++++++++++++++++++-------------
 gnu/packages/perl.scm |  7 +------
 gnu/packages/xml.scm  | 19 +++----------------
 guix/search-paths.scm | 25 +++++++++++++++++++++++++
 4 files changed, 49 insertions(+), 35 deletions(-)

Comments

Ludovic Courtès Oct. 12, 2023, 7:16 a.m. UTC | #1
Hi Bruno,

Bruno Victal <mirai@makinata.eu> skribis:

> These variables are used by some packages for XML/SGML catalog lookups.
>
> * guix/search-paths ($XML_CATALOG_FILES, $SGML_CATALOG_FILES): New variable,
> extracted from …
> * gnu/packages/xml.scm (libxml2, opensp)[native-search-paths]: … here. Refer
> to the variables from (guix search-paths) respectively.
> * gnu/packages/perl.scm
> (perl-app-xml-docbook-builder)[native-search-paths]: Use $XML_CATALOG_FILES.
> * doc/guix.texi (Search Paths): Update documentation to reflect changes.

The way I see it, we’d define in (guix search-paths) only search paths
that are repeated in several different places, like $SSL_CERT_DIR.

$XML_CATALOG_FILES has 2 users, one of which looks dubious and should
probably be audited, and $SGML_CATALOG_FILES has only 1 user.  Thus, the
status quo seems good to me.

WDYT?

(BTW, the patch would be acceptable for ‘master’ as it does not trigger
any rebuild if I’m not mistaken.)

Thanks,
Ludo’.
Simon Tournier Oct. 12, 2023, 7:36 a.m. UTC | #2
Hi Ludo,

On Thu, 12 Oct 2023 at 09:16, Ludovic Courtès <ludo@gnu.org> wrote:

> (BTW, the patch would be acceptable for ‘master’ as it does not trigger
> any rebuild if I’m not mistaken.)

FYI and as said in [1], the series is now part of core-updates.  For
instance this patch is 1e82e148e1d15f2faa761ec9f50f9392039696d2.

     1: bug#65479: [PATCH core-updates v3 00/63] Docbook & XML/SGML improvements
     Maxim Cournoyer <maxim.cournoyer@gmail.com>
     Tue, 10 Oct 2023 21:25:07 -0400
     id:87fs2ieyrw.fsf@gmail.com
     https://issues.guix.gnu.org/65479
     https://issues.guix.gnu.org/msgid/87fs2ieyrw.fsf@gmail.com
     https://yhetil.org/guix/87fs2ieyrw.fsf@gmail.com


Cheers,
simon
Bruno Victal Oct. 12, 2023, 1:14 p.m. UTC | #3
Hi Ludo’,

On 2023-10-12 08:16, Ludovic Courtès wrote:
> Hi Bruno,
> 
> Bruno Victal <mirai@makinata.eu> skribis:
> 
>> These variables are used by some packages for XML/SGML catalog lookups.
>>
>> * guix/search-paths ($XML_CATALOG_FILES, $SGML_CATALOG_FILES): New variable,
>> extracted from …
>> * gnu/packages/xml.scm (libxml2, opensp)[native-search-paths]: … here. Refer
>> to the variables from (guix search-paths) respectively.
>> * gnu/packages/perl.scm
>> (perl-app-xml-docbook-builder)[native-search-paths]: Use $XML_CATALOG_FILES.
>> * doc/guix.texi (Search Paths): Update documentation to reflect changes.
> 
> The way I see it, we’d define in (guix search-paths) only search paths
> that are repeated in several different places, like $SSL_CERT_DIR.

I didn't do an exhaustive search of what applications under the sun make use
of the XML_CATALOG_FILES and SGML_CATALOG_FILES environment variables but I
can say that we were missing them in a few crucial packages. In the packages
where I added these search-paths (spans across various patches) I went through
their manpages and in some occasions had to grep through their source code to
confirm this.

[…]

> $XML_CATALOG_FILES has 2 users, one of which looks dubious and should
> probably be audited, and $SGML_CATALOG_FILES has only 1 user.  Thus, the
> status quo seems good to me.

Which package are you finding its use dubious?
By 2 users I presume the ones within the commit which isn't the end of the tale,
see patches 03-04, 15, 18 and 24-25.
In v1/v2 their use was much more pronounced until Maxims suggestion of introducing
%libxslt-search-paths [1] to avoid top-level import cycles. (whilst also being
a more concise way to convey this information without manually duplicating it
when cycles did occur in v2)

$SGML_CATALOG_FILES actually has other users, opensp [2], libxml2 and libxslt
come to mind and are used in subsequent patches within the series.


[1]: Message-Id: <87a5swmxhn.fsf@gmail.com>
     Link: <https://lists.gnu.org/archive/html/guix-patches/2023-10/msg00268.html>
[2]: Message-Id: <e4e0b35c-00f9-5532-2a1d-84ad032a3e09@makinata.eu>
     Link: <https://lists.gnu.org/archive/html/guix-patches/2023-06/msg00395.html>
Ludovic Courtès Oct. 14, 2023, 5:17 p.m. UTC | #4
Hello,

Bruno Victal <mirai@makinata.eu> skribis:

>> The way I see it, we’d define in (guix search-paths) only search paths
>> that are repeated in several different places, like $SSL_CERT_DIR.
>
> I didn't do an exhaustive search of what applications under the sun make use
> of the XML_CATALOG_FILES and SGML_CATALOG_FILES environment variables but I
> can say that we were missing them in a few crucial packages. In the packages
> where I added these search-paths (spans across various patches) I went through
> their manpages and in some occasions had to grep through their source code to
> confirm this.
>
> […]
>
>> $XML_CATALOG_FILES has 2 users, one of which looks dubious and should
>> probably be audited, and $SGML_CATALOG_FILES has only 1 user.  Thus, the
>> status quo seems good to me.
>
> Which package are you finding its use dubious?

On ‘master’, ‘XML_CATALOG_FILES’ is the search path of
‘perl-app-xml-docbook-builder’ and ‘libxml2’.  The first looks more like
a hack, with this comment:

  ;; xsltproc's search paths, to avoid propagating libxslt.

> By 2 users I presume the ones within the commit which isn't the end of the tale,
> see patches 03-04, 15, 18 and 24-25.

Oh my bad, I guess I didn’t see the whole series.

> In v1/v2 their use was much more pronounced until Maxims suggestion of introducing
> %libxslt-search-paths [1] to avoid top-level import cycles. (whilst also being
> a more concise way to convey this information without manually duplicating it
> when cycles did occur in v2)
>
> $SGML_CATALOG_FILES actually has other users, opensp [2], libxml2 and libxslt
> come to mind and are used in subsequent patches within the series.

Alright.

Sorry for being late to the party; maybe these comments of mine are
completely off for ‘core-updates’, apologies.

Ludo’.
Bruno Victal Oct. 15, 2023, 3:10 p.m. UTC | #5
On 2023-10-14 18:17, Ludovic Courtès wrote:
> Sorry for being late to the party; maybe these comments of mine are
> completely off for ‘core-updates’, apologies.

No problem! Thanks for giving a look at it nonetheless.
diff mbox series

Patch

diff --git a/doc/guix.texi b/doc/guix.texi
index 8c5697589f..4afe1af6c0 100644
--- a/doc/guix.texi
+++ b/doc/guix.texi
@@ -11144,17 +11144,14 @@  Search Paths
 to be found in @file{xml} sub-directories---nothing less.  The search
 path specification looks like this:
 
+@c This is defined at (guix search-paths) as $XML_CATALOG_FILES.
 @lisp
-(package
-  (name "libxml2")
-  ;; some fields omitted
-  (native-search-paths
-   (list (search-path-specification
-          (variable "XML_CATALOG_FILES")
-          (separator " ")
-          (files '("xml"))
-          (file-pattern "^catalog\\.xml$")
-          (file-type 'regular)))))
+(search-path-specification
+ (variable "XML_CATALOG_FILES")
+ (separator " ")
+ (files '("xml"))
+ (file-pattern "^catalog\\.xml$")
+ (file-type 'regular))
 @end lisp
 
 Worry not, search path specifications are usually not this tricky.
@@ -11190,15 +11187,16 @@  Search Paths
 though it can be any symbol returned by @code{stat:type} (@pxref{File
 System, @code{stat},, guile, GNU Guile Reference Manual}).
 
-In the libxml2 example above, we would match regular files; in the
-Python example, we would match directories.
+In the @env{XML_CATALOG_FILES} example above, we would match regular
+files; in the Python example, we would match directories.
 
 @item @code{file-pattern} (default: @code{#f})
 This must be either @code{#f} or a regular expression specifying
 files to be matched @emph{within} the sub-directories specified by the
 @code{files} field.
 
-Again, the libxml2 example shows a situation where this is needed.
+Again, the @env{XML_CATALOG_FILES} example shows a situation where this
+is needed.
 @end table
 @end deftp
 
@@ -11206,6 +11204,15 @@  Search Paths
 To reduce duplications, some of them are pre-defined in @code{(guix
 search-paths)}.
 
+@defvar $SGML_CATALOG_FILES
+@defvarx $XML_CATALOG_FILES
+These two search paths indicate where the
+@url{https://www.oasis-open.org/specs/a401.htm,TR9401 catalog}@footnote{
+Alternatively known as SGML catalog.} or
+@url{https://www.oasis-open.org/committees/download.php/14809/xml-catalogs.html,
+XML catalog} files can be found.
+@end defvar
+
 @defvar $SSL_CERT_DIR
 @defvarx $SSL_CERT_FILE
 These two search paths indicate where X.509 certificates can be found
diff --git a/gnu/packages/perl.scm b/gnu/packages/perl.scm
index 8b82c272fc..267a35e560 100644
--- a/gnu/packages/perl.scm
+++ b/gnu/packages/perl.scm
@@ -601,12 +601,7 @@  (define-public perl-app-xml-docbook-builder
      (list perl-class-xsaccessor perl-test-trap))
     (native-search-paths
      ;; xsltproc's search paths, to avoid propagating libxslt.
-     (list (search-path-specification
-            (variable "XML_CATALOG_FILES")
-            (separator " ")
-            (files '("xml"))
-            (file-pattern "^catalog\\.xml$")
-            (file-type 'regular))))
+     (list $XML_CATALOG_FILES))
     (home-page "https://www.shlomifish.org/open-source/projects/docmake/")
     (synopsis "Translate DocBook/XML documentation into other file formats")
     (description
diff --git a/gnu/packages/xml.scm b/gnu/packages/xml.scm
index cc26e2fa67..baf024820c 100644
--- a/gnu/packages/xml.scm
+++ b/gnu/packages/xml.scm
@@ -83,6 +83,7 @@  (define-module (gnu packages xml)
   #:use-module (guix build-system python)
   #:use-module (guix deprecation)
   #:use-module (guix utils)
+  #:use-module (guix search-paths)
   #:use-module (gnu packages linux)
   #:use-module (gnu packages pkg-config))
 
@@ -225,14 +226,7 @@  (define-public libxml2
     (inputs (list xz))
     (propagated-inputs (list zlib)) ; libxml2.la says '-lz'.
     (native-inputs (list perl))
-    ;; $XML_CATALOG_FILES lists 'catalog.xml' files found in under the 'xml'
-    ;; sub-directory of any given package.
-    (native-search-paths (list (search-path-specification
-                                (variable "XML_CATALOG_FILES")
-                                (separator " ")
-                                (files '("xml"))
-                                (file-pattern "^catalog\\.xml$")
-                                (file-type 'regular))))
+    (native-search-paths (list $XML_CATALOG_FILES))
     (search-paths native-search-paths)
     (description
      "Libxml2 is the XML C parser and toolkit developed for the Gnome
@@ -1806,14 +1800,7 @@  (define-public opensp
                 (("^\tOSGMLNORM=`echo osgmlnorm\\|sed '\\$\\(transform\\)'`\\\\")
                  "\tOSGMLNORM=`echo osgmlnorm|sed '$(transform)'`")
                 (("^\t\\$\\(SHELL\\)\n") "")))))))
-    ;; $SGML_CATALOG_FILES lists 'catalog' or 'CATALOG' or '*.cat' files found
-    ;; under the 'sgml' sub-directory of any given package.
-    (native-search-paths (list (search-path-specification
-                                (variable "SGML_CATALOG_FILES")
-                                (separator ":")
-                                (files '("sgml"))
-                                (file-pattern "^catalog$|^CATALOG$|^.*\\.cat$")
-                                (file-type 'regular))))
+    (native-search-paths (list $SGML_CATALOG_FILES))
     (home-page "https://openjade.sourceforge.net/")
     (synopsis "Suite of SGML/XML processing tools")
     (description "OpenSP is an object-oriented toolkit for SGML parsing and
diff --git a/guix/search-paths.scm b/guix/search-paths.scm
index 5375fae34b..d325e57989 100644
--- a/guix/search-paths.scm
+++ b/guix/search-paths.scm
@@ -42,6 +42,8 @@  (define-module (guix search-paths)
             $SSL_CERT_DIR
             $SSL_CERT_FILE
             $TZDIR
+            $SGML_CATALOG_FILES
+            $XML_CATALOG_FILES
 
             %gcc-search-paths
 
@@ -154,6 +156,29 @@  (define $TZDIR
    (files '("share/zoneinfo"))
    (separator #f)))                     ;single entry
 
+;; Some packages (notably libxml2) make use of 'XML_CATALOG_FILES'
+;; and 'SGML_CATALOG_FILES' for remapping URI references or public/system
+;; identifiers to other URI references.
+(define $SGML_CATALOG_FILES
+  ;; $SGML_CATALOG_FILES lists 'catalog' or 'CATALOG' or '*.cat' files found
+  ;; under the 'sgml' sub-directory of any given package.
+  (search-path-specification
+   (variable "SGML_CATALOG_FILES")
+   (separator ":")
+   (files '("sgml"))
+   (file-pattern "^catalog$|^CATALOG$|^.*\\.cat$")
+   (file-type 'regular)))
+
+(define $XML_CATALOG_FILES
+  ;; $XML_CATALOG_FILES lists 'catalog.xml' files found in under the 'xml'
+  ;; sub-directory of any given package.
+  (search-path-specification
+   (variable "XML_CATALOG_FILES")
+   (separator " ")
+   (files '("xml"))
+   (file-pattern "^catalog\\.xml$")
+   (file-type 'regular)))
+
 (define (search-path-specification->sexp spec)
   "Return an sexp representing SPEC, a <search-path-specification>.  The sexp
 corresponds to the arguments expected by `set-path-environment-variable'."