summary refs log tree commit diff
path: root/pkgs/tools/typesetting/tex/texlive/fixHashes.awk
blob: 88ba0bc152899bfe8980fb43a14cba1135082110 (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 sha1 --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 "}"
}