summary refs log tree commit diff
path: root/pkgs/tools/typesetting/tex/texlive/fixHashes.awk
blob: d9f1acd08eab240c60d55f117b73e12c03e51c71 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#!/usr/bin/env nix-shell
#! nix-shell -i "gawk -f" -p gawk

BEGIN {
  print "{"
}

/-texlive-/ && !/\.bin/ {
  if (match($0, /-texlive-([^\/]*)/, m) == 0) {
    print "No match for \""$0"\"" > "/dev/stderr"
    exit 1
  }
  cmd="nix-hash --type sha256 --base32 "$0
  if (( cmd | getline hash ) <= 0) {
    print "Error executing nix-hash" > "/dev/stderr"
    exit 1
  }
  close(cmd)
  printf("\"%s\"=\"%s\";\n", m[1], hash)
}

END {
  print "}"
}