Merge pull request #119362 from xworld21/texlive-combine-fix-buildenv
texlive.combine: split static $TEXMFDIST into a separate derivation
This commit is contained in:
commit
f6e067692d
@ -174,10 +174,10 @@
|
|||||||
|
|
||||||
for fname in language.{dat,def,dat.lua} ; do
|
for fname in language.{dat,def,dat.lua} ; do
|
||||||
diff --ignore-matching-lines='^\(%\|--\) Generated by ' -u \
|
diff --ignore-matching-lines='^\(%\|--\) Generated by ' -u \
|
||||||
{"$hyphenBase","$schemeFull"/share/texmf}/tex/generic/config/"$fname" \
|
{"$hyphenBase","$schemeFull"/share/texmf-var}/tex/generic/config/"$fname" \
|
||||||
| tee "$out/scheme-full/$fname.patch"
|
| tee "$out/scheme-full/$fname.patch"
|
||||||
diff --ignore-matching-lines='^\(%\|--\) Generated by ' -u \
|
diff --ignore-matching-lines='^\(%\|--\) Generated by ' -u \
|
||||||
{,"$schemeInfraOnly"/share/texmf/tex/generic/config/}"$fname" \
|
{,"$schemeInfraOnly"/share/texmf-var/tex/generic/config/}"$fname" \
|
||||||
| tee "$out/scheme-infraonly/$fname.patch"
|
| tee "$out/scheme-infraonly/$fname.patch"
|
||||||
done
|
done
|
||||||
'';
|
'';
|
||||||
@ -190,7 +190,7 @@
|
|||||||
mkdir -p "$out"
|
mkdir -p "$out"
|
||||||
|
|
||||||
diff --ignore-matching-lines='^# Generated by ' -u \
|
diff --ignore-matching-lines='^# Generated by ' -u \
|
||||||
{"$kpathsea","$schemeFull"/share/texmf}/web2c/fmtutil.cnf \
|
{"$kpathsea","$schemeFull"/share/texmf-var}/web2c/fmtutil.cnf \
|
||||||
| tee "$out/fmtutil.cnf.patch"
|
| tee "$out/fmtutil.cnf.patch"
|
||||||
'';
|
'';
|
||||||
}
|
}
|
||||||
|
@ -38,16 +38,44 @@ let
|
|||||||
mkUniqueOutPaths = pkgs: lib.unique
|
mkUniqueOutPaths = pkgs: lib.unique
|
||||||
(map (p: p.outPath) (builtins.filter lib.isDerivation pkgs));
|
(map (p: p.outPath) (builtins.filter lib.isDerivation pkgs));
|
||||||
|
|
||||||
in (buildEnv {
|
|
||||||
name = "texlive-${extraName}-${bin.texliveYear}${extraVersion}";
|
name = "texlive-${extraName}-${bin.texliveYear}${extraVersion}";
|
||||||
|
|
||||||
extraPrefix = "/share/texmf";
|
texmf = (buildEnv {
|
||||||
|
name = "${name}-texmf";
|
||||||
|
|
||||||
|
paths = pkgList.nonbin;
|
||||||
|
|
||||||
|
nativeBuildInputs = [ perl bin.core.out ];
|
||||||
|
|
||||||
|
postBuild = # generate ls-R database
|
||||||
|
''
|
||||||
|
perl -I "${bin.core.out}/share/texmf-dist/scripts/texlive" \
|
||||||
|
-- "$out/scripts/texlive/mktexlsr.pl" --sort "$out"
|
||||||
|
'';
|
||||||
|
}).overrideAttrs (_: { allowSubstitutes = true; });
|
||||||
|
|
||||||
|
# expose info and man pages in usual /share/{info,man} location
|
||||||
|
doc = buildEnv {
|
||||||
|
name = "${name}-doc";
|
||||||
|
|
||||||
|
paths = [ (texmf.outPath + "/doc") ];
|
||||||
|
extraPrefix = "/share";
|
||||||
|
|
||||||
|
pathsToLink = [
|
||||||
|
"/info"
|
||||||
|
"/man"
|
||||||
|
];
|
||||||
|
};
|
||||||
|
|
||||||
|
in (buildEnv {
|
||||||
|
|
||||||
|
inherit name;
|
||||||
|
|
||||||
ignoreCollisions = false;
|
ignoreCollisions = false;
|
||||||
paths = pkgList.nonbin;
|
paths = pkgList.bin ++ [ doc ];
|
||||||
pathsToLink = [
|
pathsToLink = [
|
||||||
"/"
|
"/"
|
||||||
"/tex/generic/config" # make it a real directory for scheme-infraonly
|
"/bin" # ensure these are writeable directories
|
||||||
];
|
];
|
||||||
|
|
||||||
nativeBuildInputs = [ makeWrapper libfaketime perl bin.texlinks ];
|
nativeBuildInputs = [ makeWrapper libfaketime perl bin.texlinks ];
|
||||||
@ -57,54 +85,40 @@ in (buildEnv {
|
|||||||
passthru.packages = pkgList.all;
|
passthru.packages = pkgList.all;
|
||||||
|
|
||||||
postBuild = ''
|
postBuild = ''
|
||||||
mkdir -p "$out"/bin
|
TEXMFDIST="${texmf}"
|
||||||
'' +
|
export PATH="$out/bin:$PATH"
|
||||||
lib.concatMapStrings
|
export PERL5LIB="$TEXMFDIST/scripts/texlive:${bin.core.out}/share/texmf-dist/scripts/texlive"
|
||||||
(path: ''
|
|
||||||
for f in '${path}'/bin/*; do
|
|
||||||
if [[ -L "$f" ]]; then
|
|
||||||
cp -d "$f" "$out"/bin/
|
|
||||||
else
|
|
||||||
ln -s "$f" "$out"/bin/
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
'')
|
|
||||||
pkgList.bin
|
|
||||||
+
|
|
||||||
''
|
|
||||||
export PATH="$out/bin:$out/share/texmf/scripts/texlive:$PATH"
|
|
||||||
export TEXMFCNF="$out/share/texmf/web2c"
|
|
||||||
TEXMFSYSCONFIG="$out/share/texmf-config"
|
TEXMFSYSCONFIG="$out/share/texmf-config"
|
||||||
TEXMFSYSVAR="$out/share/texmf-var"
|
TEXMFSYSVAR="$out/share/texmf-var"
|
||||||
export PERL5LIB="$out/share/texmf/scripts/texlive:${bin.core.out}/share/texmf-dist/scripts/texlive"
|
export TEXMFCNF="$TEXMFSYSVAR/web2c"
|
||||||
'' +
|
'' +
|
||||||
# patch texmf-dist -> $out/share/texmf
|
# patch texmf-dist -> $TEXMFDIST
|
||||||
# patch texmf-local -> $out/share/texmf-local
|
# patch texmf-local -> $out/share/texmf-local
|
||||||
|
# patch texmf.cnf -> $TEXMFSYSVAR/web2c/texmf.cnf
|
||||||
# TODO: perhaps do lua actions?
|
# TODO: perhaps do lua actions?
|
||||||
# tried inspiration from install-tl, sub do_texmf_cnf
|
# tried inspiration from install-tl, sub do_texmf_cnf
|
||||||
''
|
''
|
||||||
if [ -e "$TEXMFCNF/texmfcnf.lua" ]; then
|
mkdir -p "$TEXMFCNF"
|
||||||
|
if [ -e "$TEXMFDIST/web2c/texmfcnf.lua" ]; then
|
||||||
sed \
|
sed \
|
||||||
-e 's,texmf-dist,texmf,g' \
|
-e "s,\(TEXMFDIST[ ]*=[ ]*\)[^\,]*,\1\"$TEXMFDIST\",g" \
|
||||||
-e "s,\(TEXMFLOCAL[ ]*=[ ]*\)[^\,]*,\1\"$out/share/texmf-local\",g" \
|
-e "s,\(TEXMFLOCAL[ ]*=[ ]*\)[^\,]*,\1\"$out/share/texmf-local\",g" \
|
||||||
-e "s,\$SELFAUTOLOC,$out,g" \
|
-e "s,\$SELFAUTOLOC,$out,g" \
|
||||||
-e "s,selfautodir:/,$out/share/,g" \
|
-e "s,selfautodir:/,$out/share/,g" \
|
||||||
-e "s,selfautodir:,$out/share/,g" \
|
-e "s,selfautodir:,$out/share/,g" \
|
||||||
-e "s,selfautoparent:/,$out/share/,g" \
|
-e "s,selfautoparent:/,$out/share/,g" \
|
||||||
-e "s,selfautoparent:,$out/share/,g" \
|
-e "s,selfautoparent:,$out/share/,g" \
|
||||||
-i "$TEXMFCNF/texmfcnf.lua"
|
"$TEXMFDIST/web2c/texmfcnf.lua" > "$TEXMFCNF/texmfcnf.lua"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sed \
|
sed \
|
||||||
-e 's,texmf-dist,texmf,g' \
|
-e "s,\(TEXMFDIST[ ]*=[ ]*\)[^\,]*,\1$TEXMFDIST,g" \
|
||||||
-e "s,\$SELFAUTOLOC,$out,g" \
|
-e "s,\$SELFAUTOLOC,$out,g" \
|
||||||
-e "s,\$SELFAUTODIR,$out/share,g" \
|
-e "s,\$SELFAUTODIR,$out/share,g" \
|
||||||
-e "s,\$SELFAUTOPARENT,$out/share,g" \
|
-e "s,\$SELFAUTOPARENT,$out/share,g" \
|
||||||
-e "s,\$SELFAUTOGRANDPARENT,$out/share,g" \
|
-e "s,\$SELFAUTOGRANDPARENT,$out/share,g" \
|
||||||
-e "/^mpost,/d" `# CVE-2016-10243` \
|
-e "/^mpost,/d" `# CVE-2016-10243` \
|
||||||
-i "$TEXMFCNF/texmf.cnf"
|
"$TEXMFDIST/web2c/texmf.cnf" > "$TEXMFCNF/texmf.cnf"
|
||||||
|
|
||||||
mkdir "$out/share/texmf-local"
|
|
||||||
'' +
|
'' +
|
||||||
# now filter hyphenation patterns and formats
|
# now filter hyphenation patterns and formats
|
||||||
(let
|
(let
|
||||||
@ -132,18 +146,31 @@ in (buildEnv {
|
|||||||
+ lib.concatMapStrings (pname: section "^-- from ${pname}:$" "^}$|^-- from") hyphenPNames
|
+ lib.concatMapStrings (pname: section "^-- from ${pname}:$" "^}$|^-- from") hyphenPNames
|
||||||
+ "$p;\n"
|
+ "$p;\n"
|
||||||
);
|
);
|
||||||
|
# formats not being installed must be disabled by prepending #! (see man fmtutil)
|
||||||
|
# sed expression that enables the formats in /start/,/end/
|
||||||
|
enableFormats = pname: "/^# from ${pname}:$/,/^# from/{ s/^#! //; };\n";
|
||||||
fmtutilSed =
|
fmtutilSed =
|
||||||
writeText "fmtutil.sed" (
|
writeText "fmtutil.sed" (
|
||||||
"1{ s/^(# Generated by .*)$/\\1, modified by texlive.combine/; p; }\n"
|
# document how file was generated
|
||||||
+ "2,/^# from/{ /^# from/!p; };\n"
|
"1{ s/^(# Generated by .*)$/\\1, modified by texlive.combine/; }\n"
|
||||||
+ lib.concatMapStrings (pname: section "^# from ${pname}:$" "^# from") formatPNames
|
# disable all formats, even those already disabled
|
||||||
|
+ "s/^([^#]|#! )/#! \\1/;\n"
|
||||||
|
# enable the formats from the packages being installed
|
||||||
|
+ lib.concatMapStrings enableFormats formatPNames
|
||||||
|
# clean up formats that have been disabled twice
|
||||||
|
+ "s/^#! #! /#! /;\n"
|
||||||
);
|
);
|
||||||
in ''
|
in ''
|
||||||
for fname in "$out"/share/texmf/tex/generic/config/language.{dat,def}; do
|
mkdir -p "$TEXMFSYSVAR/tex/generic/config"
|
||||||
[[ -e "$fname" ]] && sed -E -n -f '${script}' -i "$fname"
|
for fname in tex/generic/config/language.{dat,def}; do
|
||||||
|
[[ -e "$TEXMFDIST/$fname" ]] && sed -E -n -f '${script}' "$TEXMFDIST/$fname" > "$TEXMFSYSVAR/$fname"
|
||||||
done
|
done
|
||||||
[[ -e "$out"/share/texmf/tex/generic/config/language.dat.lua ]] && sed -E -n -f '${scriptLua}' -i "$out"/share/texmf/tex/generic/config/language.dat.lua
|
[[ -e "$TEXMFDIST"/tex/generic/config/language.dat.lua ]] && sed -E -n -f '${scriptLua}' \
|
||||||
[[ -e "$TEXMFCNF"/fmtutil.cnf ]] && sed -E -n -f '${fmtutilSed}' -i "$TEXMFCNF"/fmtutil.cnf
|
"$TEXMFDIST"/tex/generic/config/language.dat.lua > "$TEXMFSYSVAR"/tex/generic/config/language.dat.lua
|
||||||
|
[[ -e "$TEXMFDIST"/web2c/fmtutil.cnf ]] && sed -E -f '${fmtutilSed}' "$TEXMFDIST"/web2c/fmtutil.cnf > "$TEXMFCNF"/fmtutil.cnf
|
||||||
|
|
||||||
|
# make new files visible to kpathsea
|
||||||
|
perl "$TEXMFDIST"/scripts/texlive/mktexlsr.pl --sort "$TEXMFSYSVAR"
|
||||||
'') +
|
'') +
|
||||||
|
|
||||||
# function to wrap created executables with required env vars
|
# function to wrap created executables with required env vars
|
||||||
@ -191,16 +218,15 @@ in (buildEnv {
|
|||||||
'' +
|
'' +
|
||||||
# texlive post-install actions
|
# texlive post-install actions
|
||||||
''
|
''
|
||||||
ln -sf "$out"/share/texmf/scripts/texlive/updmap.pl "$out"/bin/updmap
|
ln -sf "$TEXMFDIST"/scripts/texlive/updmap.pl "$out"/bin/updmap
|
||||||
'' +
|
'' +
|
||||||
# now hack to preserve "$0" for mktexfmt
|
# now hack to preserve "$0" for mktexfmt
|
||||||
''
|
''
|
||||||
cp "$out"/share/texmf/scripts/texlive/fmtutil.pl "$out/bin/fmtutil"
|
cp "$TEXMFDIST"/scripts/texlive/fmtutil.pl "$out/bin/fmtutil"
|
||||||
patchShebangs "$out/bin/fmtutil"
|
patchShebangs "$out/bin/fmtutil"
|
||||||
sed "1s|$| -I $out/share/texmf/scripts/texlive|" -i "$out/bin/fmtutil"
|
sed "1s|$| -I $TEXMFDIST/scripts/texlive|" -i "$out/bin/fmtutil"
|
||||||
ln -sf fmtutil "$out/bin/mktexfmt"
|
ln -sf fmtutil "$out/bin/mktexfmt"
|
||||||
|
|
||||||
perl "$out"/share/texmf/scripts/texlive/mktexlsr.pl --sort "$out"/share/texmf
|
|
||||||
texlinks "$out/bin" && wrapBin
|
texlinks "$out/bin" && wrapBin
|
||||||
FORCE_SOURCE_DATE=1 fmtutil --sys --all | grep '^fmtutil' # too verbose
|
FORCE_SOURCE_DATE=1 fmtutil --sys --all | grep '^fmtutil' # too verbose
|
||||||
#texlinks "$out/bin" && wrapBin # do we need to regenerate format links?
|
#texlinks "$out/bin" && wrapBin # do we need to regenerate format links?
|
||||||
@ -224,16 +250,16 @@ in (buildEnv {
|
|||||||
# sort entries to improve reproducibility
|
# sort entries to improve reproducibility
|
||||||
[[ -f "$TEXMFSYSCONFIG"/web2c/updmap.cfg ]] && sort -o "$TEXMFSYSCONFIG"/web2c/updmap.cfg "$TEXMFSYSCONFIG"/web2c/updmap.cfg
|
[[ -f "$TEXMFSYSCONFIG"/web2c/updmap.cfg ]] && sort -o "$TEXMFSYSCONFIG"/web2c/updmap.cfg "$TEXMFSYSCONFIG"/web2c/updmap.cfg
|
||||||
|
|
||||||
perl "$out"/share/texmf/scripts/texlive/mktexlsr.pl --sort "$out"/share/texmf-* # to make sure
|
perl "$TEXMFDIST"/scripts/texlive/mktexlsr.pl --sort "$TEXMFSYSCONFIG" "$TEXMFSYSVAR" # to make sure
|
||||||
'' +
|
'' +
|
||||||
# install (wrappers for) scripts, based on a list from upstream texlive
|
# install (wrappers for) scripts, based on a list from upstream texlive
|
||||||
''
|
''
|
||||||
source '${bin.core.out}/share/texmf-dist/scripts/texlive/scripts.lst'
|
source '${bin.core.out}/share/texmf-dist/scripts/texlive/scripts.lst'
|
||||||
for s in $texmf_scripts; do
|
for s in $texmf_scripts; do
|
||||||
[[ -x "$out/share/texmf/scripts/$s" ]] || continue
|
[[ -x "$TEXMFDIST/scripts/$s" ]] || continue
|
||||||
tName="$(basename $s | sed 's/\.[a-z]\+$//')" # remove extension
|
tName="$(basename $s | sed 's/\.[a-z]\+$//')" # remove extension
|
||||||
[[ ! -e "$out/bin/$tName" ]] || continue
|
[[ ! -e "$out/bin/$tName" ]] || continue
|
||||||
ln -sv "$(realpath $out/share/texmf/scripts/$s)" "$out/bin/$tName" # wrapped below
|
ln -sv "$(realpath "$TEXMFDIST/scripts/$s")" "$out/bin/$tName" # wrapped below
|
||||||
done
|
done
|
||||||
'' +
|
'' +
|
||||||
# A hacky way to provide repstopdf
|
# A hacky way to provide repstopdf
|
||||||
@ -241,8 +267,9 @@ in (buildEnv {
|
|||||||
# * ./bin/repstopdf needs to be a symlink to be processed by wrapBin
|
# * ./bin/repstopdf needs to be a symlink to be processed by wrapBin
|
||||||
''
|
''
|
||||||
if [[ -e "$out"/bin/epstopdf ]]; then
|
if [[ -e "$out"/bin/epstopdf ]]; then
|
||||||
cp "$out"/bin/epstopdf "$out"/share/texmf/scripts/repstopdf
|
mkdir -p "$TEXMFSYSVAR/scripts"
|
||||||
ln -s "$out"/share/texmf/scripts/repstopdf "$out"/bin/repstopdf
|
cp "$out"/bin/epstopdf "$TEXMFSYSVAR"/scripts/repstopdf
|
||||||
|
ln -s "$TEXMFSYSVAR"/scripts/repstopdf "$out"/bin/repstopdf
|
||||||
fi
|
fi
|
||||||
'' +
|
'' +
|
||||||
# finish up the wrappers
|
# finish up the wrappers
|
||||||
@ -262,16 +289,6 @@ in (buildEnv {
|
|||||||
# TODO: a context trigger https://www.preining.info/blog/2015/06/debian-tex-live-2015-the-new-layout/
|
# TODO: a context trigger https://www.preining.info/blog/2015/06/debian-tex-live-2015-the-new-layout/
|
||||||
# http://wiki.contextgarden.net/ConTeXt_Standalone#Unix-like_platforms_.28Linux.2FMacOS_X.2FFreeBSD.2FSolaris.29
|
# http://wiki.contextgarden.net/ConTeXt_Standalone#Unix-like_platforms_.28Linux.2FMacOS_X.2FFreeBSD.2FSolaris.29
|
||||||
|
|
||||||
# I would just create links from "$out"/share/{man,info},
|
|
||||||
# but buildenv has problems with merging symlinks with directories;
|
|
||||||
# note: it's possible we might need deepen the work-around to man/*.
|
|
||||||
''
|
|
||||||
for d in {man,info}; do
|
|
||||||
[[ -e "$out/share/texmf/doc/$d" ]] || continue;
|
|
||||||
mkdir -p "$out/share/$d"
|
|
||||||
ln -s -t "$out/share/$d" "$out/share/texmf/doc/$d"/*
|
|
||||||
done
|
|
||||||
'' +
|
|
||||||
# MkIV uses its own lookup mechanism and we need to initialize
|
# MkIV uses its own lookup mechanism and we need to initialize
|
||||||
# caches for it.
|
# caches for it.
|
||||||
''
|
''
|
||||||
@ -283,7 +300,7 @@ in (buildEnv {
|
|||||||
# Get rid of all log files. They are not needed, but take up space
|
# Get rid of all log files. They are not needed, but take up space
|
||||||
# and render the build unreproducible by their embedded timestamps.
|
# and render the build unreproducible by their embedded timestamps.
|
||||||
''
|
''
|
||||||
find $TEXMFSYSVAR/web2c -name '*.log' -delete
|
find "$TEXMFSYSVAR"/web2c -name '*.log' -delete
|
||||||
''
|
''
|
||||||
;
|
;
|
||||||
}).overrideAttrs (_: { allowSubstitutes = true; })
|
}).overrideAttrs (_: { allowSubstitutes = true; })
|
||||||
|
Loading…
Reference in New Issue
Block a user