From 6df97c9df599463fb83013aede909c1ae91c47d9 Mon Sep 17 00:00:00 2001 From: rczb Date: Mon, 28 Oct 2024 00:11:43 +0800 Subject: [PATCH] docbook: refactor rng and XML dtd versions --- pkgs/by-name/do/docbook/generic-4.nix | 61 ++++++++++++ pkgs/by-name/do/docbook/generic-5.nix | 50 ++++++++++ pkgs/by-name/do/docbook/package.nix | 95 +++++++++++++++++++ .../sgml+xml/schemas/docbook-5.0/default.nix | 36 ------- .../schemas/xml-dtd/docbook/4.1.2.nix | 22 ----- .../sgml+xml/schemas/xml-dtd/docbook/4.2.nix | 10 -- .../sgml+xml/schemas/xml-dtd/docbook/4.3.nix | 10 -- .../sgml+xml/schemas/xml-dtd/docbook/4.4.nix | 10 -- .../sgml+xml/schemas/xml-dtd/docbook/4.5.nix | 10 -- .../schemas/xml-dtd/docbook/generic.nix | 25 ----- pkgs/top-level/all-packages.nix | 23 +++-- 11 files changed, 223 insertions(+), 129 deletions(-) create mode 100644 pkgs/by-name/do/docbook/generic-4.nix create mode 100644 pkgs/by-name/do/docbook/generic-5.nix create mode 100644 pkgs/by-name/do/docbook/package.nix delete mode 100644 pkgs/data/sgml+xml/schemas/docbook-5.0/default.nix delete mode 100644 pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.1.2.nix delete mode 100644 pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.2.nix delete mode 100644 pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.3.nix delete mode 100644 pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.4.nix delete mode 100644 pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.5.nix delete mode 100644 pkgs/data/sgml+xml/schemas/xml-dtd/docbook/generic.nix diff --git a/pkgs/by-name/do/docbook/generic-4.nix b/pkgs/by-name/do/docbook/generic-4.nix new file mode 100644 index 0000000000000..814fcab10974a --- /dev/null +++ b/pkgs/by-name/do/docbook/generic-4.nix @@ -0,0 +1,61 @@ +{ + version, + url ? null, + hash, + preInstall ? "", +}: + +{ + lib, + stdenvNoCC, + fetchurl, + unzip, + libxml2, +}: + +stdenvNoCC.mkDerivation (finalAttrs: { + pname = "docbook"; + inherit version; + + src = fetchurl { + url = if isNull url then "https://docbook.org/xml/${version}/docbook-xml-${version}.zip" else url; + inherit hash; + }; + + nativeBuildInputs = [ + unzip + libxml2 + ]; + + sourceRoot = "."; + + inherit preInstall; + + installPhase = '' + runHook preInstall + dst=$out/xml/dtd/docbook + mkdir -p $dst + + cp -prv * $dst/ + substituteInPlace $dst/catalog.xml --replace 'uri="' "uri=\"$dst/" + + runHook postInstall + ''; + + meta = { + description = "General purpose XML and SGML document type"; + longDescription = '' + DocBook is general purpose XML and SGML document type particularly well + suited to books and papers about computer hardware and software (though it + is by no means limited to these applications). + + The OASIS DocBook Technical Committee maintains the DocBook schema. + DocBook is officially available as a Document Type Definition (DTD) for + both XML and SGML. It is unofficially available in other forms as well. + ''; + homepage = "https://docbook.org/"; + license = "DocBook-Schema"; + maintainers = with lib.maintainers; [ rc-zb ]; + platforms = lib.platforms.all; + }; +}) diff --git a/pkgs/by-name/do/docbook/generic-5.nix b/pkgs/by-name/do/docbook/generic-5.nix new file mode 100644 index 0000000000000..0db88c9c5a565 --- /dev/null +++ b/pkgs/by-name/do/docbook/generic-5.nix @@ -0,0 +1,50 @@ +{ + version, + url ? null, + hash, + installPhase, +}: + +{ + lib, + stdenvNoCC, + fetchurl, + unzip, +}: + +stdenvNoCC.mkDerivation (finalAttrs: { + pname = "docbook"; + inherit version; + + src = fetchurl { + url = + if isNull url then + "https://docs.oasis-open.org/docbook/docbook/v${version}/os/docbook-v${version}-os.zip" + else + url; + inherit hash; + }; + + nativeBuildInputs = [ unzip ]; + + sourceRoot = "."; + + inherit installPhase; + + meta = { + description = "General purpose XML schema"; + longDescription = '' + DocBook is general purpose XML schema particularly well suited to books and + papers about computer hardware and software (though it is by no means + limited to these applications). + + The OASIS DocBook Technical Committee maintains the DocBook schema. + Starting with V5.0, DocBook is normatively available as a RELAX NG Schema + (with some additional Schematron assertions). + ''; + homepage = "https://docbook.org/"; + license = "DocBook-Schema"; + maintainers = with lib.maintainers; [ rc-zb ]; + platforms = lib.platforms.all; + }; +}) diff --git a/pkgs/by-name/do/docbook/package.nix b/pkgs/by-name/do/docbook/package.nix new file mode 100644 index 0000000000000..156a8a6582b27 --- /dev/null +++ b/pkgs/by-name/do/docbook/package.nix @@ -0,0 +1,95 @@ +{ + callPackage, + fetchurl, + libxml2, +}: +let + makeDocBookVersions = + major: + builtins.mapAttrs (name: spec: callPackage (import (./. + "/generic-${major}.nix") spec) { }); +in +(makeDocBookVersions "5" { + docbook_5_2 = { + version = "5.2"; + hash = "sha256-grMb+6HEo18TiZWr1Ofko9yf4XIX3vlSeXm/QsFpiWI="; + installPhase = '' + runHook preInstall + dst=$out/share/xml/docbook-5.2 + mkdir -p $dst + + cp -prv * $dst/ + substituteInPlace $dst/catalog.xml --replace 'uri="' "uri=\"$dst/" + + rm -rf $dst/*.{docx,html,pdf} $dst/release-notes + runHook postInstall + ''; + }; + docbook_5_1 = { + version = "5.1"; + hash = "sha256-s/NBNlQAPB53M2DX/GDruKvQ6Mmvjn1sS1XxJPNNHn8="; + installPhase = '' + runHook preInstall + dst=$out/share/xml/docbook-5.1 + mkdir -p $dst + + cp -prv schemas/* $dst/ + substituteInPlace $dst/catalog.xml --replace 'uri="' "uri=\"$dst/" + runHook postInstall + ''; + }; + docbook_5_0 = rec { + version = "5.0.1"; + url = "https://docbook.org/xml/${version}/docbook-${version}.zip"; + hash = "sha256-evnfRSQQ4DWjcHiD5DA5tAYvCdwvSfLphto+TAOG48c="; + installPhase = '' + runHook preInstall + dst=$out/share/xml/docbook-5.0 + mkdir -p $dst + + # The dir must be specified manually, because sourceRoot is set to ".". + cp -prv docbook-${version}/* $dst/ + substituteInPlace $dst/catalog.xml --replace 'uri="' "uri=\"$dst/" + + rm -rf $dst/docs $dst/ChangeLog + + # Backwards compatibility. Will remove eventually. + mkdir -p $out/xml/rng $out/xml/dtd + ln -s $dst/rng $out/xml/rng/docbook + ln -s $dst/dtd $out/xml/dtd/docbook + runHook postInstall + ''; + }; +}) +// (makeDocBookVersions "4" { + docbook_4_5 = { + version = "4.5"; + hash = "sha256-Tk4DeiuDyYxslIGDkNS90/bhD27GLdeRiFlOJhkNx7Q="; + }; + docbook_4_4 = { + version = "4.4"; + hash = "sha256-AvFZ64jEJU2V6DHFHBRLGGOyFtkJtf9FdDoc5vUnMJA="; + }; + docbook_4_3 = { + version = "4.3"; + hash = "sha256-IwaKlOpv1ISwBMWnPsNqZqpH6o8Na2LMFpWTH1wUNGQ="; + }; + docbook_4_2 = { + version = "4.2"; + hash = "sha256-rMRgHk+XoZYHa35ks2jZJIsHx6vyazSgLMpA7uvmD6I="; + }; + docbook_4_1_2 = { + version = "4.1.2"; + url = "https://docbook.org/xml/4.1.2/docbkx412.zip"; + hash = "sha256-MPBkQGTg6nF1FDglGUCxQx9GrK2oFKBihw9IbHcud3I="; + preInstall = + let + docbook42catalog = fetchurl { + url = "https://docbook.org/xml/4.2/catalog.xml"; + sha256 = "sha256-J0g0JhEzZpuYlm0qU+lKmLc1oUbD5FKQHuUAKrC5kKI="; + }; + in + '' + sed 's|V4.2|V4.1.2|g' < ${docbook42catalog} > catalog.xml + ''; + }; +}) diff --git a/pkgs/data/sgml+xml/schemas/docbook-5.0/default.nix b/pkgs/data/sgml+xml/schemas/docbook-5.0/default.nix deleted file mode 100644 index 89439f0b8e082..0000000000000 --- a/pkgs/data/sgml+xml/schemas/docbook-5.0/default.nix +++ /dev/null @@ -1,36 +0,0 @@ -{ lib, stdenv, fetchurl, unzip }: - -stdenv.mkDerivation rec { - pname = "docbook5"; - version = "5.0.1"; - - src = fetchurl { - url = "http://www.docbook.org/xml/${version}/docbook-${version}.zip"; - sha256 = "1iz3hq1lqgnshvlz4j9gvh4jy1ml74qf90vqf2ikbq0h4i2xzybs"; - }; - - nativeBuildInputs = [ unzip ]; - - installPhase = - '' - dst=$out/share/xml/docbook-5.0 - mkdir -p $dst - cp -prv * $dst/ - - substituteInPlace $dst/catalog.xml --replace 'uri="' "uri=\"$dst/" - - rm -rf $dst/docs $dst/ChangeLog - - # Backwards compatibility. Will remove eventually. - mkdir -p $out/xml/rng $out/xml/dtd - ln -s $dst/rng $out/xml/rng/docbook - ln -s $dst/dtd $out/xml/dtd/docbook - ''; - - meta = { - description = "Schemas for DocBook 5.0, a semantic markup language for technical documentation"; - homepage = "https://docbook.org/xml/5.0/"; - maintainers = [ ]; - platforms = lib.platforms.all; - }; -} diff --git a/pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.1.2.nix b/pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.1.2.nix deleted file mode 100644 index c367e2a1d0cdf..0000000000000 --- a/pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.1.2.nix +++ /dev/null @@ -1,22 +0,0 @@ -{lib, stdenv, fetchurl, unzip, findXMLCatalogs}: - -let - # Urgh, DocBook 4.1.2 doesn't come with an XML catalog. Use the one - # from 4.2. - docbook42catalog = fetchurl { - url = "https://docbook.org/xml/4.2/catalog.xml"; - sha256 = "18lhp6q2l0753s855r638shkbdwq9blm6akdjsc9nrik24k38j17"; - }; -in - -import ./generic.nix { - inherit lib stdenv unzip findXMLCatalogs; - version = "4.1.2"; - src = fetchurl { - url = "https://docbook.org/xml/4.1.2/docbkx412.zip"; - sha256 = "0wkp5rvnqj0ghxia0558mnn4c7s3n501j99q2isp3sp0ci069w1h"; - }; - postInstall = " - sed 's|V4.2|V4.1.2|g' < ${docbook42catalog} > catalog.xml - "; -} diff --git a/pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.2.nix b/pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.2.nix deleted file mode 100644 index 8f778ea7505d9..0000000000000 --- a/pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.2.nix +++ /dev/null @@ -1,10 +0,0 @@ -{lib, stdenv, fetchurl, unzip, findXMLCatalogs}: - -import ./generic.nix { - inherit lib stdenv unzip findXMLCatalogs; - version = "4.2"; - src = fetchurl { - url = "https://docbook.org/xml/4.2/docbook-xml-4.2.zip"; - sha256 = "acc4601e4f97a196076b7e64b368d9248b07c7abf26b34a02cca40eeebe60fa2"; - }; -} diff --git a/pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.3.nix b/pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.3.nix deleted file mode 100644 index a58370ec4ac66..0000000000000 --- a/pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.3.nix +++ /dev/null @@ -1,10 +0,0 @@ -{lib, stdenv, fetchurl, unzip, findXMLCatalogs}: - -import ./generic.nix { - inherit lib stdenv unzip findXMLCatalogs; - version = "4.3"; - src = fetchurl { - url = "https://docbook.org/xml/4.3/docbook-xml-4.3.zip"; - sha256 = "0r1l2if1z4wm2v664sqdizm4gak6db1kx9y50jq89m3gxaa8l1i3"; - }; -} diff --git a/pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.4.nix b/pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.4.nix deleted file mode 100644 index 3b46fe81bd7a8..0000000000000 --- a/pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.4.nix +++ /dev/null @@ -1,10 +0,0 @@ -{lib, stdenv, fetchurl, unzip, findXMLCatalogs}: - -import ./generic.nix { - inherit lib stdenv unzip findXMLCatalogs; - version = "4.4"; - src = fetchurl { - url = "https://docbook.org/xml/4.4/docbook-xml-4.4.zip"; - sha256 = "141h4zsyc71sfi2zzd89v4bb4qqq9ca1ri9ix2als9f4i3mmkw82"; - }; -} diff --git a/pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.5.nix b/pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.5.nix deleted file mode 100644 index c4ab1f6f3a9bd..0000000000000 --- a/pkgs/data/sgml+xml/schemas/xml-dtd/docbook/4.5.nix +++ /dev/null @@ -1,10 +0,0 @@ -{lib, stdenv, fetchurl, unzip, findXMLCatalogs}: - -import ./generic.nix { - inherit lib stdenv unzip findXMLCatalogs; - version = "4.5"; - src = fetchurl { - url = "https://docbook.org/xml/4.5/docbook-xml-4.5.zip"; - sha256 = "1d671lcjckjri28xfbf6dq7y3xnkppa910w1jin8rjc35dx06kjf"; - }; -} diff --git a/pkgs/data/sgml+xml/schemas/xml-dtd/docbook/generic.nix b/pkgs/data/sgml+xml/schemas/xml-dtd/docbook/generic.nix deleted file mode 100644 index 7a635f612af8f..0000000000000 --- a/pkgs/data/sgml+xml/schemas/xml-dtd/docbook/generic.nix +++ /dev/null @@ -1,25 +0,0 @@ -{ lib, stdenv, unzip, src, version, postInstall ? "true", findXMLCatalogs }: - -stdenv.mkDerivation { - inherit version src postInstall; - pname = "docbook-xml"; - - nativeBuildInputs = [ unzip ]; - propagatedNativeBuildInputs = [ findXMLCatalogs ]; - - unpackPhase = '' - mkdir -p $out/xml/dtd/docbook - cd $out/xml/dtd/docbook - unpackFile $src - ''; - - installPhase = '' - find . -type f -exec chmod -x {} \; - runHook postInstall - ''; - - meta = { - branch = version; - platforms = lib.platforms.unix; - }; -} diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 485a085938f23..5ee0f30e89cac 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -26780,21 +26780,32 @@ with pkgs; dm-sans = callPackage ../data/fonts/dm-sans { }; dns-root-data = callPackage ../data/misc/dns-root-data { }; - docbook5 = callPackage ../data/sgml+xml/schemas/docbook-5.0 { }; + # TODO: refactor DocBook versions into ../by-name/do/docbook/ + inherit (callPackage ../by-name/do/docbook/package.nix {}) + docbook_5_2 + docbook_5_1 + docbook_5_0 + docbook_4_5 + docbook_4_4 + docbook_4_3 + docbook_4_2 + docbook_4_1_2; + + docbook5 = docbook_5_0; docbook_sgml_dtd_31 = callPackage ../data/sgml+xml/schemas/sgml-dtd/docbook/3.1.nix { }; docbook_sgml_dtd_41 = callPackage ../data/sgml+xml/schemas/sgml-dtd/docbook/4.1.nix { }; - docbook_xml_dtd_412 = callPackage ../data/sgml+xml/schemas/xml-dtd/docbook/4.1.2.nix { }; + docbook_xml_dtd_412 = docbook_4_1_2; - docbook_xml_dtd_42 = callPackage ../data/sgml+xml/schemas/xml-dtd/docbook/4.2.nix { }; + docbook_xml_dtd_42 = docbook_4_2; - docbook_xml_dtd_43 = callPackage ../data/sgml+xml/schemas/xml-dtd/docbook/4.3.nix { }; + docbook_xml_dtd_43 = docbook_4_3; - docbook_xml_dtd_44 = callPackage ../data/sgml+xml/schemas/xml-dtd/docbook/4.4.nix { }; + docbook_xml_dtd_44 = docbook_4_4; - docbook_xml_dtd_45 = callPackage ../data/sgml+xml/schemas/xml-dtd/docbook/4.5.nix { }; + docbook_xml_dtd_45 = docbook_4_5; docbook_xml_ebnf_dtd = callPackage ../data/sgml+xml/schemas/xml-dtd/docbook-ebnf { };