Merge pull request #179254 from dotlambda/asciidoc-10.2.0

This commit is contained in:
Sandro 2022-06-30 15:51:19 +02:00 committed by GitHub
commit dcbdbb9800
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 83 additions and 119 deletions

View file

@ -48,6 +48,17 @@ stdenv.mkDerivation rec {
url = "https://github.com/libjxl/libjxl/commit/204f87a5e4d684544b13900109abf040dc0b402b.patch"; url = "https://github.com/libjxl/libjxl/commit/204f87a5e4d684544b13900109abf040dc0b402b.patch";
sha256 = "sha256-DoAaYWLmQ+R9GZbHMTYGe0gBL9ZesgtB+2WhmbARna8="; sha256 = "sha256-DoAaYWLmQ+R9GZbHMTYGe0gBL9ZesgtB+2WhmbARna8=";
}) })
# fix build with asciidoc wrapped in shell script
(fetchpatch {
url = "https://github.com/libjxl/libjxl/commit/b8ec58c58c6281987f42ebec892f513824c0cc0e.patch";
hash = "sha256-g8U+YVhLfgSHJ+PWJgvVOI66+FElJSC8IgSRodNnsMw=";
})
(fetchpatch {
url = "https://github.com/libjxl/libjxl/commit/ca8e276aacf63a752346a6a44ba673b0af993237.patch";
excludes = [ "AUTHORS" ];
hash = "sha256-9VXy1LdJ0JhYbCGPNMySpnGLBxUrr8BYzE+oU3LnUGw=";
})
]; ];
nativeBuildInputs = [ nativeBuildInputs = [

View file

@ -1,39 +1,39 @@
{ fetchurl, lib, stdenv, python3 { fetchurl, lib, stdenv, python3
, fetchFromGitHub, autoreconfHook , fetchFromGitHub, autoreconfHook
, installShellFiles
, enableStandardFeatures ? false , enableStandardFeatures ? false
, sourceHighlight ? null , sourceHighlight
, highlight ? null , highlight
, pygments ? null , pygments
, graphviz ? null , graphviz
, texlive ? null , texlive
, dblatexFull ? null , dblatexFull
, libxslt ? null , libxslt
, w3m ? null , w3m
, lynx ? null , lynx
, imagemagick ? null , imagemagick
, lilypond ? null , lilypond
, libxml2 ? null , libxml2
, docbook_xml_dtd_45 ? null , docbook_xml_dtd_45
, docbook_xsl_ns ? null , docbook_xsl_ns
, docbook_xsl ? null , docbook_xsl
, fop ? null , fop
# TODO: Package this: , epubcheck
#, epubcheck ? null , gnused
, gnused ? null , coreutils
, coreutils ? null
# if true, enable all the below filters and backends # if true, enable all the below filters and backends
, enableExtraPlugins ? false , enableExtraPlugins ? false
# unzip is needed to extract filter and backend plugins # unzip is needed to extract filter and backend plugins
, unzip ? null , unzip
# filters # filters
, enableDitaaFilter ? false, jre ? null , enableDitaaFilter ? false, jre
, enableMscgenFilter ? false, mscgen ? null , enableMscgenFilter ? false, mscgen
, enableDiagFilter ? false, blockdiag ? null, seqdiag ? null, actdiag ? null, nwdiag ? null , enableDiagFilter ? false, blockdiag, seqdiag, actdiag, nwdiag
, enableQrcodeFilter ? false, qrencode ? null , enableQrcodeFilter ? false, qrencode
, enableMatplotlibFilter ? false, matplotlib ? null, numpy ? null , enableMatplotlibFilter ? false, matplotlib, numpy
, enableAafigureFilter ? false, aafigure ? null, recursivePthLoader ? null , enableAafigureFilter ? false, aafigure, recursivePthLoader
# backends # backends
, enableDeckjsBackend ? false , enableDeckjsBackend ? false
, enableOdfBackend ? false , enableOdfBackend ? false
@ -44,38 +44,6 @@
, buildPackages , buildPackages
}: }:
assert enableStandardFeatures ->
sourceHighlight != null &&
highlight != null &&
pygments != null &&
graphviz != null &&
texlive != null &&
dblatexFull != null &&
libxslt != null &&
w3m != null &&
lynx != null &&
imagemagick != null &&
lilypond != null &&
libxml2 != null &&
docbook_xml_dtd_45 != null &&
docbook_xsl_ns != null &&
docbook_xsl != null &&
(fop != null || !enableJava) &&
# TODO: Package this:
# epubcheck != null &&
gnused != null &&
coreutils != null;
# filters
assert enableExtraPlugins || enableDitaaFilter || enableMscgenFilter || enableDiagFilter || enableQrcodeFilter || enableAafigureFilter -> unzip != null;
assert (enableExtraPlugins && enableJava) || enableDitaaFilter -> jre != null;
assert enableExtraPlugins || enableMscgenFilter -> mscgen != null;
assert enableExtraPlugins || enableDiagFilter -> blockdiag != null && seqdiag != null && actdiag != null && nwdiag != null;
assert enableExtraPlugins || enableMatplotlibFilter -> matplotlib != null && numpy != null;
assert enableExtraPlugins || enableAafigureFilter -> aafigure != null && recursivePthLoader != null;
# backends
assert enableExtraPlugins || enableDeckjsBackend || enableOdfBackend -> unzip != null;
let let
_enableDitaaFilter = (enableExtraPlugins && enableJava) || enableDitaaFilter; _enableDitaaFilter = (enableExtraPlugins && enableJava) || enableDitaaFilter;
@ -144,26 +112,24 @@ let
sha256 = "08ya4bskygzqkfqwjllpg31qc5k08xp2k78z9b2480g8y57bfy10"; sha256 = "08ya4bskygzqkfqwjllpg31qc5k08xp2k78z9b2480g8y57bfy10";
}; };
in in python3.pkgs.buildPythonApplication rec {
stdenv.mkDerivation rec {
pname = "asciidoc" pname = "asciidoc"
+ lib.optionalString enableStandardFeatures "-full" + lib.optionalString enableStandardFeatures "-full"
+ lib.optionalString enableExtraPlugins "-with-plugins"; + lib.optionalString enableExtraPlugins "-with-plugins";
version = "9.1.0"; version = "10.2.0";
# Note: a substitution to improve reproducibility should be updated once 10.0.0 is
# released. See the comment in `patchPhase` for more information.
src = fetchFromGitHub { src = fetchFromGitHub {
owner = "asciidoc"; owner = "asciidoc-py";
repo = "asciidoc-py3"; repo = "asciidoc-py";
rev = version; rev = version;
sha256 = "1clf1axkns23wfmh48xfspzsnw04pjh4mq1pshpzvj0cwxhz0yaq"; hash = "sha256-TqC0x9xB6e2d6Wc9bgnlqgZVOmYHmUUKfE/CKAiEtag=";
}; };
strictDeps = true; nativeBuildInputs = [
nativeBuildInputs = [ python3 unzip autoreconfHook ]; autoreconfHook
buildInputs = [ python3 ]; installShellFiles
unzip
];
# install filters early, so their shebangs are patched too # install filters early, so their shebangs are patched too
postPatch = with lib; '' postPatch = with lib; ''
@ -230,22 +196,22 @@ stdenv.mkDerivation rec {
-e "s|twopi|${graphviz}/bin/twopi|g" \ -e "s|twopi|${graphviz}/bin/twopi|g" \
-e "s|circo|${graphviz}/bin/circo|g" \ -e "s|circo|${graphviz}/bin/circo|g" \
-e "s|fdp|${graphviz}/bin/fdp|g" \ -e "s|fdp|${graphviz}/bin/fdp|g" \
-i "filters/graphviz/graphviz2png.py" -i "asciidoc/resources/filters/graphviz/graphviz2png.py"
sed -e "s|run('latex|run('${texlive}/bin/latex|g" \ sed -e "s|run('latex|run('${texlive}/bin/latex|g" \
-e "s|cmd = 'dvipng'|cmd = '${texlive}/bin/dvipng'|g" \ -e "s|cmd = 'dvipng'|cmd = '${texlive}/bin/dvipng'|g" \
-e "s|cmd = 'dvisvgm'|cmd = '${texlive}/bin/dvisvgm'|g" \ -e "s|cmd = 'dvisvgm'|cmd = '${texlive}/bin/dvisvgm'|g" \
-i "filters/latex/latex2img.py" -i "asciidoc/resources/filters/latex/latex2img.py"
sed -e "s|run('abc2ly|run('${lilypond}/bin/abc2ly|g" \ sed -e "s|run('abc2ly|run('${lilypond}/bin/abc2ly|g" \
-e "s|run('lilypond|run('${lilypond}/bin/lilypond|g" \ -e "s|run('lilypond|run('${lilypond}/bin/lilypond|g" \
-e "s|run('convert|run('${imagemagick.out}/bin/convert|g" \ -e "s|run('convert|run('${imagemagick.out}/bin/convert|g" \
-i "filters/music/music2png.py" -i "asciidoc/resources/filters/music/music2png.py"
sed -e 's|filter="source-highlight|filter="${sourceHighlight}/bin/source-highlight|' \ sed -e 's|filter="source-highlight|filter="${sourceHighlight}/bin/source-highlight|' \
-e 's|filter="highlight|filter="${highlight}/bin/highlight|' \ -e 's|filter="highlight|filter="${highlight}/bin/highlight|' \
-e 's|filter="pygmentize|filter="${pygments}/bin/pygmentize|' \ -e 's|filter="pygmentize|filter="${pygments}/bin/pygmentize|' \
-i "filters/source/source-highlight-filter.conf" -i "asciidoc/resources/filters/source/source-highlight-filter.conf"
# ENV is custom environment passed to programs that a2x invokes. Here we # ENV is custom environment passed to programs that a2x invokes. Here we
# use it to work around an impurity in the tetex package; tetex tools # use it to work around an impurity in the tetex package; tetex tools
@ -260,55 +226,45 @@ stdenv.mkDerivation rec {
-e "s|^W3M =.*|W3M = '${w3m}/bin/w3m'|" \ -e "s|^W3M =.*|W3M = '${w3m}/bin/w3m'|" \
-e "s|^LYNX =.*|LYNX = '${lynx}/bin/lynx'|" \ -e "s|^LYNX =.*|LYNX = '${lynx}/bin/lynx'|" \
-e "s|^XMLLINT =.*|XMLLINT = '${libxml2.bin}/bin/xmllint'|" \ -e "s|^XMLLINT =.*|XMLLINT = '${libxml2.bin}/bin/xmllint'|" \
-e "s|^EPUBCHECK =.*|EPUBCHECK = 'nixpkgs_is_missing_epubcheck'|" \ -e "s|^EPUBCHECK =.*|EPUBCHECK = '${epubcheck}/bin/epubcheck'|" \
-i a2x.py -i asciidoc/a2x.py
'' else '' '' else ''
sed -e "s|^ENV =.*|ENV = dict(XML_CATALOG_FILES='${docbook_xml_dtd_45}/xml/dtd/docbook/catalog.xml ${docbook_xsl_ns}/xml/xsl/docbook/catalog.xml ${docbook_xsl}/xml/xsl/docbook/catalog.xml')|" \ sed -e "s|^ENV =.*|ENV = dict(XML_CATALOG_FILES='${docbook_xml_dtd_45}/xml/dtd/docbook/catalog.xml ${docbook_xsl_ns}/xml/xsl/docbook/catalog.xml ${docbook_xsl}/xml/xsl/docbook/catalog.xml')|" \
-e "s|^XSLTPROC =.*|XSLTPROC = '${libxslt.bin}/bin/xsltproc'|" \ -e "s|^XSLTPROC =.*|XSLTPROC = '${libxslt.bin}/bin/xsltproc'|" \
-e "s|^XMLLINT =.*|XMLLINT = '${libxml2.bin}/bin/xmllint'|" \ -e "s|^XMLLINT =.*|XMLLINT = '${libxml2.bin}/bin/xmllint'|" \
-i a2x.py -i asciidoc/a2x.py
'') + '' '') + ''
patchShebangs --host \
asciidoc.py \
a2x.py \
tests/testasciidoc.py \
filters/code/code-filter.py \
filters/latex/latex2img.py \
filters/music/music2png.py \
filters/unwraplatex.py \
filters/graphviz/graphviz2png.py
# Hardcode the path to its own asciidoc.
# This helps with cross-compilation.
substituteInPlace a2x.py \
--replace "find_executable(ASCIIDOC)" "'${placeholder "out"}/bin/asciidoc'"
# Note: this substitution will not work in the planned 10.0.0 release:
#
# https://github.com/asciidoc/asciidoc-py3/commit/dfffda23381014481cd13e8e9d8f131e1f93f08a
#
# Update this substitution to:
#
# --replace "python3 -m asciidoc.a2x" "python3 -m asciidoc.a2x -a revdate=01/01/1980"
substituteInPlace Makefile.in \
--replace "python3 a2x.py" "python3 a2x.py -a revdate=01/01/1980"
# Fix tests # Fix tests
for f in $(grep -R --files-with-matches "2002-11-25") ; do for f in $(grep -R --files-with-matches "2002-11-25") ; do
substituteInPlace $f --replace "2002-11-25" "1970-01-01" substituteInPlace $f --replace "2002-11-25" "1980-01-02"
substituteInPlace $f --replace "00:37:42" "00:00:01" substituteInPlace $f --replace "00:37:42" "00:00:00"
done done
'' + lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) '' '' + lib.optionalString (stdenv.buildPlatform != stdenv.hostPlatform) ''
# We want to use asciidoc from the build platform to build the documentation. # We want to use asciidoc from the build platform to build the documentation.
substituteInPlace Makefile.in \ substituteInPlace Makefile.in \
--replace "python3 a2x.py" "python3 ${buildPackages.asciidoc}/bin/a2x.py" --replace "python3 -m asciidoc.a2x" "${buildPackages.asciidoc}/bin/a2x"
''; '';
preInstall = "mkdir -p $out/etc/vim"; postBuild = ''
makeFlags = lib.optional stdenv.isCygwin "DESTDIR=/."; make manpages
'';
checkInputs = [ sourceHighlight ]; postInstall = ''
doCheck = true; installManPage doc/asciidoc.1 doc/a2x.1 doc/testasciidoc.1
'';
checkInputs = with python3.pkgs; [
pytest
pytest-mock
];
checkPhase = ''
runHook preCheck
make test
runHook postCheck
'';
meta = with lib; { meta = with lib; {
description = "Text-based document generation system"; description = "Text-based document generation system";
@ -325,9 +281,10 @@ stdenv.mkDerivation rec {
sourceProvenance = with sourceTypes; [ sourceProvenance = with sourceTypes; [
fromSource fromSource
] ++ lib.optional _enableDitaaFilter binaryBytecode; ] ++ lib.optional _enableDitaaFilter binaryBytecode;
homepage = "http://www.methods.co.nz/asciidoc/"; homepage = "https://asciidoc-py.github.io/";
changelog = "https://github.com/asciidoc-py/asciidoc-py/blob/${src.rev}/CHANGELOG.adoc";
license = licenses.gpl2Plus; license = licenses.gpl2Plus;
platforms = platforms.unix; platforms = platforms.unix;
maintainers = [ maintainers.bjornfor ]; maintainers = with maintainers; [ bjornfor dotlambda ];
}; };
} }

View file

@ -4572,21 +4572,17 @@ with pkgs;
arpoison = callPackage ../tools/networking/arpoison { }; arpoison = callPackage ../tools/networking/arpoison { };
asciidoc = callPackage ../tools/typesetting/asciidoc { asciidoc = callPackage ../tools/typesetting/asciidoc {
inherit (python3.pkgs) matplotlib numpy aafigure recursivePthLoader; inherit (python3.pkgs) pygments matplotlib numpy aafigure recursivePthLoader;
texlive = texlive.combine { inherit (texlive) scheme-minimal dvipng; };
w3m = w3m-batch;
enableStandardFeatures = false; enableStandardFeatures = false;
}; };
asciidoc-full = asciidoc.override { asciidoc-full = asciidoc.override {
inherit (python3.pkgs) pygments;
texlive = texlive.combine { inherit (texlive) scheme-minimal dvipng; };
w3m = w3m-batch;
enableStandardFeatures = true; enableStandardFeatures = true;
}; };
asciidoc-full-with-plugins = asciidoc.override { asciidoc-full-with-plugins = asciidoc.override {
inherit (python3.pkgs) pygments;
texlive = texlive.combine { inherit (texlive) scheme-minimal dvipng; };
w3m = w3m-batch;
enableStandardFeatures = true; enableStandardFeatures = true;
enableExtraPlugins = true; enableExtraPlugins = true;
}; };