mirror of
https://github.com/NixOS/nixpkgs.git
synced 2024-11-15 22:36:23 +01:00
cdd0ac7e54
game.json now contains a dictionary of old game hashes. I have added them for the last 3 releases. - add script to generate hashes Makes it much easier to update game.json file. - add updateScript meta This adds some info on the ./update.sh updateScript now available. - cleanup updateScript - Add some more systems - Correctly detect source extensions (.zip or .tar.bz2) - Proper bash quoting - fix update.sh - correctly detect latest df version - append to game.json instead of overwriting it - update hashes for 44.12
42 lines
1.3 KiB
Bash
Executable file
42 lines
1.3 KiB
Bash
Executable file
#!/usr/bin/env nix-shell
|
|
#! nix-shell -i bash -p jq nix coreutils curl
|
|
|
|
# systems to generate hashes for
|
|
systems='linux linux32 osx osx32
|
|
win win_s win32 win32_s
|
|
legacy legacy_s legacy32 legacy32_s'
|
|
|
|
if [ $# -eq 0 ]; then
|
|
versions="$(curl http://www.bay12games.com/dwarves/ \
|
|
| grep 'DOWNLOAD DWARF FORTRESS' \
|
|
| sed 's/.*DOWNLOAD DWARF FORTRESS \([0-9.]*\) .*/\1/')"
|
|
else
|
|
versions="$@"
|
|
fi
|
|
|
|
tmp1="$(mktemp)"
|
|
tmp2="$(mktemp)"
|
|
for version in $versions; do
|
|
for system in $systems; do
|
|
echo -n $version,$system,
|
|
ver=$(echo $version | sed -e s,^0\.,, | tr . _)
|
|
if [[ "$system" = *win* ]] || [[ "$system" = *legacy* ]]; then
|
|
ext=zip
|
|
else
|
|
ext=tar.bz2
|
|
fi
|
|
nix-prefetch-url \
|
|
http://www.bay12games.com/dwarves/df_${ver}_${system}.${ext}
|
|
done
|
|
done | jq --slurp --raw-input \
|
|
'split("\n") | .[:-1] | map(split(",")) |
|
|
map({ "version": .[0], "platform": .[1], "sha256": .[2] }) |
|
|
group_by(.version) |
|
|
map(map({"version": .version, (.platform): .sha256}) | add |
|
|
{(.version): .} | map_values(del(.version))) | add' \
|
|
> "$tmp1"
|
|
|
|
# Append $tmp1 to game.json. There should be a better way to handle
|
|
# this but all other attempts failed for me.
|
|
jq -M --argfile a "$tmp1" '. + $a' < "$(dirname "$0")/game.json" > "$tmp2"
|
|
cat "$tmp2" > "$(dirname "$0")/game.json"
|