diff options
| author | Bruno Victal <mirai@makinata.eu> | 2023-10-09 21:05:57 +0100 |
|---|---|---|
| committer | Ludovic Courtès <ludo@gnu.org> | 2024-08-31 10:42:08 +0200 |
| commit | 07114a3f34db9a86c599312d062fdac7780bda9d (patch) | |
| tree | 52bf93be8f29988b4be8aae544aa1b8ce7c3e554 /gnu/packages/docbook.scm | |
| parent | aeb0d142eb24c2a18840bd8cec66c77b237d9c5d (diff) | |
gnu: docbook-xsl: Add rewrite entries for http.
Refactored 'patch-catalog.xml to reduce code duplication.
The catalog for docbook-xsl hosted on the CDN [1] have entries for the 'http'
scheme yet when building from source only 'https' entries are generated.
Patch the XML catalog to provide them both.
[1]: <https://cdn.docbook.org/release/xsl/current/catalog.xml>
* gnu/packages/docbook.scm (docbook-xsl)[arguments]<#:phases>: Rename
'patch-catalog-xml to 'patch-catalog.xml. Refactor this phase for
deduplication and add 'https' entries.
Signed-off-by: Maxim Cournoyer <maxim.cournoyer@gmail.com>
Diffstat (limited to 'gnu/packages/docbook.scm')
| -rw-r--r-- | gnu/packages/docbook.scm | 142 |
1 files changed, 60 insertions, 82 deletions
diff --git a/gnu/packages/docbook.scm b/gnu/packages/docbook.scm index a0813211ca9..3e4f0607bb0 100644 --- a/gnu/packages/docbook.scm +++ b/gnu/packages/docbook.scm | |||
| @@ -342,93 +342,71 @@ downloading from @var{source}, where @var{version} is a string and | |||
| 342 | (add-before 'install 'generate-catalog.xml | 342 | (add-before 'install 'generate-catalog.xml |
| 343 | (lambda* (#:key make-flags #:allow-other-keys) | 343 | (lambda* (#:key make-flags #:allow-other-keys) |
| 344 | (apply invoke "make" "-C" "xsl" "catalog.xml" make-flags))) | 344 | (apply invoke "make" "-C" "xsl" "catalog.xml" make-flags))) |
| 345 | (add-before 'install 'patch-catalog-xml | 345 | (add-after 'generate-catalog.xml 'patch-catalog.xml |
| 346 | ;; Note: URI resolutions are not recursive. | ||
| 347 | ;; A rewrite rule from: | ||
| 348 | ;; 'http://docbook.sourceforge.net/release/xsl-ns/' | ||
| 349 | ;; to | ||
| 350 | ;; 'http://docbook.sourceforge.net/release/xsl/' | ||
| 351 | ;; will not trigger the rewrite rule that ultimately | ||
| 352 | ;; remaps to a /gnu/store URI, as can be seen by | ||
| 353 | ;; invoking: | ||
| 354 | ;; $ xmlcatalog "" \ | ||
| 355 | ;; 'http://docbook.sourceforge.net/release/xsl-ns/current/' | ||
| 356 | ;; http://docbook.sourceforge.net/release/xsl/current/ | ||
| 357 | ;; $ xmlcatalog "" \ | ||
| 358 | ;; 'http://docbook.sourceforge.net/release/xsl/current/' | ||
| 359 | ;; file:/gnu/store/…/xml/xsl/… | ||
| 360 | ;; | ||
| 361 | ;; See XML Catalog specification, item 7.2.2. for | ||
| 362 | ;; details. | ||
| 346 | (lambda* (#:key inputs #:allow-other-keys) | 363 | (lambda* (#:key inputs #:allow-other-keys) |
| 347 | (let ((xmlcatalog (search-input-file inputs | 364 | (let ((xmlcatalog (search-input-file inputs |
| 348 | "/bin/xmlcatalog")) | 365 | "/bin/xmlcatalog")) |
| 349 | (catalog-files (find-files "." "catalog\\.xml$")) | 366 | (catalog-file "xsl/catalog.xml") |
| 350 | (store-uri (string-append "file://" dest-path "/"))) | 367 | (store-uri (string-append "file:" dest-path "/"))) |
| 368 | ;; Remove /snapshot/ references. | ||
| 351 | (for-each | 369 | (for-each |
| 352 | (lambda (catalog) | 370 | (lambda (scheme) |
| 353 | ;; Replace /snapshot/ reference with one based on | 371 | (invoke xmlcatalog "--noout" |
| 354 | ;; BASE-VERSION. | 372 | "--del" |
| 355 | (let ((versioned-uri | 373 | (string-append |
| 356 | (format | 374 | scheme |
| 357 | #f "https://cdn.docbook.org/release/xsl/~a/" | 375 | "://cdn.docbook.org/release/xsl/snapshot/") |
| 358 | #$base-version))) | 376 | catalog-file)) |
| 359 | (invoke xmlcatalog "--noout" | 377 | (list "http" "https")) |
| 360 | "--del" | 378 | ;; Rewrite both http:// and https:// URIs. |
| 361 | "https://cdn.docbook.org/release/xsl/snapshot/" | 379 | (for-each |
| 362 | catalog) | 380 | (lambda (path) |
| 363 | (for-each | ||
| 364 | (lambda (type) | ||
| 365 | (invoke xmlcatalog "--noout" | ||
| 366 | "--add" type | ||
| 367 | versioned-uri | ||
| 368 | store-uri | ||
| 369 | catalog)) | ||
| 370 | (list "rewriteSystem" "rewriteURI"))) | ||
| 371 | |||
| 372 | ;; Patch /current/ references to point to /gnu/store/…. | ||
| 373 | (for-each | ||
| 374 | (lambda (type) | ||
| 375 | (invoke xmlcatalog "--noout" | ||
| 376 | "--add" type | ||
| 377 | "https://cdn.docbook.org/release/xsl/current/" | ||
| 378 | store-uri | ||
| 379 | catalog)) | ||
| 380 | (list "rewriteSystem" "rewriteURI")) | ||
| 381 | |||
| 382 | ;; Re-add the no longer present compatibility entries for | ||
| 383 | ;; v.1.79.1 or earlier URIs. | ||
| 384 | (for-each | ||
| 385 | (lambda (type) | ||
| 386 | (invoke xmlcatalog "--noout" | ||
| 387 | "--add" type | ||
| 388 | "http://docbook.sourceforge.net/release/xsl/current/" | ||
| 389 | store-uri | ||
| 390 | catalog)) | ||
| 391 | (list "rewriteSystem" "rewriteURI")) | ||
| 392 | |||
| 393 | ;; Originally the | ||
| 394 | ;; "http://docbook.sourceforge.net/release/xsl/" | ||
| 395 | ;; URI referred to the non-namespaced docbook-xsl, | ||
| 396 | ;; with its namespaced version using a URI differing in | ||
| 397 | ;; the path component as '…/xsl-ns/'. | ||
| 398 | ;; At some point the namespaced version was made the | ||
| 399 | ;; canonical docbook-xsl package whilst preserving the | ||
| 400 | ;; original URI. | ||
| 401 | ;; | ||
| 402 | ;; For compatibility with XML files that still specify | ||
| 403 | ;; the legacy namespaced docbook-xsl URIs we re-add them | ||
| 404 | ;; here. | ||
| 405 | (for-each | 381 | (for-each |
| 406 | (lambda (type) | 382 | (lambda (scheme) |
| 407 | ;; Remap /xsl-ns/ to /xsl/. | 383 | (for-each |
| 408 | ;; Note: URI resolutions are not recursive. | 384 | (lambda (entry-type) |
| 409 | ;; A rewrite rule from: | 385 | (let ((uri (string-append scheme "://" path))) |
| 410 | ;; 'http://docbook.sourceforge.net/release/xsl-ns/' | 386 | (invoke xmlcatalog "--noout" |
| 411 | ;; to | 387 | "--add" entry-type uri store-uri |
| 412 | ;; 'http://docbook.sourceforge.net/release/xsl/' | 388 | catalog-file))) |
| 413 | ;; will not trigger the rewrite rule that ultimately | 389 | (list "rewriteSystem" "rewriteURI"))) |
| 414 | ;; remaps to a /gnu/store URI, as can be seen by | 390 | (list "http" "https"))) |
| 415 | ;; invoking: | 391 | (list #$(format #f "cdn.docbook.org/release/xsl/~a/" |
| 416 | ;; $ xmlcatalog "" \ | 392 | base-version) |
| 417 | ;; 'http://docbook.sourceforge.net/release/xsl-ns/current/' | 393 | "cdn.docbook.org/release/xsl/current/" |
| 418 | ;; http://docbook.sourceforge.net/release/xsl/current/ | 394 | ;; Re-add the no longer present compatibility entries for |
| 419 | ;; $ xmlcatalog "" \ | 395 | ;; v.1.79.1 or earlier URIs. |
| 420 | ;; 'http://docbook.sourceforge.net/release/xsl/current/' | 396 | "docbook.sourceforge.net/release/xsl/current/" |
| 421 | ;; file://gnu/store/…/xml/xsl/… | 397 | ;; Originally the |
| 422 | ;; | 398 | ;; "http://docbook.sourceforge.net/release/xsl/" |
| 423 | ;; See XML Catalog specification, item 7.2.2. for | 399 | ;; URI referred to the non-namespaced docbook-xsl, |
| 424 | ;; details. | 400 | ;; with its namespaced version using a URI differing in |
| 425 | (invoke xmlcatalog "--noout" | 401 | ;; the path component as '…/xsl-ns/'. |
| 426 | "--add" type | 402 | ;; At some point the namespaced version was made the |
| 427 | "http://docbook.sourceforge.net/release/xsl-ns/current/" | 403 | ;; canonical docbook-xsl package whilst preserving the |
| 428 | store-uri | 404 | ;; original URI. |
| 429 | catalog)) | 405 | ;; |
| 430 | (list "rewriteSystem" "rewriteURI"))) | 406 | ;; For compatibility with XML files that still specify |
| 431 | catalog-files)))) | 407 | ;; the legacy namespaced docbook-xsl URIs we re-add them |
| 408 | ;; here. | ||
| 409 | "docbook.sourceforge.net/release/xsl-ns/current/"))))) | ||
| 432 | (replace 'install | 410 | (replace 'install |
| 433 | (lambda _ | 411 | (lambda _ |
| 434 | (let ((select-rx (make-regexp | 412 | (let ((select-rx (make-regexp |
