about summary refs log tree commit diff
path: root/pkgs/tools/typesetting/tex/texlive/tl2nix.sed
diff options
context:
space:
mode:
Diffstat (limited to 'pkgs/tools/typesetting/tex/texlive/tl2nix.sed')
-rw-r--r--pkgs/tools/typesetting/tex/texlive/tl2nix.sed74
1 files changed, 73 insertions, 1 deletions
diff --git a/pkgs/tools/typesetting/tex/texlive/tl2nix.sed b/pkgs/tools/typesetting/tex/texlive/tl2nix.sed
index 022ec5c8589b..7c8520707a93 100644
--- a/pkgs/tools/typesetting/tex/texlive/tl2nix.sed
+++ b/pkgs/tools/typesetting/tex/texlive/tl2nix.sed
@@ -81,6 +81,20 @@ $a}
   }
 
   # detect presence of notable files
+  /^docfiles /{
+    s/^.*$//  # ignore the first line
+
+    # read all files
+    :next-doc
+      N
+      s/\n / /   # remove newline
+      t next-doc # loop if the previous lines matched
+
+    / (texmf-dist|RELOC)\/doc\/man\//i\  hasManpages = true;
+
+    D # restart cycle
+  }
+
   /^runfiles /{
     s/^.*$//  # ignore the first line
 
@@ -89,9 +103,25 @@ $a}
       N
       s/\n / /    # remove newline
       t next-file # loop if previous line matched
+    s/\n/ \n/     # add space before last newline for accurate matching below
 
     / (RELOC|texmf-dist)\//i\  hasRunfiles = true;
     / tlpkg\//i\  hasTlpkg = true;
+
+    # extract script extensions
+    / texmf-dist\/scripts\/.*\.(jar|lua|py|rb|sno|tcl|texlua|tlu) /{
+      i\  scriptExts = [
+        / texmf-dist\/scripts\/.*\.jar /i\    "jar"
+        / texmf-dist\/scripts\/.*\.lua /i\    "lua"
+        / texmf-dist\/scripts\/.*\.py /i\    "py"
+        / texmf-dist\/scripts\/.*\.rb /i\    "rb"
+        / texmf-dist\/scripts\/.*\.sno /i\    "sno"
+        / texmf-dist\/scripts\/.*\.tcl /i\    "tcl"
+        / texmf-dist\/scripts\/.*\.texlua /i\    "texlua"
+        / texmf-dist\/scripts\/.*\.tlu /i\    "tlu"
+      i\  ];
+    }
+
     D # restart cycle from the current line
   }
 
@@ -101,8 +131,50 @@ $a}
   # 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 format details
+  /^execute\sAddFormat\s/{
+    # open a list
+    i\  formats = [
+
+    # create one attribute set per format
+    # note that format names are not unique
+
+    # plain keys: name, engine, patterns
+    # optionally double quoted key: options
+    # boolean key: mode (enabled/disabled)
+    # comma-separated lists: fmttriggers, patterns
+    :next-fmt
+      s/(^|\n)execute\sAddFormat/    {/
+      s/\s+options="([^"]+)"/\n      options = "\1";/
+      s/\s+(name|engine|options)=([^ \t\n]+)/\n      \1 = "\2";/g
+      s/\s+mode=enabled//
+      s/\s+mode=disabled/\n      enabled = false;/
+      s/\s+(fmttriggers|patterns)=([^ \t\n]+)/\n      \1 = [ "\2" ];/g
+      s/$/\n    }/
+
+      :split-triggers
+        s/"([^,]+),([^"]+)" ]/"\1" "\2" ]/;
+        t split-triggers   # repeat until there are no commas
+
+      p
+      s/^.*$// # clear pattern space
+      N
+      /^\nexecute\sAddFormat\s/b next-fmt
+
+    # close the list
+    i\  ];
+    D # restart cycle from the current line
+  }
 
   # close attrmap
   /^$/i};
 }
+
+# add list of binaries from one of the architecture-specific packages
+/^name ([^.]+|texlive\.infra)\.x86_64-linux$/,/^$/{
+  s/^name ([0-9].*|texlive\.infra)\.x86_64-linux$/"\1".binfiles = [/p
+  s/^name (.*)\.x86_64-linux$/\1.binfiles = [/p
+  s!^ bin/x86_64-linux/(.+)$!  "\1"!p
+  /^$/i];
+}