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.sed48
1 files changed, 23 insertions, 25 deletions
diff --git a/pkgs/tools/typesetting/tex/texlive/tl2nix.sed b/pkgs/tools/typesetting/tex/texlive/tl2nix.sed
index 94b10ba6f7765..7d48388cd39fa 100644
--- a/pkgs/tools/typesetting/tex/texlive/tl2nix.sed
+++ b/pkgs/tools/typesetting/tex/texlive/tl2nix.sed
@@ -14,11 +14,11 @@ $a}
 }
 
 # form an attrmap per package
-# ignore packages whose name contains "." (such as binaries)
-:next-package
+# ignore packages whose name contains "." (such as binaries) except for texlive.infra
 /^name ([^.]+|texlive\.infra)$/,/^$/{
-  # quote package names, as some start with a number :-/
-  s/^name (.*)$/"\1" = {/p
+  # quote invalid names
+  s/^name ([0-9].*|texlive\.infra)$/"\1" = {/p
+  s/^name (.*)$/\1 = {/p
 
   # extract revision
   s/^revision ([0-9]*)$/  revision = \1;/p
@@ -37,33 +37,34 @@ $a}
   s/^catalogue-version_(.*)/  version = "\1";/p
 
   # extract deps
-  /^depend [^.]+$/{
-    s/^depend (.+)$/  deps = [\n    "\1"/
+  /^depend ([^.]+|texlive\.infra)$/{
+    # open a list
+    i\  deps = [
 
     # loop through following depend lines
-    :next
-      h ; N     # save & read next line
-      s/\ndepend ([^.]+|texlive\.infra)$/\n    "\1"/
-      s/\ndepend (.+)$//
-      t next    # loop if the previous lines matched
-
-    x; s/$/\n  ];/p ; x     # print saved deps
-    s/^.*\n//   # remove deps, resume processing
+    :next-dep
+      s/^\n?depend ([^.]+|texlive\.infra)$/    "\1"/p # print dep
+      s/^.*$//                                        # clear pattern space
+      N; /^\ndepend /b next-dep
+
+    # close the list
+    i\  ];
+    D # restart cycle from the current line
   }
 
   # detect presence of notable files
   /^runfiles /{
-    s/^runfiles .*$//  # ignore the first line
+    s/^.*$//  # ignore the first line
+
+    # read all files
     :next-file
-      h ; N            # save to hold space & read next line
-      s!\n (.+)$! \1!  # save file name
-      t next-file      # loop if the previous lines matched
+      N
+      s/\n / /    # remove newline
+      t next-file # loop if previous line matched
 
-    x                  # work on saved lines in hold space
     / (RELOC|texmf-dist)\//i\  hasRunfiles = true;
     / tlpkg\//i\  hasTlpkg = true;
-    x                  # restore pattern space
-    s/^.*\n//          # remove saved lines, resume processing
+    D # restart cycle from the current line
   }
 
   # extract postaction scripts (right now, at most one per package, so a string suffices)
@@ -75,8 +76,5 @@ $a}
   /^execute\sAddFormat/i\  hasFormats = true;
 
   # close attrmap
-  /^$/{
-    i};
-    b next-package
-  }
+  /^$/i};
 }