From patchwork Wed Aug 23 22:34:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bruno Victal X-Patchwork-Id: 53136 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id A3A9D27BBEC; Wed, 23 Aug 2023 23:38:35 +0100 (BST) X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, SPF_HELO_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mira.cbaines.net (Postfix) with ESMTPS id 4284727BBE2 for ; Wed, 23 Aug 2023 23:38:34 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qYwTP-0007rv-0f; Wed, 23 Aug 2023 18:37:11 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qYwTF-0007mO-Jk for guix-patches@gnu.org; Wed, 23 Aug 2023 18:37:01 -0400 Received: from debbugs.gnu.org ([2001:470:142:5::43]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qYwTE-0004vW-I2 for guix-patches@gnu.org; Wed, 23 Aug 2023 18:37:00 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qYwTI-0004AC-65 for guix-patches@gnu.org; Wed, 23 Aug 2023 18:37:04 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65479] [PATCH core-updates 05/61] gnu: docbook-xsl: Add rewrite entries for http. Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Wed, 23 Aug 2023 22:37:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 65479 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 65479@debbugs.gnu.org Cc: Bruno Victal Received: via spool by 65479-submit@debbugs.gnu.org id=B65479.169283018715526 (code B ref 65479); Wed, 23 Aug 2023 22:37:04 +0000 Received: (at 65479) by debbugs.gnu.org; 23 Aug 2023 22:36:27 +0000 Received: from localhost ([127.0.0.1]:35336 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qYwSf-00042E-Ov for submit@debbugs.gnu.org; Wed, 23 Aug 2023 18:36:26 -0400 Received: from smtpm3.myservices.hosting ([185.26.105.234]:44612) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qYwSR-00040F-Qh for 65479@debbugs.gnu.org; Wed, 23 Aug 2023 18:36:16 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpm3.myservices.hosting (Postfix) with ESMTP id 78F892106A for <65479@debbugs.gnu.org>; Thu, 24 Aug 2023 00:36:07 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id D68DD80060; Thu, 24 Aug 2023 00:36:06 +0200 (CEST) X-Virus-Scanned: Debian amavisd-new at mail1.netim.hosting Received: from mail1.netim.hosting ([127.0.0.1]) by localhost (mail1-2.netim.hosting [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id DBzkZOMJp4JM; Thu, 24 Aug 2023 00:36:06 +0200 (CEST) Received: from guix-nuc.home.arpa (unknown [10.192.1.83]) (Authenticated sender: lumen@makinata.eu) by mail1.netim.hosting (Postfix) with ESMTPSA id DDB9B80098; Thu, 24 Aug 2023 00:36:05 +0200 (CEST) From: Bruno Victal Date: Wed, 23 Aug 2023 23:34:57 +0100 Message-Id: <74a2b06314c7715c7121a63e398141a19d913295.1692830149.git.mirai@makinata.eu> X-Mailer: git-send-email 2.40.1 In-Reply-To: References: MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org X-getmail-retrieved-from-mailbox: Patches 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]: * 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. --- gnu/packages/docbook.scm | 140 +++++++++++++++++---------------------- 1 file changed, 59 insertions(+), 81 deletions(-) diff --git a/gnu/packages/docbook.scm b/gnu/packages/docbook.scm index 55f99aae62..83a5496a0e 100644 --- a/gnu/packages/docbook.scm +++ b/gnu/packages/docbook.scm @@ -342,93 +342,71 @@ (define-public docbook-xsl (add-before 'install 'generate-catalog.xml (lambda* (#:key make-flags #:allow-other-keys) (apply invoke "make" "-C" "xsl" "catalog.xml" make-flags))) - (add-before 'install 'patch-catalog-xml + (add-after 'generate-catalog.xml 'patch-catalog.xml + ;; Note: URI resolutions are not recursive. + ;; A rewrite rule from: + ;; 'http://docbook.sourceforge.net/release/xsl-ns/' + ;; to + ;; 'http://docbook.sourceforge.net/release/xsl/' + ;; will not trigger the rewrite rule that ultimately + ;; remaps to a /gnu/store URI, as can be seen by + ;; invoking: + ;; $ xmlcatalog "" \ + ;; 'http://docbook.sourceforge.net/release/xsl-ns/current/' + ;; http://docbook.sourceforge.net/release/xsl/current/ + ;; $ xmlcatalog "" \ + ;; 'http://docbook.sourceforge.net/release/xsl/current/' + ;; file://gnu/store/…/xml/xsl/… + ;; + ;; See XML Catalog specification, item 7.2.2. for + ;; details. (lambda* (#:key inputs #:allow-other-keys) (let ((xmlcatalog (search-input-file inputs "/bin/xmlcatalog")) - (catalog-files (find-files "." "catalog\\.xml$")) + (catalog-file "xsl/catalog.xml") (store-uri (string-append "file://" dest-path "/"))) + ;; Remove /snapshot/ references. (for-each - (lambda (catalog) - ;; Replace /snapshot/ reference with one based on - ;; BASE-VERSION. - (let ((versioned-uri - (format - #f "https://cdn.docbook.org/release/xsl/~a/" - #$base-version))) - (invoke xmlcatalog "--noout" - "--del" - "https://cdn.docbook.org/release/xsl/snapshot/" - catalog) - (for-each - (lambda (type) - (invoke xmlcatalog "--noout" - "--add" type - versioned-uri - store-uri - catalog)) - (list "rewriteSystem" "rewriteURI"))) - - ;; Patch /current/ references to point to /gnu/store/…. - (for-each - (lambda (type) - (invoke xmlcatalog "--noout" - "--add" type - "https://cdn.docbook.org/release/xsl/current/" - store-uri - catalog)) - (list "rewriteSystem" "rewriteURI")) - - ;; Re-add the no longer present compatibility entries for - ;; v.1.79.1 or earlier URIs. - (for-each - (lambda (type) - (invoke xmlcatalog "--noout" - "--add" type - "http://docbook.sourceforge.net/release/xsl/current/" - store-uri - catalog)) - (list "rewriteSystem" "rewriteURI")) - - ;; Originally the - ;; "http://docbook.sourceforge.net/release/xsl/" - ;; URI referred to the non-namespaced docbook-xsl, - ;; with its namespaced version using a URI differing in - ;; the path component as '…/xsl-ns/'. - ;; At some point the namespaced version was made the - ;; canonical docbook-xsl package whilst preserving the - ;; original URI. - ;; - ;; For compatibility with XML files that still specify - ;; the legacy namespaced docbook-xsl URIs we re-add them - ;; here. + (lambda (scheme) + (invoke xmlcatalog "--noout" + "--del" + (string-append + scheme + "://cdn.docbook.org/release/xsl/snapshot/") + catalog-file)) + (list "http" "https")) + ;; Rewrite both http:// and https:// URIs. + (for-each + (lambda (path) (for-each - (lambda (type) - ;; Remap /xsl-ns/ to /xsl/. - ;; Note: URI resolutions are not recursive. - ;; A rewrite rule from: - ;; 'http://docbook.sourceforge.net/release/xsl-ns/' - ;; to - ;; 'http://docbook.sourceforge.net/release/xsl/' - ;; will not trigger the rewrite rule that ultimately - ;; remaps to a /gnu/store URI, as can be seen by - ;; invoking: - ;; $ xmlcatalog "" \ - ;; 'http://docbook.sourceforge.net/release/xsl-ns/current/' - ;; http://docbook.sourceforge.net/release/xsl/current/ - ;; $ xmlcatalog "" \ - ;; 'http://docbook.sourceforge.net/release/xsl/current/' - ;; file://gnu/store/…/xml/xsl/… - ;; - ;; See XML Catalog specification, item 7.2.2. for - ;; details. - (invoke xmlcatalog "--noout" - "--add" type - "http://docbook.sourceforge.net/release/xsl-ns/current/" - store-uri - catalog)) - (list "rewriteSystem" "rewriteURI"))) - catalog-files)))) + (lambda (scheme) + (for-each + (lambda (entry-type) + (let ((uri (string-append scheme "://" path))) + (invoke xmlcatalog "--noout" + "--add" entry-type uri store-uri + catalog-file))) + (list "rewriteSystem" "rewriteURI"))) + (list "http" "https"))) + (list #$(format #f "cdn.docbook.org/release/xsl/~a/" + base-version) + "cdn.docbook.org/release/xsl/current/" + ;; Re-add the no longer present compatibility entries for + ;; v.1.79.1 or earlier URIs. + "docbook.sourceforge.net/release/xsl/current/" + ;; Originally the + ;; "http://docbook.sourceforge.net/release/xsl/" + ;; URI referred to the non-namespaced docbook-xsl, + ;; with its namespaced version using a URI differing in + ;; the path component as '…/xsl-ns/'. + ;; At some point the namespaced version was made the + ;; canonical docbook-xsl package whilst preserving the + ;; original URI. + ;; + ;; For compatibility with XML files that still specify + ;; the legacy namespaced docbook-xsl URIs we re-add them + ;; here. + "docbook.sourceforge.net/release/xsl-ns/current/"))))) (replace 'install (lambda _ (let ((select-rx (make-regexp