texlive.combine: generate language.{dat,def} more accurately

This commit is contained in:
Vincenzo Mantova 2021-07-04 11:47:33 +01:00
parent 14209b1383
commit 7d12a7dde9

View file

@ -124,23 +124,24 @@ in (buildEnv {
(let
hyphens = lib.filter (p: p.hasHyphens or false && p.tlType == "run") pkgList.splitBin.wrong;
pnames = uniqueStrings (map (p: p.pname) hyphens);
# sed expression that prints the lines in /start/,/end/ except for /end/
section = start: end: "/${start}/,/${end}/{ /${start}/p; /${end}/!p; };\n";
script =
writeText "hyphens.sed" (
# document how the file was generated (for language.dat)
"1{ s/^(% Generated by .*)$/\\1, modified by texlive.combine/; p; }\n"
# pick up the header
"1,/^% from/p;\n"
+ "2,/^% from/{ /^% from/!p; };\n"
# pick up all sections matching packages that we combine
+ lib.concatMapStrings (pname: "/^% from ${pname}:$/,/^%/p;\n") pnames
# pick up footer (for language.def)
+ lib.concatMapStrings (pname: section "^% from ${pname}:$" "^% from|^%%% No changes may be made beyond this point.$") pnames
# pick up the footer (for language.def)
+ "/^%%% No changes may be made beyond this point.$/,$p;\n"
);
in ''
(
cd ./share/texmf/tex/generic/config/
for fname in language.dat language.def; do
[ -e $fname ] || continue;
cnfOrig="$(realpath ./$fname)"
rm ./$fname
cat "$cnfOrig" | sed -n -f '${script}' > ./$fname
for fname in language.{dat,def}; do
[[ -e "$fname" ]] && sed -E -n -f '${script}' -i "$fname"
done
)
'') +