texlive: use --replace-fail for substitutions

This commit is contained in:
Vincenzo Mantova 2024-03-16 19:17:11 +00:00
parent c591acdb52
commit 7f51e79e66
3 changed files with 15 additions and 15 deletions

View File

@ -453,7 +453,7 @@ xdvi = stdenv.mkDerivation {
postInstall = ''
substituteInPlace "$out/bin/xdvi" \
--replace "exec xdvi-xaw" "exec '$out/bin/xdvi-xaw'"
--replace-fail "exec xdvi-xaw" "exec '$out/bin/xdvi-xaw'"
'';
# TODO: it's suspicious that mktexpk generates fonts into ~/.texlive2014
};
@ -489,8 +489,8 @@ xindy = stdenv.mkDerivation {
# hardcode clisp location
postPatch = ''
substituteInPlace xindy-*/user-commands/xindy.in \
--replace "our \$clisp = ( \$is_windows ? 'clisp.exe' : 'clisp' ) ;" \
"our \$clisp = '$(type -P clisp)';"
--replace-fail "our \$clisp = ( \$is_windows ? 'clisp.exe' : 'clisp' ) ;" \
"our \$clisp = '$(type -P clisp)';"
'';
nativeBuildInputs = [

View File

@ -378,7 +378,7 @@ let
if [[ -e "$out/bin/mtxrun" ]]; then
mv "$out"/bin/mtxrun.lua{,.orig}
substitute "$TEXMFDIST"/scripts/context/lua/mtxrun.lua "$out"/bin/mtxrun.lua \
--replace 'randomseed(math.initialseed)' "randomseed($SOURCE_DATE_EPOCH)"
--replace-fail 'randomseed(math.initialseed)' "randomseed($SOURCE_DATE_EPOCH)"
fi
'' +
# texlive postactions (see TeXLive::TLUtils::_do_postaction_script)
@ -409,7 +409,7 @@ let
# note that calling faketime and fmtutil is fragile (faketime uses LD_PRELOAD, fmtutil calls /bin/sh, causing potential glibc issues on non-NixOS)
# so we patch fmtutil to use faketime, rather than calling faketime fmtutil
substitute "$TEXMFDIST"/scripts/texlive/fmtutil.pl fmtutil \
--replace 'my $cmdline = "$eng -ini ' 'my $cmdline = "faketime -f '"'"'\@1980-01-01 00:00:00 x0.001'"'"' $eng -ini '
--replace-fail 'my $cmdline = "$eng -ini ' 'my $cmdline = "faketime -f '"'"'\@1980-01-01 00:00:00 x0.001'"'"' $eng -ini '
FORCE_SOURCE_DATE=1 TZ= perl fmtutil --sys --all | grep '^fmtutil' # too verbose
# Disable unavailable map files

View File

@ -293,7 +293,7 @@ in lib.recursiveUpdate orig rec {
#### other script fixes
# wrong $0 expectations
bibcop.postFixup = ''
substituteInPlace "$out"/bin/bibcop --replace "basename(\$0) eq 'bibcop.pl'" "basename(\$0) eq 'bibcop'"
substituteInPlace "$out"/bin/bibcop --replace-fail "basename(\$0) eq 'bibcop.pl'" "basename(\$0) eq 'bibcop'"
'';
# misc tab and python3 fixes
@ -305,12 +305,12 @@ in lib.recursiveUpdate orig rec {
# add runtime dependencies to PATH
epspdf.postFixup = ''
sed -i '2ios.setenv("PATH","${lib.makeBinPath epspdf.extraBuildInputs}" .. (os.getenv("PATH") and ":" .. os.getenv("PATH") or ""))' "$out"/bin/epspdf
substituteInPlace "$out"/bin/epspdftk --replace '[info script]' "\"$scriptsFolder/epspdftk.tcl\""
substituteInPlace "$out"/bin/epspdftk --replace-fail '[info script]' "\"$scriptsFolder/epspdftk.tcl\""
'';
# find files in script directory, not in binary directory
latexindent.postFixup = ''
substituteInPlace "$out"/bin/latexindent --replace 'use FindBin;' "BEGIN { \$0 = '$scriptsFolder' . '/latexindent.pl'; }; use FindBin;"
substituteInPlace "$out"/bin/latexindent --replace-fail 'use FindBin;' "BEGIN { \$0 = '$scriptsFolder' . '/latexindent.pl'; }; use FindBin;"
'';
# flag lua dependency
@ -330,14 +330,14 @@ in lib.recursiveUpdate orig rec {
# patch interpreter
texosquery.postFixup = ''
substituteInPlace "$out"/bin/* --replace java "$interpJava"
substituteInPlace "$out"/bin/* --replace-fail java "$interpJava"
'';
# hardcode revision numbers (since texlive.infra, tlshell are not in either system or user texlive.tlpdb)
tlshell.postFixup = ''
substituteInPlace "$out"/bin/tlshell \
--replace '[dict get $::pkgs texlive.infra localrev]' '${toString orig."texlive.infra".revision}' \
--replace '[dict get $::pkgs tlshell localrev]' '${toString orig.tlshell.revision}'
--replace-fail '[dict get $::pkgs texlive.infra localrev]' '${toString orig."texlive.infra".revision}' \
--replace-fail '[dict get $::pkgs tlshell localrev]' '${toString orig.tlshell.revision}'
'';
#### dependency changes
@ -389,9 +389,9 @@ in lib.recursiveUpdate orig rec {
TEXMFCNF="${tl.kpathsea.tex}"/web2c TEXMF="$scriptsFolder/../.." \
texlua "$out"/bin/texdoc --print-completion zsh > "$TMPDIR"/_texdoc
substituteInPlace "$TMPDIR"/_texdoc \
--replace 'compdef __texdoc texdoc' '#compdef texdoc' \
--replace '$(kpsewhich -var-value TEXMFROOT)/tlpkg/texlive.tlpdb' '$(kpsewhich Data.tlpdb.lua)' \
--replace '/^name[^.]*$/ {print $2}' '/^ \["[^"]*"\] = {$/ { print substr($1,3,length($1)-4) }'
--replace-fail 'compdef __texdoc texdoc' '#compdef texdoc' \
--replace-fail '$(kpsewhich -var-value TEXMFROOT)/tlpkg/texlive.tlpdb' '$(kpsewhich Data.tlpdb.lua)' \
--replace-fail '/^name[^.]*$/ {print $2}' '/^ \["[^"]*"\] = {$/ { print substr($1,3,length($1)-4) }'
echo '__texdoc' >> "$TMPDIR"/_texdoc
installShellCompletion --zsh "$TMPDIR"/_texdoc
'';
@ -410,7 +410,7 @@ in lib.recursiveUpdate orig rec {
# make tlmgr believe it can use kpsewhich to evaluate TEXMFROOT
postFixup = ''
substituteInPlace "$out"/bin/tlmgr \
--replace 'if (-r "$bindir/$kpsewhichname")' 'if (1)'
--replace-fail 'if (-r "$bindir/$kpsewhichname")' 'if (1)'
sed -i '2i$ENV{PATH}='"'"'${lib.makeBinPath [ gnupg ]}'"'"' . ($ENV{PATH} ? ":$ENV{PATH}" : '"'''"');' "$out"/bin/tlmgr
sed -i '2iPATH="${lib.makeBinPath [ coreutils gnused tl.kpathsea ]}''${PATH:+:$PATH}"' "$out"/bin/mktexlsr
'';