Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 stdenv, 3 lib, 4 fetchurl, 5 docbook_xsl, 6 docbook_xsl_ns, 7 gettext, 8 libxslt, 9 glibcLocales, 10 docbook_xml_dtd_45, 11 docbook_sgml_dtd_41, 12 opensp, 13 bash, 14 fetchpatch, 15 perl, 16 buildPerlPackage, 17 ModuleBuild, 18 TextWrapI18N, 19 LocaleGettext, 20 SGMLSpm, 21 UnicodeLineBreak, 22 PodParser, 23 YAMLTiny, 24 SyntaxKeywordTry, 25 writeShellScriptBin, 26}: 27 28buildPerlPackage rec { 29 pname = "po4a"; 30 version = "0.73"; 31 32 src = fetchurl { 33 url = "https://github.com/mquinson/po4a/releases/download/v${version}/po4a-${version}.tar.gz"; 34 hash = "sha256-bxj4LYyyo3c5QTfqOWzD6BldbNbkVP4CGKoPDjYDjqA="; 35 }; 36 37 strictDeps = true; 38 39 nativeBuildInputs = 40 # the tests for the tex-format use kpsewhich -- texlive's file finding utility. 41 # We don't want to depend on texlive here, so we replace it with a minimal 42 # shellscript that suffices for the tests in t/fmt/tex/, i.e. it looks up 43 # article.cls to an existing file, but doesn't find article-wrong.cls. 44 let 45 kpsewhich-stub = writeShellScriptBin "kpsewhich" ''[[ $1 = "article.cls" ]] && echo /dev/null''; 46 in 47 [ 48 gettext 49 libxslt 50 docbook_xsl 51 docbook_xsl_ns 52 ModuleBuild 53 docbook_xml_dtd_45 54 docbook_sgml_dtd_41 55 opensp 56 kpsewhich-stub 57 glibcLocales 58 ]; 59 patches = [ 60 # Needs a patch for 5.40 until the next release 61 (fetchpatch { 62 url = "https://github.com/mquinson/po4a/commit/28fe52651eb8096d97d6bd3a97b3168522ba5306.patch"; 63 hash = "sha256-QUXxkSzcnwRvU+2y2KoBXmtfE8qTZ2BV0StkJHqZehQ="; 64 }) 65 (fetchpatch { 66 name = "gettext-0.25.patch"; 67 url = "https://github.com/mquinson/po4a/commit/7d88a5e59606a9a29ffe73325fff4a5ddb865d5c.patch"; 68 hash = "sha256-5x+EX++v7DxOHOZgRM2tv5eNN1Gy28f+qaqH27emZhk="; 69 }) 70 ]; 71 72 # TODO: TermReadKey was temporarily removed from propagatedBuildInputs to unfreeze the build 73 propagatedBuildInputs = 74 lib.optionals (!stdenv.hostPlatform.isMusl) [ 75 TextWrapI18N 76 ] 77 ++ [ 78 LocaleGettext 79 SGMLSpm 80 UnicodeLineBreak 81 PodParser 82 YAMLTiny 83 SyntaxKeywordTry 84 ]; 85 86 buildInputs = [ bash ]; 87 88 LC_ALL = "en_US.UTF-8"; 89 SGML_CATALOG_FILES = "${docbook_xml_dtd_45}/xml/dtd/docbook/catalog.xml"; 90 91 preConfigure = '' 92 touch Makefile.PL 93 export PERL_MB_OPT="--install_base=$out --prefix=$out" 94 ''; 95 96 buildPhase = '' 97 perl Build.PL --install_base=$out --install_path="lib=$out/${perl.libPrefix}" 98 ./Build build 99 ''; 100 101 # Disabling tests on musl 102 # Void linux package have investigated the failure and tracked it down to differences in gettext behavior. They decided to disable tests. 103 # https://github.com/void-linux/void-packages/pull/34029#issuecomment-973267880 104 # Alpine packagers have not worried about running the tests until now: 105 # https://git.alpinelinux.org/aports/tree/main/po4a/APKBUILD#n11 106 # 107 # Disabling tests on Darwin until https://github.com/NixOS/nixpkgs/issues/236560 is resolved. 108 doCheck = (!stdenv.hostPlatform.isMusl) && (!stdenv.hostPlatform.isDarwin); 109 110 checkPhase = '' 111 export SGML_CATALOG_FILES=${docbook_sgml_dtd_41}/sgml/dtd/docbook-4.1/docbook.cat 112 ./Build test 113 ''; 114 115 installPhase = '' 116 ./Build install 117 for f in $out/bin/*; do 118 substituteInPlace $f --replace "#! /usr/bin/env perl" "#!${perl}/bin/perl" 119 substituteInPlace $f --replace "exec perl" "exec ${perl}/bin/perl" 120 done 121 ''; 122 123 meta = { 124 description = "Tools for helping translation of documentation"; 125 homepage = "https://po4a.org"; 126 license = with lib.licenses; [ gpl2Plus ]; 127 }; 128}