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 (let
hyphens = lib.filter (p: p.hasHyphens or false && p.tlType == "run") pkgList.splitBin.wrong; hyphens = lib.filter (p: p.hasHyphens or false && p.tlType == "run") pkgList.splitBin.wrong;
pnames = uniqueStrings (map (p: p.pname) hyphens); 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 = script =
writeText "hyphens.sed" ( 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 # pick up the header
"1,/^% from/p;\n" + "2,/^% from/{ /^% from/!p; };\n"
# pick up all sections matching packages that we combine # pick up all sections matching packages that we combine
+ lib.concatMapStrings (pname: "/^% from ${pname}:$/,/^%/p;\n") pnames + lib.concatMapStrings (pname: section "^% from ${pname}:$" "^% from|^%%% No changes may be made beyond this point.$") pnames
# pick up footer (for language.def) # pick up the footer (for language.def)
+ "/^%%% No changes may be made beyond this point.$/,$p;\n" + "/^%%% No changes may be made beyond this point.$/,$p;\n"
); );
in '' in ''
( (
cd ./share/texmf/tex/generic/config/ cd ./share/texmf/tex/generic/config/
for fname in language.dat language.def; do for fname in language.{dat,def}; do
[ -e $fname ] || continue; [[ -e "$fname" ]] && sed -E -n -f '${script}' -i "$fname"
cnfOrig="$(realpath ./$fname)"
rm ./$fname
cat "$cnfOrig" | sed -n -f '${script}' > ./$fname
done done
) )
'') + '') +