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.
This commit is contained in:
Dmitry Kalinkin 2020-03-09 17:18:43 -04:00
parent a0cb913949
commit d9fb53ddd6
No known key found for this signature in database
GPG Key ID: 5157B3EC8B2CA333
3 changed files with 26 additions and 13 deletions

View File

@ -58,10 +58,9 @@ mv fixedHashes.nix fixedHashes-old.nix
# start with empty fixedHashes
echo '{}' > fixedHashes.nix
nix-build ../../../../.. -Q --no-out-link -A texlive.scheme-full.pkgs | ./fixHashes.sh > ./fixedHashes-new.nix
nix-build ../../../../.. -Q --no-out-link -A texlive.scheme-full.pkgs | ./fixHashes.awk > ./fixedHashes-new.nix
# The script wrongly includes the nix store path to `biber`, which is a separate nixpkgs package
grep -v -F '/nix/store/' fixedHashes-new.nix > fixedHashes.nix
mv fixedHashes-new.nix fixedHashes.nix
```
### Commit changes

View File

@ -0,0 +1,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 "}"
}

View File

@ -1,10 +0,0 @@
#!/bin/sh
echo "{"
grep -v -F '.bin-' | while read path; do
hash=`nix-hash --type sha1 --base32 "$path"`
echo -n "$path" | sed -E 's/[^-]*-texlive-(.*)/"\1"/'
echo "=\"$hash\";"
done
echo "}"