nixpkgs/pkgs/tools/typesetting/tex/texlive/fixHashes.awk
Dmitry Kalinkin d9fb53ddd6
texlive: reimplement fixHashes.sh in GNU Awk
The shell script doesn't work very well in non-GNU environments like
darwin. This provides an implementation that uses just a single GNU tool
- gawk, thus reduces number of points of failure.
2020-03-15 14:56:16 -04:00

25 lines
445 B
Awk
Executable file

#!/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 "}"
}