1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
|
#!/usr/bin/env python3
# SPDX-License-Identifier: BSD-3-Clause
import hashlib
import json
import os
import sys
# This script is pretty hard-coded to assuming the three IWADs and
# URLs present as of the Freedoom 0.9 release. Not much can be done
# about that, but it will have to be changed whenever the project
# expands or switches web host.
iwads = {
"freedm.wad": {"description": "Deathmatch IWAD", "name": "FreeDM"},
"freedoom1.wad": {
"description": "Ultimate Doom compatible IWAD",
"name": "Freedoom: Phase 1",
},
"freedoom2.wad": {
"description": "Doom II compatible IWAD",
"name": "Freedoom: Phase 2",
},
}
# Find the version to generate JSON for:
version = os.getenv("VERSION")
# Find the file to append objects to:
json_file = os.getenv("JSON")
if version is None:
sys.stderr.write("Version is not specified for release\n")
sys.exit(1)
if version[0] is "v":
# Strip the leading "v" from versioning
version = version[1:]
if json_file is None:
sys.stderr.write("JSON file not specified!\n")
sys.exit(1)
with open("wads/freedoom1.wad", "rb") as f:
iwads["freedoom1.wad"]["md5"] = hashlib.md5(f.read()).hexdigest()
with open("wads/freedoom2.wad", "rb") as f:
iwads["freedoom2.wad"]["md5"] = hashlib.md5(f.read()).hexdigest()
with open("wads/freedm.wad", "rb") as f:
iwads["freedm.wad"]["md5"] = hashlib.md5(f.read()).hexdigest()
iwads["freedoom1.wad"]["url"] = (
"https://github.com/freedoom/freedoom/releases/download/v"
+ version
+ "/freedoom-"
+ version
+ ".zip"
)
iwads["freedoom1.wad"]["version"] = version
iwads["freedoom2.wad"]["url"] = (
"https://github.com/freedoom/freedoom/releases/download/v"
+ version
+ "/freedoom-"
+ version
+ ".zip"
)
iwads["freedoom2.wad"]["version"] = version
iwads["freedm.wad"]["url"] = (
"https://github.com/freedoom/freedoom/releases/download/v"
+ version
+ "/freedm-"
+ version
+ ".zip"
)
iwads["freedm.wad"]["version"] = version
with open(json_file, "w") as f:
json.dump(iwads, f, indent=2, sort_keys=True)
f.write("\n")
|