From 641fb6ab8437b87f96d07fb85263575c6d0b99f2 Mon Sep 17 00:00:00 2001 From: Vincenzo Mantova <1962985+xworld21@users.noreply.github.com> Date: Mon, 13 Feb 2023 19:59:50 +0000 Subject: [PATCH] texlive: use looping in tl2nix (#216066) --- pkgs/tools/typesetting/tex/texlive/tl2nix.sed | 66 +++++++++++-------- 1 file changed, 38 insertions(+), 28 deletions(-) diff --git a/pkgs/tools/typesetting/tex/texlive/tl2nix.sed b/pkgs/tools/typesetting/tex/texlive/tl2nix.sed index 61150fa8b7cf..c02ca35296ec 100644 --- a/pkgs/tools/typesetting/tex/texlive/tl2nix.sed +++ b/pkgs/tools/typesetting/tex/texlive/tl2nix.sed @@ -2,37 +2,47 @@ 1itl: { # no indentation $a} -# trash packages we don't want -/^name .*\./,/^$/d - -# quote package names, as some start with a number :-/ -s/^name (.*)/name "\1"/ - -# extract revision -s/^revision ([0-9]*)$/ revision = \1;/p - # form an attrmap per package -/^name /s/^name (.*)/\1 = {/p -/^$/,1i}; +# ignore packages whose name contains "." (such as binaries) +/^name ([^.]+)$/,/^$/{ + # quote package names, as some start with a number :-/ + s/^name (.*)$/"\1" = {/p + /^$/,1i}; -# extract hashes of *.tar.xz -s/^containerchecksum (.*)/ sha512.run = "\1";/p -s/^doccontainerchecksum (.*)/ sha512.doc = "\1";/p -s/^srccontainerchecksum (.*)/ sha512.source = "\1";/p -/^runfiles /i\ hasRunfiles = true; + # extract revision + s/^revision ([0-9]*)$/ revision = \1;/p -# number of path components to strip, defaulting to 1 ("texmf-dist/") -/^relocated 1/i\ stripPrefix = 0; + # extract hashes of *.tar.xz + s/^containerchecksum (.*)/ sha512.run = "\1";/p + s/^doccontainerchecksum (.*)/ sha512.doc = "\1";/p + s/^srccontainerchecksum (.*)/ sha512.source = "\1";/p + /^runfiles /i\ hasRunfiles = true; -# extract version and clean unwanted chars from it -/^catalogue-version/y/ \/~/_--/ -/^catalogue-version/s/[\#,:\(\)]//g -s/^catalogue-version_(.*)/ version = "\1";/p + # number of path components to strip, defaulting to 1 ("texmf-dist/") + /^relocated 1/i\ stripPrefix = 0; -# extract deps -s/^depend ([^.]*)$/ deps."\1" = tl."\1";/p + # extract version and clean unwanted chars from it + /^catalogue-version/y/ \/~/_--/ + /^catalogue-version/s/[\#,:\(\)]//g + s/^catalogue-version_(.*)/ version = "\1";/p -# extract hyphenation patterns and formats -# (this may create duplicate lines, use uniq to remove them) -/^execute\sAddHyphen/i\ hasHyphens = true; -/^execute\sAddFormat/i\ hasFormats = true; + # extract deps + /^depend [^.]+$/{ + s/^depend (.+)$/ deps."\1" = tl."\1";/ + + # loop through following depend lines + :next + h ; N # save & read next line + s/\ndepend (.+)\.(.+)$// + s/\ndepend (.+)$/\n deps."\1" = tl."\1";/ + t next # loop if the previous lines matched + + x; p; x # print saved deps + s/^.*\n// # remove deps, resume processing + } + + # extract hyphenation patterns and formats + # (this may create duplicate lines, use uniq to remove them) + /^execute\sAddHyphen/i\ hasHyphens = true; + /^execute\sAddFormat/i\ hasFormats = true; +}