From patchwork Sat Sep 23 14:19:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Bruno Victal X-Patchwork-Id: 54186 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 48B8127BBEA; Sat, 23 Sep 2023 15:22:56 +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 7465E27BBE9 for ; Sat, 23 Sep 2023 15:22:54 +0100 (BST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qk3W8-0006ur-7a; Sat, 23 Sep 2023 10:21:56 -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 1qk3W4-0006tm-MC for guix-patches@gnu.org; Sat, 23 Sep 2023 10:21:53 -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 1qk3W4-00038D-0K for guix-patches@gnu.org; Sat, 23 Sep 2023 10:21:52 -0400 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1qk3WF-00081m-6O for guix-patches@gnu.org; Sat, 23 Sep 2023 10:22:03 -0400 X-Loop: help-debbugs@gnu.org Subject: [bug#65479] [PATCH core-updates v2 01/62] gnu: docbook-xml: Fix installation paths. Resent-From: Bruno Victal Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Sat, 23 Sep 2023 14:22:03 +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.169547889830619 (code B ref 65479); Sat, 23 Sep 2023 14:22:03 +0000 Received: (at 65479) by debbugs.gnu.org; 23 Sep 2023 14:21:38 +0000 Received: from localhost ([127.0.0.1]:40168 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qk3Vm-0007xY-3g for submit@debbugs.gnu.org; Sat, 23 Sep 2023 10:21:37 -0400 Received: from smtpm5.myservices.hosting ([185.26.105.236]:51134) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1qk3Ve-0007wv-Ru for 65479@debbugs.gnu.org; Sat, 23 Sep 2023 10:21:30 -0400 Received: from mail1.netim.hosting (unknown [185.26.106.173]) by smtpm5.myservices.hosting (Postfix) with ESMTP id C1C0520C9E for <65479@debbugs.gnu.org>; Sat, 23 Sep 2023 16:21:14 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by mail1.netim.hosting (Postfix) with ESMTP id 30FEC80095; Sat, 23 Sep 2023 16:21:11 +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 LFlEr6afpxvU; Sat, 23 Sep 2023 16:21:10 +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 7146880092; Sat, 23 Sep 2023 16:21:10 +0200 (CEST) From: Bruno Victal Date: Sat, 23 Sep 2023 15:19:36 +0100 Message-ID: <41989879ab49bc0fcc437d5f52839a3c57434ccc.1695478390.git.mirai@makinata.eu> X-Mailer: git-send-email 2.41.0 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 Using xml/dtd/docbook as installation path had two problems: * The paths would conflict in profile, which made it impossible for two different docbook-xml packages to coexist within the XML_CATALOG_FILES variable. * It was technically incorrect since non-DTD schemas were also placed here. This commit makes docbook-xml use versioned paths instead. * gnu/packages/docbook.scm (docbook-xml-package, docbook-xml-4.x-package): New procedure. (docbook-xml): Make docbook-xml an alias for docbook-xml-5.1. (docbook-xml-5.1): New variable. (docbook-xml-4.5, docbook-xml-4.4, docbook-xml-4.3, docbook-xml-4.2) (docbook-xml-4.1.2): Refactor to use docbook-xml-4.x-package procedure. --- gnu/packages/docbook.scm | 265 ++++++++++++++++++++++++--------------- 1 file changed, 163 insertions(+), 102 deletions(-) diff --git a/gnu/packages/docbook.scm b/gnu/packages/docbook.scm index 4461293e1e..329d19a05d 100644 --- a/gnu/packages/docbook.scm +++ b/gnu/packages/docbook.scm @@ -50,17 +50,17 @@ (define-module (gnu packages docbook) #:use-module (guix build-system trivial) #:use-module (guix build-system python)) -(define-public docbook-xml +;; The fetch-plan, install-plan and phases for docbook-xml tend to vary +;; between releases therefore we use a “template” package for the +;; transformations that are common to these packages. +(define* (docbook-xml-package source version) + "Return a package for a docbook-xml package version @var{version} and +downloading from @var{source}, where @var{version} is a string and +@var{source} is a @code{} record." (package (name "docbook-xml") - (version "5.1") - (source (origin - (method url-fetch) - (uri (string-append "https://docbook.org/xml/" version - "/docbook-v" version "-os.zip")) - (sha256 - (base32 - "0zqy9prj9wam9dn7v3mgr7ld1axqxdhgrmv06dviwg00ahv43wxk")))) + (version version) + (source source) (build-system copy-build-system) (arguments (list @@ -71,23 +71,27 @@ (define-public docbook-xml #~(modify-phases %standard-phases (add-after 'unpack 'fix-permissions (lambda _ - ;; XXX: These files do not need 0755 permission. + ;; These files do not need 0755 permission. (for-each (cut chmod <> #o644) (find-files ".")))) (add-before 'install 'patch-catalog-xml (lambda* (#:key inputs #:allow-other-keys) (let ((xsltproc (search-input-file inputs "/bin/xsltproc")) - (dtd-path (string-append #$output "/xml/dtd/docbook"))) - (invoke xsltproc "--nonet" "--noout" - "--stringparam" "prefix" dtd-path - "--output" "catalog.xml.new" - #$(local-file - (search-auxiliary-file "xml/patch-catalog-xml.xsl")) - "catalog.xml") - (rename-file "catalog.xml.new" "catalog.xml")))) - (replace 'install - (lambda _ - (let ((dtd-path (string-append #$output "/xml/dtd/docbook"))) - (copy-recursively "." dtd-path))))))) + (xslt-file #$(local-file + (search-auxiliary-file + "xml/patch-catalog-xml.xsl"))) + ;; Avoid profile conflicts by installing to a + ;; versioned path. + (dest-path + (format #f "~a/xml/docbook/~a" #$output #$version))) + (for-each + (lambda (catalog) + (let ((catalog* (string-append catalog ".new"))) + (invoke xsltproc "--nonet" "--novalid" "--noout" + "--stringparam" "prefix" dest-path + "--output" catalog* + xslt-file catalog) + (rename-file catalog* catalog))) + (find-files "." "catalog\\.xml$")))))))) (native-inputs (list libxslt unzip)) (home-page "https://docbook.org") (synopsis "DocBook XML DTDs for document authoring") @@ -97,95 +101,152 @@ (define-public docbook-xml by no means limited to these applications.) This package provides XML DTDs.") (license (license:x11-style "" "See file headers.")))) +(define-public docbook-xml-5.1 + (let* ((version "5.1") + (source (origin + (method url-fetch/zipbomb) + (uri (string-append "https://docbook.org/xml/" version + "/docbook-v" version "-os.zip")) + (sha256 + (base32 + "0zqy9prj9wam9dn7v3mgr7ld1axqxdhgrmv06dviwg00ahv43wxk")))) + (template (docbook-xml-package source version))) + (package + (inherit template) + (arguments + (let ((dest-dir (format #f "xml/docbook/~a/" version))) + (substitute-keyword-arguments (package-arguments template) + ;; XXX: A default value must be provided otherwise this + ;; substitution has no effect. + ((#:install-plan _ #f) + #~`(("schemas/" #$dest-dir))))))))) +;; XXX: docbook-xml-4.x versions use the same #:install-plan but since the +;; paths are versioned we can't use (inherit …). +(define* (docbook-xml-4.x-package source version) + "Return a template for a docbook-xml-4.x package version @var{version} and +downloading from @var{source}, where @var{version} is a string and +@var{source} is a @code{} record." + (let ((base-template (docbook-xml-package source version))) + (package + (inherit base-template) + (arguments + (let* ((dest-dir (format #f "xml/docbook/~a/" version))) + (substitute-keyword-arguments (package-arguments base-template) + ((#:phases phases) + ;; Some programs, such as kdoctools, instead of using + ;; XML_CATALOG_FILES, prefer to use cmake to locate + ;; the DTDs for docbook-xml-4.x packages but + ;; since there's no agreed standard as to where these files + ;; should be placed, in practice the .cmake files + ;; end up searching for paths that are distribution specific. + #~(modify-phases #$phases + (add-after 'install 'symlink-alternate-path + (lambda _ + ;; kdoctools searches under xml/dtd/docbook/ + ;; which is the convention used by Nix. + (mkdir-p (string-append #$output "/xml/dtd")) + (symlink (string-append #$output "/" #$dest-dir) + (string-append #$output "/xml/dtd/docbook")))))) + ((#:install-plan _ #f) + #~`(("./" #$dest-dir + #:exclude-regexp ("ChangeLog$" + "README$" + "docbook\\.cat$" + "\\.txt$")))))))))) + (define-public docbook-xml-4.5 - (package - (inherit docbook-xml) - (version "4.5") - (source (origin - (method url-fetch/zipbomb) - (uri (string-append "https://docbook.org/xml/" version - "/docbook-xml-" version ".zip")) - (sha256 - (base32 - "1d671lcjckjri28xfbf6dq7y3xnkppa910w1jin8rjc35dx06kjf")))))) + (let* ((version "4.5") + (source (origin + (method url-fetch/zipbomb) + (uri (string-append "https://docbook.org/xml/" version + "/docbook-xml-" version ".zip")) + (sha256 + (base32 + "1d671lcjckjri28xfbf6dq7y3xnkppa910w1jin8rjc35dx06kjf"))))) + (docbook-xml-4.x-package source version))) (define-public docbook-xml-4.4 - (package (inherit docbook-xml) - (version "4.4") - (source (origin - (method url-fetch/zipbomb) - (uri (string-append "https://docbook.org/xml/" version - "/docbook-xml-" version ".zip")) - (sha256 - (base32 - "141h4zsyc71sfi2zzd89v4bb4qqq9ca1ri9ix2als9f4i3mmkw82")))))) + (let* ((version "4.4") + (source (origin + (method url-fetch/zipbomb) + (uri (string-append "https://docbook.org/xml/" version + "/docbook-xml-" version ".zip")) + (sha256 + (base32 + "141h4zsyc71sfi2zzd89v4bb4qqq9ca1ri9ix2als9f4i3mmkw82"))))) + (docbook-xml-4.x-package source version))) (define-public docbook-xml-4.3 - (package (inherit docbook-xml) - (version "4.3") - (source (origin - (method url-fetch/zipbomb) - (uri (string-append "https://docbook.org/xml/" version - "/docbook-xml-" version ".zip")) - (sha256 - (base32 - "0r1l2if1z4wm2v664sqdizm4gak6db1kx9y50jq89m3gxaa8l1i3")))))) + (let* ((version "4.3") + (source (origin + (method url-fetch/zipbomb) + (uri (string-append "https://docbook.org/xml/" version + "/docbook-xml-" version ".zip")) + (sha256 + (base32 + "0r1l2if1z4wm2v664sqdizm4gak6db1kx9y50jq89m3gxaa8l1i3"))))) + (docbook-xml-4.x-package source version))) (define-public docbook-xml-4.2 - (package (inherit docbook-xml) - (version "4.2") - (source (origin - (method url-fetch/zipbomb) - (uri (string-append "https://docbook.org/xml/" version - "/docbook-xml-" version ".zip")) - (sha256 - (base32 - "18hgwvmywh6a5jh38szjmg3hg2r4v5lb6r3ydc3rd8cp9wg61i5c")))))) + (let* ((version "4.2") + (source (origin + (method url-fetch/zipbomb) + (uri (string-append "https://docbook.org/xml/" version + "/docbook-xml-" version ".zip")) + (sha256 + (base32 + "18hgwvmywh6a5jh38szjmg3hg2r4v5lb6r3ydc3rd8cp9wg61i5c"))))) + (docbook-xml-4.x-package source version))) (define-public docbook-xml-4.1.2 - (package - (inherit docbook-xml) - (version "4.1.2") - (source (origin - (method url-fetch/zipbomb) - (uri (string-append "https://docbook.org/xml/" version - "/docbkx412.zip")) - (sha256 - (base32 - "0wkp5rvnqj0ghxia0558mnn4c7s3n501j99q2isp3sp0ci069w1h")))) - (arguments - (substitute-keyword-arguments (package-arguments docbook-xml) - ((#:phases phases) - #~(modify-phases #$phases - (add-after 'unpack 'copy-catalog-file - ;; docbook-xml-4.1.2 is unique in the fact that it doesn't come - ;; with a catalog.xml file, requiring it to be generated by hand - ;; from the docbook.cat SGML catalog. We could automatically - ;; generate it here at the cost of enlarging the package - ;; definition with a rudimentary (PEG) parser for the SGML - ;; catalog but this is overkill since this file is unlikely to - ;; change, therefore we ship a pre-generated catalog.xml. - (lambda _ - (copy-file - #$(local-file - (search-auxiliary-file - "xml/docbook-xml/catalog-4.1.2.xml")) - "catalog.xml"))) - (add-after 'patch-catalog-xml 'add-rewrite-entries - (lambda* (#:key inputs #:allow-other-keys) - (let ((xmlcatalog (search-input-file inputs "/bin/xmlcatalog")) - (dtd-path (string-append #$output "/xml/dtd/docbook"))) - (for-each - (lambda (type) - (invoke xmlcatalog "--noout" - "--add" type - "http://www.oasis-open.org/docbook/xml/4.1.2/" - (string-append "file://" dtd-path "/") - "catalog.xml")) - (list "rewriteSystem" "rewriteURI"))))))))) - (native-inputs - (modify-inputs (package-native-inputs docbook-xml) - (prepend libxml2))))) + (let* ((version "4.1.2") + (source (origin + (method url-fetch/zipbomb) + (uri (string-append "https://docbook.org/xml/" version + "/docbkx412.zip")) + (sha256 + (base32 + "0wkp5rvnqj0ghxia0558mnn4c7s3n501j99q2isp3sp0ci069w1h")))) + (template (docbook-xml-4.x-package source version))) + (package + (inherit template) + (arguments + (substitute-keyword-arguments (package-arguments template) + ((#:phases phases) + #~(modify-phases #$phases + (add-after 'unpack 'copy-catalog-file + ;; docbook-xml-4.1.2 is unique in the fact that it doesn't come + ;; with a catalog.xml file, requiring it to be generated by hand + ;; from the docbook.cat SGML catalog. We could automatically + ;; generate it here at the cost of enlarging the package + ;; definition with a rudimentary (PEG) parser for the SGML + ;; catalog but this is overkill since this file is unlikely to + ;; change, therefore we ship a pre-generated catalog.xml. + (lambda _ + (copy-file + #$(local-file + (search-auxiliary-file + "xml/docbook-xml/catalog-4.1.2.xml")) + "catalog.xml"))) + (add-after 'patch-catalog-xml 'add-rewrite-entries + (lambda* (#:key inputs #:allow-other-keys) + (let ((xmlcatalog (search-input-file inputs + "/bin/xmlcatalog")) + (dtd-path (format #f "~a/xml/docbook/~a" + #$output #$version))) + (for-each + (lambda (type) + (invoke xmlcatalog "--noout" + "--add" type + "http://www.oasis-open.org/docbook/xml/4.1.2/" + (string-append "file://" dtd-path "/") + "catalog.xml")) + (list "rewriteSystem" "rewriteURI"))))))))) + (native-inputs + (modify-inputs (package-native-inputs template) + (prepend libxml2)))))) + +(define-public docbook-xml docbook-xml-5.1) ;;; There's an issue in docbook-xsl 1.79.2 that causes manpages to be ;;; generated incorrectly and embed raw nroff syntax such as '.PP' when there