asymptote: do not build sty, docs if provided via texlive

This commit is contained in:
Vincenzo Mantova 2024-04-21 20:28:20 +01:00
parent b7440798d3
commit e2d64efdcb
1 changed files with 57 additions and 14 deletions

View File

@ -4,21 +4,27 @@
, boehmgc, libGLU, libGL, mesa, ncurses, readline, gsl, libsigsegv
, python3, qtbase, qtsvg, boost
, zlib, perl, curl
, texliveSmall, texinfo
, texinfo
, texlive
, texliveSmall
, darwin
}:
stdenv.mkDerivation rec {
stdenv.mkDerivation (finalAttrs: {
version = "2.88";
pname = "asymptote";
outputs = [ "out" "man" "info" "doc" "tex" ];
src = fetchurl {
url = "mirror://sourceforge/asymptote/${version}/asymptote-${version}.src.tgz";
url = "mirror://sourceforge/asymptote/${finalAttrs.version}/asymptote-${finalAttrs.version}.src.tgz";
hash = "sha256-DecadD+m7pORuH3Sdcs/5M3vUbN6rhSkFoNN0Soq9bs=";
};
# override with TeX Live containers to avoid building sty, docs from source
texContainer = null;
texdocContainer = null;
patches = [
(fetchpatch {
# partial fix for macOS XDR/V3D support (LDFLAGS change seems like an unrelated bugfix)
@ -37,8 +43,8 @@ stdenv.mkDerivation rec {
wrapQtAppsHook
cmake
pkg-config
(texliveSmall.withPackages (ps: with ps; [ epsf cm-super ps.texinfo media9 ocgx2 collection-latexextra ]))
];
] ++ lib.optional (finalAttrs.texContainer == null || finalAttrs.texdocContainer == null)
(texliveSmall.withPackages (ps: with ps; [ epsf cm-super ps.texinfo media9 ocgx2 collection-latexextra ]));
buildInputs = [
ghostscriptX imagemagick fftw eigen
@ -57,12 +63,25 @@ stdenv.mkDerivation rec {
dontWrapQtApps = true;
# Do not build $tex/ls-R which will be generated by texlive.combine
# do not build $tex/ls-R which will be generated by texlive.withPackages
# do not build and install sty and docs, if provided by tex/texdoc texlive containers
# (this is an optimisation to make texliveMedium and texliveFull independent of texliveSmall)
preConfigure = ''
HOME=$TMP
substituteInPlace Makefile.in \
--replace-fail 'install: install-notexhash install-texhash' 'install: install-notexhash install-asy'
prependToVar configureFlags "--with-latex=$tex/tex/latex" "--with-context=$tex/tex/context/third"
--replace-fail ' install-texhash' '''
if [[ -n $texContainer ]] ; then
sed -i Makefile.in -e '/(\(latex\|context\)dir)/d'
substituteInPlace Makefile.in \
--replace-fail 'asy sty' 'asy'
else
prependToVar configureFlags "--with-latex=$tex/tex/latex" "--with-context=$tex/tex/context/third"
fi
if [[ -n $texdocContainer ]] ; then
substituteInPlace Makefile.in \
--replace-fail ' install-man' ''' \
--replace-fail 'docdir = $(DESTDIR)@docdir@' 'docdir = $(TMP)/doc'
fi
'';
# do not use bundled libgc.so
@ -76,12 +95,36 @@ stdenv.mkDerivation rec {
rm "$out"/bin/xasy
makeQtWrapper "$out"/share/asymptote/GUI/xasy.py "$out"/bin/xasy --prefix PATH : "$out"/bin
mv "$info"/share/info/asymptote/*.info "$info"/share/info/
sed -i -e 's|(asymptote/asymptote)|(asymptote)|' "$info"/share/info/asymptote.info
rmdir "$info"/share/info/asymptote
rm -f "$info"/share/info/dir
if [[ -z $texdocContainer ]] ; then
mv "$info"/share/info/asymptote/*.info "$info"/share/info/
sed -i -e 's|(asymptote/asymptote)|(asymptote)|' "$info"/share/info/asymptote.info
rmdir "$info"/share/info/asymptote
rm -f "$info"/share/info/dir
fi
install -Dt $out/share/emacs/site-lisp/${finalAttrs.pname} $out/share/asymptote/*.el
'';
install -Dt $out/share/emacs/site-lisp/${pname} $out/share/asymptote/*.el
# fixupPhase crashes if the outputs are not directories
preFixup = ''
if [[ -n $texContainer ]] ; then
mkdir -p "$tex"
fi
if [[ -n $texdocContainer ]] ; then
mkdir -p "$doc" "$man" "$info"
fi
'';
postFixup = ''
if [[ -n $texContainer ]] ; then
rmdir "$tex"
ln -s "$texContainer" "$tex"
fi
if [[ -n $texdocContainer ]] ; then
mkdir -p "$man/share" "$info/share"
ln -s "$texdocContainer" "$doc/share"
ln -s "$texdocContainer/doc/man" "$man/share"
ln -s "$texdocContainer/doc/info" "$info/share"
fi
'';
dontUseCmakeConfigure = true;
@ -98,4 +141,4 @@ stdenv.mkDerivation rec {
maintainers = [ maintainers.raskin ];
platforms = platforms.linux ++ platforms.darwin;
};
}
})